# HG changeset patch # User Pierre-Yves David # Date 1444112221 25200 # Node ID e99c3846d78a0ee7e8abf6841da725513ac38a24 # Parent 1e8e0b01faba14e905d18b8dfc737125007e9e34 export: introduce a generic way to add patch header on export Extensions currently have no easy way to add data to exported patch. This is now fixed using a generic mechanism in the same fashion used by bundle2. Tests are coming in the next changeset with its first user. diff -r 1e8e0b01faba -r e99c3846d78a mercurial/cmdutil.py --- a/mercurial/cmdutil.py Mon Oct 05 00:23:20 2015 -0700 +++ b/mercurial/cmdutil.py Mon Oct 05 23:17:01 2015 -0700 @@ -991,6 +991,14 @@ lockmod.release(dsguard) os.unlink(tmpname) +# facility to let extensions include additional data in an exported patch +# list of identifiers to be executed in order +extraexport = [] +# mapping from identifier to actual export function +# function as to return a string to be added to the header or None +# it is given two arguments (sequencenumber, changectx) +extraexportmap = {} + def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, opts=None, match=None): '''export changesets as hg patches.''' @@ -1040,6 +1048,11 @@ write("# Parent %s\n" % hex(prev)) if len(parents) > 1: write("# Parent %s\n" % hex(parents[1])) + + for headerid in extraexport: + header = extraexportmap[headerid](seqno, ctx) + if header is not None: + write('# %s\n' % header) write(ctx.description().rstrip()) write("\n\n")