diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -70,11 +70,11 @@ def recordfilter(ui, originalhunks, oper testfile = ui.config('experimental', 'crecordtest', None) oldwrite = setupwrapcolorwrite(ui) try: - newchunks = filterchunks(ui, originalhunks, usecurses, testfile, - operation) + newchunks, newopts = filterchunks(ui, originalhunks, usecurses, + testfile, operation) finally: ui.write = oldwrite - return newchunks + return newchunks, newopts def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, filterfn, *pats, **opts): @@ -121,9 +121,10 @@ def dorecord(ui, repo, commitfunc, cmdsu # 1. filter patch, so we have intending-to apply subset of it try: - chunks = filterfn(ui, originalchunks) + chunks, newopts = filterfn(ui, originalchunks) except patch.PatchError as err: raise error.Abort(_('error parsing patch: %s') % err) + opts.update(newopts) # We need to keep a backup of files that have been newly added and # modified during the recording process because there is a previous @@ -3201,7 +3202,7 @@ def _performrevert(repo, parents, ctx, a try: - chunks = recordfilter(repo.ui, originalchunks) + chunks, opts = recordfilter(repo.ui, originalchunks) if reversehunks: chunks = patch.reversehunks(chunks) diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -454,7 +454,7 @@ def filterpatch(ui, chunks, chunkselecto uiheaders = [uiheader(h) for h in headers] # let user choose headers/hunks/lines, and mark their applied flags # accordingly - chunkselector(ui, uiheaders) + ret = chunkselector(ui, uiheaders) appliedhunklist = [] for hdr in uiheaders: if (hdr.applied and @@ -472,7 +472,7 @@ def filterpatch(ui, chunks, chunkselecto else: fixoffset += hnk.removed - hnk.added - return appliedhunklist + return (appliedhunklist, ret) def gethw(): """ @@ -501,6 +501,7 @@ def chunkselector(ui, headerlist): raise error.Abort(chunkselector.initerr) # ncurses does not restore signal handler for SIGTSTP signal.signal(signal.SIGTSTP, f) + return chunkselector.opts def testdecorator(testfn, f): def u(*args, **kwargs): @@ -521,6 +522,7 @@ def testchunkselector(testfn, ui, header while True: if chunkselector.handlekeypressed(testcommands.pop(0), test=True): break + return chunkselector.opts class curseschunkselector(object): def __init__(self, headerlist, ui): @@ -528,6 +530,7 @@ class curseschunkselector(object): self.headerlist = patch(headerlist) self.ui = ui + self.opts = {} self.errorstr = None # list of all chunks diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1106,8 +1106,8 @@ the hunk is left unchanged. applied[newhunk.filename()].append(newhunk) else: fixoffset += chunk.removed - chunk.added - return sum([h for h in applied.itervalues() - if h[0].special() or len(h) > 1], []) + return (sum([h for h in applied.itervalues() + if h[0].special() or len(h) > 1], []), {}) class hunk(object): def __init__(self, desc, num, lr, context): self.number = num