# HG changeset patch # User Pierre-Yves David # Date 1495217705 -7200 # Node ID 98613938d098d56412e043fe410cc9d041c2249f # Parent 0b05142117d2dbd0639d1f96f66fdab75f6a66b7 effectflag: basic diff change detection We adds some basic diff detection. diff --git a/hgext3rd/evolve/obshistory.py b/hgext3rd/evolve/obshistory.py --- a/hgext3rd/evolve/obshistory.py +++ b/hgext3rd/evolve/obshistory.py @@ -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 diff --git a/tests/test-evolve-effectflags.t b/tests/test-evolve-effectflags.t --- a/tests/test-evolve-effectflags.t +++ b/tests/test-evolve-effectflags.t @@ -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) +