Mercurial > hg
changeset 38923:8460c3cbca7e
absorb: drop wrapper around the amend command
We can reinstate this later if we want.
Differential Revision: https://phab.mercurial-scm.org/D3992
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 31 Jul 2018 11:29:25 -0400 |
parents | ec0697f4f9c9 |
children | 6fed8b323651 |
files | hgext/absorb.py tests/test-absorb.t |
diffstat | 2 files changed, 0 insertions(+), 114 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/absorb.py Wed Aug 01 18:30:10 2018 -0400 +++ b/hgext/absorb.py Tue Jul 31 11:29:25 2018 -0400 @@ -41,7 +41,6 @@ context, crecord, error, - extensions, linelog, mdiff, node, @@ -976,73 +975,3 @@ state = absorb(ui, repo, pats=pats, opts=opts) if sum(s[0] for s in state.chunkstats.values()) == 0: return 1 - -def _wrapamend(flag): - """add flag to amend, which will be a shortcut to the absorb command""" - if not flag: - return - amendcmd = extensions.bind(_amendcmd, flag) - # the amend command can exist in evolve, or fbamend - for extname in ['evolve', 'fbamend', None]: - try: - if extname is None: - cmdtable = commands.table - else: - ext = extensions.find(extname) - cmdtable = ext.cmdtable - except (KeyError, AttributeError): - continue - try: - entry = extensions.wrapcommand(cmdtable, 'amend', amendcmd) - options = entry[1] - msg = _('incorporate corrections into stack. ' - 'see \'hg help absorb\' for details') - options.append(('', flag, None, msg)) - return - except error.UnknownCommand: - pass - -def _amendcmd(flag, orig, ui, repo, *pats, **opts): - if not opts.get(flag): - return orig(ui, repo, *pats, **opts) - # use absorb - for k, v in opts.iteritems(): # check unsupported flags - if v and k not in ['interactive', flag]: - raise error.Abort(_('--%s does not support --%s') - % (flag, k.replace('_', '-'))) - state = absorb(ui, repo, pats=pats, opts=opts) - # different from the original absorb, tell users what chunks were - # ignored and were left. it's because users usually expect "amend" to - # take all of their changes and will feel strange otherwise. - # the original "absorb" command faces more-advanced users knowing - # what's going on and is less verbose. - adoptedsum = 0 - messages = [] - for path, (adopted, total) in state.chunkstats.iteritems(): - adoptedsum += adopted - if adopted == total: - continue - reason = _('%d modified chunks were ignored') % (total - adopted) - messages.append(('M', 'modified', path, reason)) - for idx, word, symbol in [(0, 'modified', 'M'), (1, 'added', 'A'), - (2, 'removed', 'R'), (3, 'deleted', '!')]: - paths = set(state.status[idx]) - set(state.paths) - for path in sorted(paths): - if word == 'modified': - reason = _('unsupported file type (ex. binary or link)') - else: - reason = _('%s files were ignored') % word - messages.append((symbol, word, path, reason)) - if messages: - ui.write(_('\n# changes not applied and left in ' - 'working directory:\n')) - for symbol, word, path, reason in messages: - ui.write(_('# %s %s : %s\n') % ( - ui.label(symbol, 'status.' + word), - ui.label(path, 'status.' + word), reason)) - - if adoptedsum == 0: - return 1 - -def extsetup(ui): - _wrapamend(ui.config('absorb', 'amendflag'))
--- a/tests/test-absorb.t Wed Aug 01 18:30:10 2018 -0400 +++ b/tests/test-absorb.t Tue Jul 31 11:29:25 2018 -0400 @@ -316,49 +316,6 @@ 8:5867d584106b commit a 2 fec2b3bd9e0834b7cb6a564348a0058171aed811 7:8c76602baf10 commit a 1 f9a81da8dc53380ed91902e5b82c1b36255a4bd0 -Test config option absorb.amendflags and running as a sub command of amend: - - $ cat >> $TESTTMP/dummyamend.py << EOF - > from mercurial import commands, registrar - > cmdtable = {} - > command = registrar.command(cmdtable) - > @command('amend', [], '') - > def amend(ui, repo, *pats, **opts): - > return 3 - > EOF - $ cat >> $HGRCPATH << EOF - > [extensions] - > fbamend=$TESTTMP/dummyamend.py - > [absorb] - > amendflag = correlated - > EOF - - $ hg amend -h - hg amend - - (no help text available) - - options: - - --correlated incorporate corrections into stack. see 'hg help absorb' for - details - - (some details hidden, use --verbose to show complete help) - - $ $PYTHON -c 'print("".join(map(chr, range(0,3))))' > c - $ hg commit -A c -m 'c is a binary file' - $ echo c >> c - $ sedi $'2i\\\nINS\n' b - $ echo END >> b - $ hg rm a - $ hg amend --correlated - 1 of 2 chunk(s) applied - - # changes not applied and left in working directory: - # M b : 1 modified chunks were ignored - # M c : unsupported file type (ex. binary or link) - # R a : removed files were ignored - Executable files: $ cat >> $HGRCPATH << EOF