changeset 34015:2d80e078724a

tag: use filtered repo when creating new tags (issue5539) When pruning a changeset that added a tag and then adding another tag, the "pruned" tag gets restored. This is because the tag creation step (tags._tag() call in tags.tag()) is currently done on the unfiltered repo. This behavior has been there from 7977d35df13b which backs out b08af8f0ac01 with no clear reason but caution on unthought situations at that time. In this changeset, we pass the filtered repo to tags._tag(), preventing "pruned" tags to reappear. This somehow restores b08af8f0ac01, though now we arguably have a valid use case for.
author Denis Laxalde <denis@laxalde.org>
date Tue, 29 Aug 2017 11:25:22 +0200
parents 47e52f079a57
children 96f249dce03e
files mercurial/tags.py tests/test-tag.t
diffstat 2 files changed, 54 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/tags.py	Mon Aug 21 16:46:05 2017 -0700
+++ b/mercurial/tags.py	Tue Aug 29 11:25:22 2017 +0200
@@ -541,7 +541,7 @@
 
     with repo.wlock():
         repo.tags() # instantiate the cache
-        _tag(repo.unfiltered(), names, node, message, local, user, date,
+        _tag(repo, names, node, message, local, user, date,
              editor=editor)
 
 def _tag(repo, names, node, message, local, user, date, extra=None,
--- a/tests/test-tag.t	Mon Aug 21 16:46:05 2017 -0700
+++ b/tests/test-tag.t	Tue Aug 29 11:25:22 2017 +0200
@@ -411,6 +411,59 @@
   abort: cannot tag null revision
   [255]
 
+issue5539: pruned tags do not appear in .hgtags
+
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > stabilization=createmarkers,exchange
+  > EOF
+  $ hg up e4d483960b9b --quiet
+  $ echo aaa >>a
+  $ hg ci -maaa
+  $ hg log -r . -T "{node}\n"
+  743b3afd5aa69f130c246806e48ad2e699f490d2
+  $ hg tag issue5539
+  hook: tag changes detected
+  hook: +A 743b3afd5aa69f130c246806e48ad2e699f490d2 issue5539
+  $ cat .hgtags
+  acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
+  a0eea09de1eeec777b46f2085260a373b2fbc293 newline
+  743b3afd5aa69f130c246806e48ad2e699f490d2 issue5539
+  $ hg log -r . -T "{node}\n"
+  abeb261f0508ecebcd345ce21e7a25112df417aa
+(mimic 'hg prune' command by obsoleting current changeset and then moving to its parent)
+  $ hg debugobsolete abeb261f0508ecebcd345ce21e7a25112df417aa --record-parents
+  obsoleted 1 changesets
+  $ hg up ".^" --quiet
+  $ cat .hgtags
+  acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
+  a0eea09de1eeec777b46f2085260a373b2fbc293 newline
+  $ echo bbb >>a
+  $ hg ci -mbbb
+  $ hg log -r . -T "{node}\n"
+  089dd20da58cae34165c37b064539c6ac0c6a0dd
+  $ hg tag issue5539
+  hook: tag changes detected
+  hook: -M 743b3afd5aa69f130c246806e48ad2e699f490d2 issue5539
+  hook: +M 089dd20da58cae34165c37b064539c6ac0c6a0dd issue5539
+  $ hg id
+  0accf560a709 tip
+  $ cat .hgtags
+  acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
+  a0eea09de1eeec777b46f2085260a373b2fbc293 newline
+  089dd20da58cae34165c37b064539c6ac0c6a0dd issue5539
+  $ hg tags
+  tip                               19:0accf560a709
+  issue5539                         18:089dd20da58c
+  new-topo-head                     13:0f26aaea6f74
+  baz                               13:0f26aaea6f74
+  custom-tag                        12:75a534207be6
+  tag-and-branch-same-name          11:fc93d2ea1cd7
+  newline                            9:a0eea09de1ee
+  localnewline                       8:c2899151f4e7
+  localblah                          0:acb14030fe0a
+  foobar                             0:acb14030fe0a
+
   $ cd ..
 
 tagging on an uncommitted merge (issue2542)