Mercurial > hg
changeset 26557:23f3f1cbd53b
extract: add some facility for extensible header parsing
We need a way for extension to extend the header we can parse. We start with a
very simple mechanism that will be used in the next changeset.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 07 Oct 2015 01:20:49 -0700 |
parents | 2bef84fad19f |
children | fe52cd049f01 |
files | mercurial/patch.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Tue Oct 06 02:16:24 2015 -0700 +++ b/mercurial/patch.py Wed Oct 07 01:20:49 2015 -0700 @@ -151,6 +151,10 @@ # if we are here, we have a very plain patch return remainder(cur) +## Some facility for extensible patch parsing: +# list of pairs ("header to match", "data key") +patchheadermap = [] + def extract(ui, fileobj): '''extract patch from data read from fileobj. @@ -238,7 +242,12 @@ data['nodeid'] = line[10:] elif line.startswith("# Parent "): parents.append(line[9:].lstrip()) - elif not line.startswith("# "): + elif line.startswith("# "): + for header, key in patchheadermap: + prefix = '# %s ' % header + if line.startswith(prefix): + data[key] = line[len(prefix):] + else: hgpatchheader = False elif line == '---': ignoretext = True