tag: shorten hash in default commit message
authorMatt Mackall <mpm@selenic.com>
Sun, 20 Aug 2006 23:52:52 -0500
changeset 2967 eef469259745
parent 2966 fb493241d7f6
child 2968 545d33aa3f82
child 2989 3091b1153e2c
child 2993 985594e891b8
tag: shorten hash in default commit message Move default message to commands.py Pass node in binary for consistency Remove default arguments Fix up tests
mercurial/commands.py
mercurial/localrepo.py
tests/test-hook.out
tests/test-parse-date.out
tests/test-tag.out
tests/test-tags.out
--- a/mercurial/commands.py	Sun Aug 20 22:51:56 2006 -0500
+++ b/mercurial/commands.py	Sun Aug 20 23:52:52 2006 -0500
@@ -2594,17 +2594,20 @@
     if opts['rev']:
         rev_ = opts['rev']
     if rev_:
-        r = hex(repo.lookup(rev_))
+        r = repo.lookup(rev_)
     else:
         p1, p2 = repo.dirstate.parents()
         if p1 == nullid:
             raise util.Abort(_('no revision to tag'))
         if p2 != nullid:
             raise util.Abort(_('outstanding uncommitted merges'))
-        r = hex(p1)
-
-    repo.tag(name, r, opts['local'], opts['message'], opts['user'],
-             opts['date'])
+        r = p1
+
+    message = opts['message']
+    if not message:
+        message = _('Added tag %s for changeset %s') % (name, short(r))
+
+    repo.tag(name, r, message, opts['local'], opts['user'], opts['date'])
 
 def tags(ui, repo):
     """list repository tags
--- a/mercurial/localrepo.py	Sun Aug 20 22:51:56 2006 -0500
+++ b/mercurial/localrepo.py	Sun Aug 20 23:52:52 2006 -0500
@@ -169,7 +169,7 @@
 
     tag_disallowed = ':\r\n'
 
-    def tag(self, name, node, local=False, message=None, user=None, date=None):
+    def tag(self, name, node, message, local, user, date):
         '''tag a revision with a symbolic name.
 
         if local is True, the tag is stored in a per-repository file.
@@ -191,11 +191,11 @@
             if c in name:
                 raise util.Abort(_('%r cannot be used in a tag name') % c)
 
-        self.hook('pretag', throw=True, node=node, tag=name, local=local)
+        self.hook('pretag', throw=True, node=hex(node), tag=name, local=local)
 
         if local:
-            self.opener('localtags', 'a').write('%s %s\n' % (node, name))
-            self.hook('tag', node=node, tag=name, local=local)
+            self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name))
+            self.hook('tag', node=hex(node), tag=name, local=local)
             return
 
         for x in self.status()[:5]:
@@ -203,15 +203,12 @@
                 raise util.Abort(_('working copy of .hgtags is changed '
                                    '(please commit .hgtags manually)'))
 
-        self.wfile('.hgtags', 'ab').write('%s %s\n' % (node, name))
+        self.wfile('.hgtags', 'ab').write('%s %s\n' % (hex(node), name))
         if self.dirstate.state('.hgtags') == '?':
             self.add(['.hgtags'])
 
-        if not message:
-            message = _('Added tag %s for changeset %s') % (name, node)
-
         self.commit(['.hgtags'], message, user, date)
-        self.hook('tag', node=node, tag=name, local=local)
+        self.hook('tag', node=hex(node), tag=name, local=local)
 
     def tags(self):
         '''return a mapping of tag to node'''
--- a/tests/test-hook.out	Sun Aug 20 22:51:56 2006 -0500
+++ b/tests/test-hook.out	Sun Aug 20 23:52:52 2006 -0500
@@ -36,43 +36,43 @@
 (run 'hg update' to get a working copy)
 pretag hook: t=a n=4c52fb2e402287dd5dc052090682536c8406c321 l=0
 precommit hook: p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
-pretxncommit hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
-4:4f92e785b90a
-commit hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
+pretxncommit hook: n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
+4:8ea2ef7ad3e8
+commit hook: n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
 commit hook b
 tag hook: t=a n=4c52fb2e402287dd5dc052090682536c8406c321 l=0
-pretag hook: t=la n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
-tag hook: t=la n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
-pretag hook: t=fa n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=0
+pretag hook: t=la n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 l=1
+tag hook: t=la n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 l=1
+pretag hook: t=fa n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 l=0
 pretag.forbid hook
 abort: pretag.forbid hook exited with status 1
-pretag hook: t=fla n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
+pretag hook: t=fla n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 l=1
 pretag.forbid hook
 abort: pretag.forbid hook exited with status 1
-4:4f92e785b90a
-precommit hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
-pretxncommit hook: n=7792358308a2026661cea44f9d47c072813004cb p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
-5:7792358308a2
-pretxncommit.forbid hook: tip=5:7792358308a2
+4:8ea2ef7ad3e8
+precommit hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2=
+pretxncommit hook: n=fad284daf8c032148abaffcd745dafeceefceb61 p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2=
+5:fad284daf8c0
+pretxncommit.forbid hook: tip=5:fad284daf8c0
 abort: pretxncommit.forbid hook exited with status 1
 transaction abort!
 rollback completed
-4:4f92e785b90a
-precommit hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
+4:8ea2ef7ad3e8
+precommit hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2=
 precommit.forbid hook
 abort: precommit.forbid hook exited with status 1
-4:4f92e785b90a
+4:8ea2ef7ad3e8
 preupdate hook: p1=b702efe9688826e3a91283852b328b84dbf37bc2 p2=
 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-preupdate hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
-update hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2= err=0
+preupdate hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2=
+update hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= err=0
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 3:4c52fb2e4022
 prechangegroup.forbid hook
 pulling from ../a
 searching for changes
 abort: prechangegroup.forbid hook exited with status 1
-pretxnchangegroup.forbid hook: tip=4:4f92e785b90a
+pretxnchangegroup.forbid hook: tip=4:8ea2ef7ad3e8
 pulling from ../a
 searching for changes
 adding changesets
@@ -84,7 +84,7 @@
 rollback completed
 3:4c52fb2e4022
 preoutgoing hook: s=pull
-outgoing hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 s=pull
+outgoing hook: n=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 s=pull
 pulling from ../a
 searching for changes
 adding changesets
--- a/tests/test-parse-date.out	Sun Aug 20 22:51:56 2006 -0500
+++ b/tests/test-parse-date.out	Sun Aug 20 23:52:52 2006 -0500
@@ -1,6 +1,6 @@
 reverting a
 changeset 3:107ce1ee2b43 backs out changeset 1:25a1420a55f8
-merging with changeset 2:99a1acecff55
+merging with changeset 2:e6c3abc120e7
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 abort: invalid date: 'should fail'
--- a/tests/test-tag.out	Sun Aug 20 22:51:56 2006 -0500
+++ b/tests/test-tag.out	Sun Aug 20 23:52:52 2006 -0500
@@ -4,11 +4,11 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     test
 
-changeset:   1:c5c60883086f
+changeset:   1:3ecf002a1c57
 tag:         tip
 user:        test
 date:        Mon Jan 12 13:46:40 1970 +0000
-summary:     Added tag bleah for changeset 0acdaf8983679e0aac16e811534eb49d7ee1f2b4
+summary:     Added tag bleah for changeset 0acdaf898367
 
 changeset:   0:0acdaf898367
 tag:         bleah
@@ -24,9 +24,9 @@
 use of 'hg tag NAME [REV]' is deprecated, please use 'hg tag [-r REV] NAME' instead
 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah
 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah0
-c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1
+3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar
-c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1
+3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1
 abort: '\n' cannot be used in a tag name
 abort: ':' cannot be used in a tag name
--- a/tests/test-tags.out	Sun Aug 20 22:51:56 2006 -0500
+++ b/tests/test-tags.out	Sun Aug 20 23:52:52 2006 -0500
@@ -16,21 +16,21 @@
 (branch merge, don't forget to commit)
 8216907a933d+8a3ca90d111d+ tip
 M .hgtags
-tip                                6:c6af9d771a81
+tip                                6:e2174d339386
 first                              0:0acdaf898367
-.hgtags (rev 7:39bba1bbbc4c), line 2: cannot parse entry
-.hgtags (rev 7:39bba1bbbc4c), line 4: node 'foo' is not well formed
+.hgtags (rev 7:c071f74ab5eb), line 2: cannot parse entry
+.hgtags (rev 7:c071f74ab5eb), line 4: node 'foo' is not well formed
 localtags, line 1: tag 'invalid' refers to unknown node
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-.hgtags (rev 7:39bba1bbbc4c), line 2: cannot parse entry
-.hgtags (rev 7:39bba1bbbc4c), line 4: node 'foo' is not well formed
+.hgtags (rev 7:c071f74ab5eb), line 2: cannot parse entry
+.hgtags (rev 7:c071f74ab5eb), line 4: node 'foo' is not well formed
 .hgtags (rev 8:4ca6f1b1a68c), line 2: node 'x' is not well formed
 localtags, line 1: tag 'invalid' refers to unknown node
 tip                                8:4ca6f1b1a68c
 first                              0:0acdaf898367
 changeset:   8:4ca6f1b1a68c
-.hgtags (rev 7:39bba1bbbc4c), line 2: cannot parse entry
-.hgtags (rev 7:39bba1bbbc4c), line 4: node 'foo' is not well formed
+.hgtags (rev 7:c071f74ab5eb), line 2: cannot parse entry
+.hgtags (rev 7:c071f74ab5eb), line 4: node 'foo' is not well formed
 .hgtags (rev 8:4ca6f1b1a68c), line 2: node 'x' is not well formed
 localtags, line 1: tag 'invalid' refers to unknown node
 tag:         tip