Patchwork [08,of,10] effectflag: detect when parents changed

login
register
mail settings
Submitter Boris Feld
Date July 7, 2017, 12:38 p.m.
Message ID <96a9902a0c2a2c93e7e2.1499431117@FB>
Download mbox | patch
Permalink /patch/22097/
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 1499345776 -7200
#      Thu Jul 06 14:56:16 2017 +0200
# Node ID 96a9902a0c2a2c93e7e2a672fb682c845cfcbb88
# Parent  194f5c17a9d460ac0376c9d5dd215c8d6222b3ed
# EXP-Topic effectflag
effectflag: detect when parents changed

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

It can happens with "hg rebase" or "hg grab".

Patch

diff -r 194f5c17a9d4 -r 96a9902a0c2a mercurial/obsutil.py
--- a/mercurial/obsutil.py	Thu Jul 06 14:55:12 2017 +0200
+++ b/mercurial/obsutil.py	Thu Jul 06 14:56:16 2017 +0200
@@ -538,6 +538,7 @@ 
 
 # logic around storing and using effect flags
 DESCCHANGED = 1 << 0 # action changed the description
+PARENTCHANGED = 1 << 2 # action change the parent
 USERCHANGED = 1 << 4 # the user changed
 DATECHANGED = 1 << 5 # the date changed
 BRANCHCHANGED = 1 << 6 # the branch changed
@@ -567,4 +568,8 @@ 
         if changectx.branch() != source.branch():
             effects |= BRANCHCHANGED
 
+        # Check if at least one of the parent has changed
+        if changectx.parents() != source.parents():
+            effects |= PARENTCHANGED
+
     return effects
diff -r 194f5c17a9d4 -r 96a9902a0c2a tests/test-obsmarkers-effectflag.t
--- a/tests/test-obsmarkers-effectflag.t	Thu Jul 06 14:55:12 2017 +0200
+++ b/tests/test-obsmarkers-effectflag.t	Thu Jul 06 14:56:16 2017 +0200
@@ -82,7 +82,7 @@ 
 check result
 
   $ hg debugobsolete --rev .
-  c85eff83a0340efd9da52b806a94c350222f3371 da86aa2f19a30d6686b15cae15c7b6c908ec9699 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'user': 'test'}
+  c85eff83a0340efd9da52b806a94c350222f3371 da86aa2f19a30d6686b15cae15c7b6c908ec9699 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'user': 'test'}
 
 amend touching the diff
 -----------------------
@@ -153,7 +153,7 @@ 
   rebasing 20:b57fed8d8322 "H1"
   merging H0
   $ hg debugobsolete -r tip
-  b57fed8d83228a8ae3748d8c3760a77638dd4f8c e509e2eb3df5d131ff7c02350bf2a9edd0c09478 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'user': 'test'}
+  b57fed8d83228a8ae3748d8c3760a77638dd4f8c e509e2eb3df5d131ff7c02350bf2a9edd0c09478 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'user': 'test'}
 
 amend closing the branch should be detected as meta change
 ----------------------------------------------------------