Patchwork [04,of,10] effectflag: detect when description changed

login
register
mail settings
Submitter Boris Feld
Date July 7, 2017, 12:38 p.m.
Message ID <a00ff3d815d246d40a0a.1499431113@FB>
Download mbox | patch
Permalink /patch/22091/
State Changes Requested
Headers show

Comments

Boris Feld - July 7, 2017, 12:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499345554 -7200
#      Thu Jul 06 14:52:34 2017 +0200
# Node ID a00ff3d815d246d40a0add309119e98373f5d9f5
# Parent  f5418d3695e7533ddc67917c423d976b367d52d6
# EXP-Topic effectflag
effectflag: detect when description changed

Store in effect flag when the description changed between the predecessor and
its successors.

It can happens with "hg commit --amend", "hg amend" or "histedit".

Patch

diff -r f5418d3695e7 -r a00ff3d815d2 mercurial/obsutil.py
--- a/mercurial/obsutil.py	Thu Jul 06 14:51:08 2017 +0200
+++ b/mercurial/obsutil.py	Thu Jul 06 14:52:34 2017 +0200
@@ -536,6 +536,9 @@ 
                 cache[current] = final
     return cache[initialnode]
 
+# logic around storing and using effect flags
+DESCCHANGED = 1 << 0 # action changed the description
+
 def geteffectflag(relation):
     """ From an obs-marker relation, compute what changed between the
     predecessor and the successor.
@@ -544,4 +547,9 @@ 
 
     source = relation[0]
 
+    for changectx in relation[1]:
+        # Check if description has changed
+        if changectx.description() != source.description():
+            effects |= DESCCHANGED
+
     return effects
diff -r f5418d3695e7 -r a00ff3d815d2 tests/test-obsmarkers-effectflag.t
--- a/tests/test-obsmarkers-effectflag.t	Thu Jul 06 14:51:08 2017 +0200
+++ b/tests/test-obsmarkers-effectflag.t	Thu Jul 06 14:52:34 2017 +0200
@@ -29,7 +29,7 @@ 
 check result
 
   $ hg debugobsolete --rev .
-  471f378eab4c5e25f6c77f785b27c936efb22874 fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'user': 'test'}
+  471f378eab4c5e25f6c77f785b27c936efb22874 fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'user': 'test'}
 
 amend touching the user only
 ----------------------------
@@ -109,7 +109,7 @@ 
 
   $ hg debugobsolete --rev .
   3b12912003b4e7aa6df6cded86255006c3c29d27 0 {fad47e5bd78e6aa4db1b5a0a1751bc12563655ff} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'user': 'test'}
-  fad47e5bd78e6aa4db1b5a0a1751bc12563655ff a94e0fd5f1c81d969381a76eb0d37ce499a44fae 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'user': 'test'}
+  fad47e5bd78e6aa4db1b5a0a1751bc12563655ff a94e0fd5f1c81d969381a76eb0d37ce499a44fae 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'user': 'test'}
 
 rebase not touching the diff
 ----------------------------