Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 27155:8d3c5797a175
commit: add a way to return more information from the chunkselector
Before this patch, the chunkselector for record or crecord was used to return
the list of hunks that were selected by the user. The goal of this series is to
reintroduce the toggle amend feature for crecord. To do so, we need to be able
to return more than just the selected hunks from the chunkselector but also
the information: is amend mode toggled. This patch adds a new return value for
chunkselectors that will be used to implement the toggle amend feature in
crecord.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Mon, 30 Nov 2015 16:35:21 -0800 |
parents | 39163708825c |
children | ccae1588117f |
comparison
equal
deleted
inserted
replaced
27154:3bc7919fb215 | 27155:8d3c5797a175 |
---|---|
68 """ | 68 """ |
69 usecurses = ui.configbool('experimental', 'crecord', False) | 69 usecurses = ui.configbool('experimental', 'crecord', False) |
70 testfile = ui.config('experimental', 'crecordtest', None) | 70 testfile = ui.config('experimental', 'crecordtest', None) |
71 oldwrite = setupwrapcolorwrite(ui) | 71 oldwrite = setupwrapcolorwrite(ui) |
72 try: | 72 try: |
73 newchunks = filterchunks(ui, originalhunks, usecurses, testfile, | 73 newchunks, newopts = filterchunks(ui, originalhunks, usecurses, |
74 operation) | 74 testfile, operation) |
75 finally: | 75 finally: |
76 ui.write = oldwrite | 76 ui.write = oldwrite |
77 return newchunks | 77 return newchunks, newopts |
78 | 78 |
79 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, | 79 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |
80 filterfn, *pats, **opts): | 80 filterfn, *pats, **opts): |
81 import merge as mergemod | 81 import merge as mergemod |
82 | 82 |
119 originaldiff = patch.diff(repo, changes=status, opts=diffopts) | 119 originaldiff = patch.diff(repo, changes=status, opts=diffopts) |
120 originalchunks = patch.parsepatch(originaldiff) | 120 originalchunks = patch.parsepatch(originaldiff) |
121 | 121 |
122 # 1. filter patch, so we have intending-to apply subset of it | 122 # 1. filter patch, so we have intending-to apply subset of it |
123 try: | 123 try: |
124 chunks = filterfn(ui, originalchunks) | 124 chunks, newopts = filterfn(ui, originalchunks) |
125 except patch.PatchError as err: | 125 except patch.PatchError as err: |
126 raise error.Abort(_('error parsing patch: %s') % err) | 126 raise error.Abort(_('error parsing patch: %s') % err) |
127 opts.update(newopts) | |
127 | 128 |
128 # We need to keep a backup of files that have been newly added and | 129 # We need to keep a backup of files that have been newly added and |
129 # modified during the recording process because there is a previous | 130 # modified during the recording process because there is a previous |
130 # version without the edit in the workdir | 131 # version without the edit in the workdir |
131 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) | 132 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) |
3199 diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) | 3200 diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) |
3200 originalchunks = patch.parsepatch(diff) | 3201 originalchunks = patch.parsepatch(diff) |
3201 | 3202 |
3202 try: | 3203 try: |
3203 | 3204 |
3204 chunks = recordfilter(repo.ui, originalchunks) | 3205 chunks, opts = recordfilter(repo.ui, originalchunks) |
3205 if reversehunks: | 3206 if reversehunks: |
3206 chunks = patch.reversehunks(chunks) | 3207 chunks = patch.reversehunks(chunks) |
3207 | 3208 |
3208 except patch.PatchError as err: | 3209 except patch.PatchError as err: |
3209 raise error.Abort(_('error parsing patch: %s') % err) | 3210 raise error.Abort(_('error parsing patch: %s') % err) |