effectflag: basic diff change detection
We adds some basic diff detection.
--- a/hgext3rd/evolve/obshistory.py Fri May 19 19:52:57 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py Fri May 19 20:15:05 2017 +0200
@@ -361,6 +361,7 @@
DESCCHANGED = 1 << 0 # action changed the description
METACHANGED = 1 << 1 # action change the meta (user, date, branch, etc...)
PARENTCHANGED = 1 << 2 # action change the parent
+DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset
def geteffectflag(relation):
"""compute the effect flag by comparing the source and destination"""
@@ -387,8 +388,34 @@
if changectx.parents() != source.parents():
effects |= PARENTCHANGED
+ if not _cmpdiff(source, changectx):
+ effects |= DIFFCHANGED
+
return effects
+def _getdiffline(iterdiff):
+ """return a cleaned up line"""
+ try:
+ line = iterdiff.next()
+ except StopIteration:
+ return None
+ return line
+
+def _cmpdiff(leftctx, rightctx):
+ """return True if both ctx introduce the "same diff"
+
+ This is a first and basic implementation, with many shortcoming.
+ """
+ leftdiff = leftctx.diff(git=1)
+ rightdiff = rightctx.diff(git=1)
+ left, right = (0, 0)
+ while None not in (left, right):
+ left = _getdiffline(leftdiff)
+ right = _getdiffline(rightdiff)
+ if left != right:
+ return False
+ return True
+
@eh.wrapfunction(obsolete, 'createmarkers')
def createmarkerswithbits(orig, repo, relations, flag=0, date=None, metadata=None):
"""compute 'effect-flag' and augment the created markers
--- a/tests/test-evolve-effectflags.t Fri May 19 19:52:57 2017 +0200
+++ b/tests/test-evolve-effectflags.t Fri May 19 20:15:05 2017 +0200
@@ -71,3 +71,22 @@
x 2ee0a31bd600 (6) D0
rewritten by test (*) as 131ac3eecd92 (glob)
+
+amend touching the diff
+-----------------------
+
+ $ mkcommit E0
+ $ echo 42 >> E0
+ $ hg amend
+
+check result
+
+ $ hg debugobsolete --rev .
+ 5734caf1004261ffc2ed05763b82bf9d75ba3788 0 {f75604747b4fd2dfebe7f48c6e629aea15e3b237} (*) {'ef1': '0', 'user': 'test'} (glob)
+ f75604747b4fd2dfebe7f48c6e629aea15e3b237 bed7e49faeb8ae06649b547a755d50f5bb0be220 0 (*) {'ef1': '8', 'user': 'test'} (glob)
+ $ hg obslog .
+ @ bed7e49faeb8 (10) E0
+ |
+ x f75604747b4f (8) E0
+ rewritten by test (*) as bed7e49faeb8 (glob)
+