--- a/hgext3rd/evolve/obshistory.py Wed Jun 21 11:11:37 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py Tue Jun 20 16:22:16 2017 +0200
@@ -14,6 +14,7 @@
commands,
error,
graphmod,
+ mdiff,
patch,
obsolete,
node as nodemod,
@@ -145,7 +146,7 @@
extra = ' ' * indent
return "".join(extra + line for line in content.splitlines(True))
-def getmarkerpatch(repo, node, succ):
+def getmarkercontentpatch(repo, node, succ):
# Todo get the ops from the cmd
diffopts = patch.diffallopts(repo.ui, {})
matchfn = scmutil.matchall(repo)
@@ -157,6 +158,24 @@
return _indent(buffer)
+def getmarkerdescriptionpatch(repo, base, succ):
+ basectx = repo[base]
+ succctx = repo[succ]
+ basedesc = basectx.description() + '\n'
+ succdesc = succctx.description() + '\n'
+
+ # fake file name
+ basename = "%s-changeset-description" % basectx
+ succname = "%s-changeset-description" % succctx
+
+ d = mdiff.unidiff(basedesc, '', succdesc, '', basename, succname)
+ uheaders, hunks = d
+
+ # Copied from patch.diff
+ text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
+ patch = "\n".join(uheaders + [text])
+ return _indent(patch)
+
class missingchangectx(object):
''' a minimal object mimicking changectx for change contexts
references by obs markers but not available locally '''
@@ -455,13 +474,24 @@
if opts.get('patch'):
_patchavailable = patchavailable(node, repo, marker)
- if _patchavailable[0]:
- patch = getmarkerpatch(repo, node, _patchavailable[1])
+ if _patchavailable[0] is True:
+ succ = _patchavailable[1]
+
+ # Description patch
+ descriptionpatch = getmarkerdescriptionpatch(repo, node, succ)
+ if descriptionpatch:
+ fm.plain("\n")
+ fm.plain(descriptionpatch)
+
+ # Content patch
+ contentpatch = getmarkercontentpatch(repo, node, succ)
+ if contentpatch:
+ fm.plain("\n")
+ fm.plain(contentpatch)
else:
patch = " (No patch available yet, %s)" % _patchavailable[1]
- if patch:
fm.plain("\n")
- # should be in json too
+ # TODO: should be in json too
fm.plain(patch)
fm.plain("\n")