Patchwork [5,of,5,topic-experiment] topics: add an extrafield "topic_change_source "to prevent hash cycle

login
register
mail settings
Submitter Pulkit Goyal
Date June 21, 2017, 2:09 a.m.
Message ID <675753af7aa6855a183c.1498010966@workspace>
Download mbox | patch
Permalink /patch/21571/
State Accepted
Headers show

Comments

Pulkit Goyal - June 21, 2017, 2:09 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1498010531 -19800
#      Wed Jun 21 07:32:11 2017 +0530
# Node ID 675753af7aa6855a183c674fab69f00400f35813
# Parent  fd9e563f9e2b12615231839c847f42a98b5581fd
topics: add an extrafield "topic_change_source "to prevent hash cycle

If we have a changeset with topic `x`, we change it's topic to `y`, fine.
When we change it's topic back again to `x`, we get the hash of the the
obsoleted changeset which had the topic `x` initially. The same happens for few
more cases like clearing the topic of a changeset which initially had no topic.

This approach is influenced from cmdutil.amend.
Pierre-Yves David - June 21, 2017, 11:49 a.m.
On 06/21/2017 04:09 AM, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1498010531 -19800
> #      Wed Jun 21 07:32:11 2017 +0530
> # Node ID 675753af7aa6855a183c674fab69f00400f35813
> # Parent  fd9e563f9e2b12615231839c847f42a98b5581fd
> topics: add an extrafield "topic_change_source "to prevent hash cycle

I've pushed this series many thanks.

For this last one, I've renamed "topic_change_source" to 
"_rewrite_noise" (because I'm not sure behing command specific make 
sense here). I'm not fully convinced by the new name, but we can 
re-adjust this later if needed.

I've also pushed a fix for the working copy lagging behind have `hg 
topic --rev . foo`.

Cheers,

Patch

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -329,6 +329,7 @@ 
                 del fixedextra[constants.extrakey]
             else:
                 fixedextra[constants.extrakey] = newtopic
+            fixedextra[constants.changekey] = c.hex()
             if 'amend_source' in fixedextra:
                 # TODO: right now the commitctx wrapper in
                 # topicrepo overwrites the topic in extra if
diff --git a/hgext3rd/topic/constants.py b/hgext3rd/topic/constants.py
--- a/hgext3rd/topic/constants.py
+++ b/hgext3rd/topic/constants.py
@@ -1,1 +1,2 @@ 
 extrakey = 'topic'
+changekey = 'topic_change_source'
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -556,7 +556,7 @@ 
   changed topic on 1 changes
   please run hg evolve --rev "not topic()" now
   $ hg log -Gr 'draft() and not obsolete()'
-  o  changeset:   11:783930e1d79e
+  o  changeset:   11:441b61d558fc
   |  tag:         tip
   |  parent:      3:a53952faf762
   |  user:        test
@@ -581,7 +581,7 @@ 
   changed topic on 1 changes
   please run hg evolve --rev "topic(wat)" now
   $ hg log -Gr 'draft() and not obsolete()'
-  o  changeset:   13:d91cd8fd490e
+  o  changeset:   13:174bd31a8f4c
   |  tag:         tip
   |  topic:       wat
   |  parent:      3:a53952faf762
@@ -589,7 +589,7 @@ 
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     start on fran
   |
-  | @  changeset:   12:d9e32f4c4806
+  | @  changeset:   12:3e5965b66515
   | |  user:        test
   | |  date:        Thu Jan 01 00:00:00 1970 +0000
   | |  trouble:     unstable
@@ -600,17 +600,17 @@ 
 bonus deps in the testsuite.
 
   $ hg rebase -d tip -s .
-  rebasing 12:d9e32f4c4806 "fran?"
+  rebasing 12:3e5965b66515 "fran?"
 
   $ hg log -Gr 'draft()'
-  @  changeset:   14:cf24ad8bbef5
+  @  changeset:   14:d1f7e958b66c
   |  tag:         tip
   |  topic:       wat
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     fran?
   |
-  o  changeset:   13:d91cd8fd490e
+  o  changeset:   13:174bd31a8f4c
   |  topic:       wat
   |  parent:      3:a53952faf762
   |  user:        test
@@ -623,15 +623,15 @@ 
   $ hg topic watwat
   $ hg ci --amend
   $ hg log -Gr 'draft()'
-  @  changeset:   16:893ffcf66c1f
+  @  changeset:   16:3b23f609880b
   |  tag:         tip
   |  topic:       watwat
-  |  parent:      13:d91cd8fd490e
+  |  parent:      13:174bd31a8f4c
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     fran?
   |
-  o  changeset:   13:d91cd8fd490e
+  o  changeset:   13:174bd31a8f4c
   |  topic:       wat
   |  parent:      3:a53952faf762
   |  user:        test
@@ -644,9 +644,9 @@ 
   $ hg topic --clear
   $ hg ci --amend
   $ hg log -r .
-  changeset:   18:a13639e22b65
+  changeset:   18:44d7f9376d6a
   tag:         tip
-  parent:      13:d91cd8fd490e
+  parent:      13:174bd31a8f4c
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     fran?
@@ -659,15 +659,15 @@ 
   $ hg co 19
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -Gr 'draft()'
-  @  changeset:   19:b72b86a1f96b
+  @  changeset:   19:4ea5df7d3ff8
   |  tag:         tip
   |  topic:       watwat
-  |  parent:      13:d91cd8fd490e
+  |  parent:      13:174bd31a8f4c
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     fran?
   |
-  o  changeset:   13:d91cd8fd490e
+  o  changeset:   13:174bd31a8f4c
   |  topic:       wat
   |  parent:      3:a53952faf762
   |  user:        test
@@ -679,28 +679,28 @@ 
   changed topic on 2 changes
   please run hg evolve --rev "topic(changewat)" now
   $ hg log -Gr 'draft()'
-  o  changeset:   21:58e15a6365ca
+  o  changeset:   21:6e2eb1738e3f
   |  tag:         tip
   |  topic:       changewat
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     fran?
   |
-  o  changeset:   20:a96ac830b62e
+  o  changeset:   20:f0ac69c44c45
   |  topic:       changewat
   |  parent:      3:a53952faf762
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     start on fran
   |
-  | @  changeset:   19:b72b86a1f96b
+  | @  changeset:   19:4ea5df7d3ff8
   | |  topic:       watwat
-  | |  parent:      13:d91cd8fd490e
+  | |  parent:      13:174bd31a8f4c
   | |  user:        test
   | |  date:        Thu Jan 01 00:00:00 1970 +0000
   | |  summary:     fran?
   | |
-  | x  changeset:   13:d91cd8fd490e
+  | x  changeset:   13:174bd31a8f4c
   |/   topic:       wat
   |    parent:      3:a53952faf762
   |    user:        test