Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 290:07c6cb9fd1c5
replace hg branch with hg init [source]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
replace hg branch with hg init [source]
This does the hardlink trick if both repos are on the same filesystem,
otherwise it does a pull.
manifest hash: 780a3a0aca6e4a535909c6221ee94394701ec1c9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCp5anywK+sNU5EO8RArdDAJ9Tiia0YZmZ6xiTYdKhZJ2UZY8V5wCfeoPy
DamQ2Zyz3yTjNqu4ge0CuRQ=
=EXv5
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 08 Jun 2005 17:08:55 -0800 |
parents | 266396e32006 |
children | 11d64332a1cb |
comparison
equal
deleted
inserted
replaced
289:266396e32006 | 290:07c6cb9fd1c5 |
---|---|
150 m = max(map(len, l)) | 150 m = max(map(len, l)) |
151 pieces.append([ "%*s" % (m, x) for x in l]) | 151 pieces.append([ "%*s" % (m, x) for x in l]) |
152 | 152 |
153 for p,l in zip(zip(*pieces), lines): | 153 for p,l in zip(zip(*pieces), lines): |
154 u.write(" ".join(p) + ": " + l[1]) | 154 u.write(" ".join(p) + ": " + l[1]) |
155 | |
156 def branch(ui, path): | |
157 '''branch from a local repository''' | |
158 # this should eventually support remote repos | |
159 os.system("cp -al %s/.hg .hg" % path) | |
160 | 155 |
161 def cat(ui, repo, file, rev = []): | 156 def cat(ui, repo, file, rev = []): |
162 """output the latest or given revision of a file""" | 157 """output the latest or given revision of a file""" |
163 r = repo.file(relpath(repo, [file])[0]) | 158 r = repo.file(relpath(repo, [file])[0]) |
164 n = r.tip() | 159 n = r.tip() |
279 time.localtime(float(changes[2].split(' ')[0]))) | 274 time.localtime(float(changes[2].split(' ')[0]))) |
280 if ui.verbose: print "files:", " ".join(changes[3]) | 275 if ui.verbose: print "files:", " ".join(changes[3]) |
281 print "description:" | 276 print "description:" |
282 print changes[4] | 277 print changes[4] |
283 | 278 |
284 def init(ui): | 279 def init(ui, source=None): |
285 """create a repository""" | 280 """create a new repository or copy an existing one""" |
286 hg.repository(ui, ".", create=1) | 281 |
287 | 282 if source: |
283 paths = {} | |
284 for name, path in ui.configitems("paths"): | |
285 paths[name] = path | |
286 | |
287 if source in paths: source = paths[source] | |
288 | |
289 link = 0 | |
290 if not source.startswith("http://"): | |
291 d1 = os.stat(os.getcwd()).st_dev | |
292 d2 = os.stat(source).st_dev | |
293 if d1 == d2: link = 1 | |
294 | |
295 if link: | |
296 ui.debug("copying by hardlink\n") | |
297 os.system("cp -al %s/.hg .hg" % source) | |
298 else: | |
299 repo = hg.repository(ui, ".", create=1) | |
300 other = hg.repository(ui, source) | |
301 cg = repo.getchangegroup(other) | |
302 repo.addchangegroup(cg) | |
303 else: | |
304 hg.repository(ui, ".", create=1) | |
305 | |
288 def log(ui, repo, f): | 306 def log(ui, repo, f): |
289 """show the revision history of a single file""" | 307 """show the revision history of a single file""" |
290 f = relpath(repo, [f])[0] | 308 f = relpath(repo, [f])[0] |
291 | 309 |
292 r = repo.file(f) | 310 r = repo.file(f) |
365 | 383 |
366 def pull(ui, repo, source): | 384 def pull(ui, repo, source): |
367 """pull changes from the specified source""" | 385 """pull changes from the specified source""" |
368 paths = {} | 386 paths = {} |
369 for name, path in ui.configitems("paths"): | 387 for name, path in ui.configitems("paths"): |
370 paths[name] = path | 388 paths[name] = path |
371 | 389 |
372 if source in paths: source = paths[source] | 390 if source in paths: source = paths[source] |
373 | 391 |
374 other = hg.repository(ui, source) | 392 other = hg.repository(ui, source) |
375 cg = repo.getchangegroup(other) | 393 cg = repo.getchangegroup(other) |
482 [('r', 'revision', '', 'revision'), | 500 [('r', 'revision', '', 'revision'), |
483 ('u', 'user', None, 'show user'), | 501 ('u', 'user', None, 'show user'), |
484 ('n', 'number', None, 'show revision number'), | 502 ('n', 'number', None, 'show revision number'), |
485 ('c', 'changeset', None, 'show changeset')], | 503 ('c', 'changeset', None, 'show changeset')], |
486 'hg annotate [-u] [-c] [-n] [-r id] [files]'), | 504 'hg annotate [-u] [-c] [-n] [-r id] [files]'), |
487 "branch|clone": (branch, [], 'hg branch [path]'), | |
488 "cat|dump": (cat, [], 'hg cat <file> [rev]'), | 505 "cat|dump": (cat, [], 'hg cat <file> [rev]'), |
489 "commit|ci": (commit, | 506 "commit|ci": (commit, |
490 [('t', 'text', "", 'commit text'), | 507 [('t', 'text', "", 'commit text'), |
491 ('l', 'logfile', "", 'commit text file')], | 508 ('l', 'logfile', "", 'commit text file')], |
492 'hg commit [files]'), | 509 'hg commit [files]'), |
499 "export": (export, [], "hg export <changeset>"), | 516 "export": (export, [], "hg export <changeset>"), |
500 "forget": (forget, [], "hg forget [files]"), | 517 "forget": (forget, [], "hg forget [files]"), |
501 "heads": (heads, [], 'hg heads'), | 518 "heads": (heads, [], 'hg heads'), |
502 "history": (history, [], 'hg history'), | 519 "history": (history, [], 'hg history'), |
503 "help": (help, [], 'hg help [command]'), | 520 "help": (help, [], 'hg help [command]'), |
504 "init": (init, [], 'hg init'), | 521 "init": (init, [], 'hg init [url]'), |
505 "log": (log, [], 'hg log <file>'), | 522 "log": (log, [], 'hg log <file>'), |
506 "manifest|dumpmanifest": (manifest, [], 'hg manifest [rev]'), | 523 "manifest|dumpmanifest": (manifest, [], 'hg manifest [rev]'), |
507 "parents": (parents, [], 'hg parents [node]'), | 524 "parents": (parents, [], 'hg parents [node]'), |
508 "patch|import": (patch, | 525 "patch|import": (patch, |
509 [('p', 'strip', 1, 'path strip'), | 526 [('p', 'strip', 1, 'path strip'), |