Mercurial > evolve
diff hgext3rd/evolve/obshistory.py @ 2450:98613938d098
effectflag: basic diff change detection
We adds some basic diff detection.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 19 May 2017 20:15:05 +0200 |
parents | 0b05142117d2 |
children | ad08aedf25ac |
line wrap: on
line diff
--- 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