Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 401:af4848f83e68
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
add hg tag command
Tweaks by mpm:
clean up error messages
handle non-existent .hgtags file
add tests
update test-help output
manifest hash: 569c7fe01193159919af2566e8f5089409ffad65
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCuMMwywK+sNU5EO8RAuUdAJ90TkT/D9lDOnEVAW2d3WT7K8Ct3QCggiJA
c9Qbd79K4UWKQAVkYq03cOY=
=SWS8
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 21 Jun 2005 17:47:28 -0800 |
parents | 8f8bb77d560e |
children | fda7bb480020 |
comparison
equal
deleted
inserted
replaced
400:8b067bde6679 | 401:af4848f83e68 |
---|---|
563 | 563 |
564 for f in c: print "C", f | 564 for f in c: print "C", f |
565 for f in a: print "A", f | 565 for f in a: print "A", f |
566 for f in d: print "R", f | 566 for f in d: print "R", f |
567 for f in u: print "?", f | 567 for f in u: print "?", f |
568 | |
569 def tag(ui, repo, name, rev = None, **opts): | |
570 """add a tag for the current tip or a given revision""" | |
571 | |
572 if name == "tip": | |
573 ui.warn("abort: 'tip' is a reserved name!\n") | |
574 return -1 | |
575 | |
576 (c, a, d, u) = repo.diffdir(repo.root) | |
577 for x in (c, a, d, u): | |
578 if ".hgtags" in x: | |
579 ui.warn("abort: working copy of .hgtags is changed!\n") | |
580 ui.status("(please commit .hgtags manually)\n") | |
581 return -1 | |
582 | |
583 if rev: | |
584 r = hg.hex(repo.lookup(rev)) | |
585 else: | |
586 r = hg.hex(repo.changelog.tip()) | |
587 | |
588 add = 0 | |
589 if not os.path.exists(repo.wjoin(".hgtags")): add = 1 | |
590 repo.wfile(".hgtags", "a").write("%s %s\n" % (r, name)) | |
591 if add: repo.add([".hgtags"]) | |
592 | |
593 if not opts['text']: | |
594 opts['text'] = "Added tag %s for changeset %s" % (name, r) | |
595 | |
596 repo.commit([".hgtags"], opts['text'], opts['user'], opts['date']) | |
568 | 597 |
569 def tags(ui, repo): | 598 def tags(ui, repo): |
570 """list repository tags""" | 599 """list repository tags""" |
571 | 600 |
572 l = repo.tagslist() | 601 l = repo.tagslist() |
665 ('a', 'address', '', 'interface address'), | 694 ('a', 'address', '', 'interface address'), |
666 ('n', 'name', os.getcwd(), 'repository name'), | 695 ('n', 'name', os.getcwd(), 'repository name'), |
667 ('t', 'templates', "", 'template map')], | 696 ('t', 'templates', "", 'template map')], |
668 "hg serve [options]"), | 697 "hg serve [options]"), |
669 "status": (status, [], 'hg status'), | 698 "status": (status, [], 'hg status'), |
699 "tag": (tag, [('t', 'text', "", 'commit text'), | |
700 ('d', 'date', "", 'date'), | |
701 ('u', 'user', "", 'user')], | |
702 'hg tag [options] <name> [rev]'), | |
670 "tags": (tags, [], 'hg tags'), | 703 "tags": (tags, [], 'hg tags'), |
671 "tip": (tip, [], 'hg tip'), | 704 "tip": (tip, [], 'hg tip'), |
672 "undo": (undo, [], 'hg undo'), | 705 "undo": (undo, [], 'hg undo'), |
673 "update|up|checkout|co|resolve": (update, | 706 "update|up|checkout|co|resolve": (update, |
674 [('m', 'merge', None, | 707 [('m', 'merge', None, |