Patchwork tag: use filtered repo when creating new tags (issue5539)

login
register
mail settings
Submitter Denis Laxalde
Date Aug. 29, 2017, 1:58 p.m.
Message ID <ce974213f13d44b27db1.1504015125@marimba>
Download mbox | patch
Permalink /patch/23461/
State Accepted
Headers show

Comments

Denis Laxalde - Aug. 29, 2017, 1:58 p.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1503998722 -7200
#      Tue Aug 29 11:25:22 2017 +0200
# Node ID ce974213f13d44b27db13f4f1ae07849135362b2
# Parent  b1f75d8e887a4c06e6b120807f3defc5c7b78d33
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.
Augie Fackler - Aug. 30, 2017, 6:18 p.m.
On Tue, Aug 29, 2017 at 03:58:45PM +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1503998722 -7200
> #      Tue Aug 29 11:25:22 2017 +0200
> # Node ID ce974213f13d44b27db13f4f1ae07849135362b2
> # Parent  b1f75d8e887a4c06e6b120807f3defc5c7b78d33
> tag: use filtered repo when creating new tags (issue5539)

queued, thanks
via Mercurial-devel - Aug. 31, 2017, 5:48 a.m.
On Tue, Aug 29, 2017 at 6:58 AM, Denis Laxalde <denis@laxalde.org> wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1503998722 -7200
> #      Tue Aug 29 11:25:22 2017 +0200
> # Node ID ce974213f13d44b27db13f4f1ae07849135362b2
> # Parent  b1f75d8e887a4c06e6b120807f3defc5c7b78d33
> 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.

Perhaps this is safe since b061a2049662?

>
> diff --git a/mercurial/tags.py b/mercurial/tags.py
> --- a/mercurial/tags.py
> +++ b/mercurial/tags.py
> @@ -541,7 +541,7 @@ def tag(repo, names, node, message, loca
>
>      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,
> diff --git a/tests/test-tag.t b/tests/test-tag.t
> --- a/tests/test-tag.t
> +++ b/tests/test-tag.t
> @@ -411,6 +411,59 @@ tagging on null rev
>    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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -541,7 +541,7 @@  def tag(repo, names, node, message, loca
 
     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,
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -411,6 +411,59 @@  tagging on null rev
   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)