Patchwork [RFC] localrepo: don't reintroduce pruned tag entries when tagging

login
register
mail settings
Submitter Matt Harbison
Date Oct. 2, 2014, 1:17 a.m.
Message ID <480f18c9c5350a23da06.1412212670@Envy>
Download mbox | patch
Permalink /patch/6080/
State Superseded
Commit 6584016b3e4bb75ef3e965c7288c7ad7f964f51a
Headers show

Comments

Matt Harbison - Oct. 2, 2014, 1:17 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1412209593 14400
#      Wed Oct 01 20:26:33 2014 -0400
# Node ID 480f18c9c5350a23da06608547599e22689892dd
# Parent  939ce500c92a3dcc0e10815242361ff70a6fcae9
localrepo: don't reintroduce pruned tag entries when tagging

(Please don't queue this as-is.  It can be applied to core hg for testing, but
the test probably needs to be split out and applied to hg-evolve after dropping
the evolve=... line in the hgrc file.  All tests in core 939ce500c92a and
hg-evolve 5d574b92203c run cleanly with this change, but it undoes something
Pierre-Yves did, so I'm not sure if it is safe.)

If a commit and a followup tag commit are pruned, there are no references to it
in any non obsolete version of .hgtags.  Without this change however, the next
time a tag is added to another branch, the obsolete references are appended in
.hgtags before the new entries for the current tag command.

The annotation to unfilter localrepo._tag() has been around since b3af182a1944.
The log message for it mentions computing the tag cache though, so I'm not sure
if this was misplaced?  It doesn't look like this method built the tag cache
though, then or now.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -482,7 +482,6 @@ 
         """
         return hook.hook(self.ui, self, name, throw, **args)
 
-    @unfilteredmethod
     def _tag(self, names, node, message, local, user, date, extra={},
              editor=False):
         if isinstance(names, str):
diff --git a/tests/test-evolve-tag.t b/tests/test-evolve-tag.t
new file mode 100644
--- /dev/null
+++ b/tests/test-evolve-tag.t
@@ -0,0 +1,77 @@ 
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > rebase =
+  > evolve = C:\Users\Matt\Projects\hg-evolve\hgext\evolve.py
+  > EOF
+
+  $ hg init a
+  $ cd a
+  $ touch foo
+  $ hg add foo
+  $ hg ci -mfoo
+  $ touch bar
+  $ hg add bar
+  $ hg ci -mbar
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ touch quux
+  $ hg add quux
+  $ hg ci -m quux
+  created new head
+  $ hg up 1
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg tag 1.0
+
+  $ hg up 2
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg log -G
+  o  changeset:   3:bc47fc7e1c1d
+  |  tag:         tip
+  |  parent:      1:50c889141114
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added tag 1.0 for changeset 50c889141114
+  |
+  | @  changeset:   2:3d7f255a0081
+  | |  parent:      0:1f7b0de80e11
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     quux
+  | |
+  o |  changeset:   1:50c889141114
+  |/   tag:         1.0
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     bar
+  |
+  o  changeset:   0:1f7b0de80e11
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     foo
+  
+  $ hg kill 1::
+  2 changesets pruned
+  $ hg tag 1.0
+  $ hg log -G
+  @  changeset:   4:f9f2ab71ffd5
+  |  tag:         tip
+  |  parent:      2:3d7f255a0081
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added tag 1.0 for changeset 3d7f255a0081
+  |
+  o  changeset:   2:3d7f255a0081
+  |  tag:         1.0
+  |  parent:      0:1f7b0de80e11
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     quux
+  |
+  o  changeset:   0:1f7b0de80e11
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     foo
+  
+  $ cat .hgtags
+  3d7f255a008103380aeb2a7d581fe257f40969e7 1.0
+