changeset 2647:46182568b4ce

change 'hg tag' to tag the parent rev instead of tip
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 21 Jul 2006 01:40:07 +0200
parents 02b6fa7bbfbf
children f47432ae5376
files mercurial/commands.py tests/test-tag tests/test-tag.out
diffstat 3 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jul 19 07:56:40 2006 -0700
+++ b/mercurial/commands.py	Fri Jul 21 01:40:07 2006 +0200
@@ -2651,7 +2651,7 @@
     very useful to compare different revision, to go back to significant
     earlier versions or to mark branch points as releases, etc.
 
-    If no revision is given, the tip is used.
+    If no revision is given, the parent of the working directory is used.
 
     To facilitate version control, distribution, and merging of tags,
     they are stored as a file named ".hgtags" which is managed
@@ -2671,7 +2671,12 @@
     if rev_:
         r = hex(repo.lookup(rev_))
     else:
-        r = hex(repo.changelog.tip())
+        p1, p2 = repo.dirstate.parents()
+        if p1 == nullid:
+            raise util.Abort(_('no revision to tag'))
+        if p2 != nullid:
+            raise util.Abort(_('outstanding uncommited merges'))
+        r = hex(p1)
 
     repo.tag(name, r, opts['local'], opts['message'], opts['user'],
              opts['date'])
--- a/tests/test-tag	Wed Jul 19 07:56:40 2006 -0700
+++ b/tests/test-tag	Fri Jul 21 01:40:07 2006 +0200
@@ -19,6 +19,11 @@
 cat .hgtags
 cat .hg/localtags
 
+hg update 0
+hg tag -d "1000000 0" "foobar"
+cat .hgtags
+cat .hg/localtags
+
 hg tag -l 'xx
 newline'
 hg tag -l 'xx:xx'
--- a/tests/test-tag.out	Wed Jul 19 07:56:40 2006 -0700
+++ b/tests/test-tag.out	Fri Jul 21 01:40:07 2006 +0200
@@ -25,5 +25,8 @@
 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah
 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah0
 c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar
+c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1
 abort: '\n' cannot be used in a tag name
 abort: ':' cannot be used in a tag name