tag: without a checkout, base the tag changeset on tip instead of nullid
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Mon, 08 Sep 2008 14:04:10 +0200
changeset 7009 3d54cf97598d
parent 7008 8fee8ff13d37
child 7010 9141bebefe3e
child 7016 58dcf10eea2b
tag: without a checkout, base the tag changeset on tip instead of nullid issue916
mercurial/localrepo.py
tests/test-tag-issue916
tests/test-tag-issue916.out
--- a/mercurial/localrepo.py	Mon Sep 08 13:07:00 2008 +0200
+++ b/mercurial/localrepo.py	Mon Sep 08 14:04:10 2008 +0200
@@ -221,7 +221,13 @@
                 raise util.Abort(_('working copy of .hgtags is changed '
                                    '(please commit .hgtags manually)'))
 
-        self._tag(names, node, message, local, user, date)
+        parents = self[None].parents()
+        parent = None
+        # use tip instead of the parent rev if there's no working copy
+        # (avoid creating a new head)
+        if len(parents) == 1 and parents[0].node() == nullid:
+            parent = self['tip'].node()
+        self._tag(names, node, message, local, user, date, parent=parent)
 
     def tags(self):
         '''return a mapping of tag to node'''
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-tag-issue916	Mon Sep 08 14:04:10 2008 +0200
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+hg init
+echo a > a
+hg commit -Am "test" -d "1000000 0"
+
+echo % issue 916
+hg up 000000
+hg parents
+hg tag -r tip -d "1000000 0" "jglick"
+echo % should it be removed ?
+cat .hgtags
+hg tip
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-tag-issue916.out	Mon Sep 08 14:04:10 2008 +0200
@@ -0,0 +1,11 @@
+adding a
+% issue 916
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+% should it be removed ?
+0acdaf8983679e0aac16e811534eb49d7ee1f2b4 jglick
+changeset:   1:99b47705d075
+tag:         tip
+user:        test
+date:        Mon Jan 12 13:46:40 1970 +0000
+summary:     Added tag jglick for changeset 0acdaf898367
+