Patchwork D3992: absorb: drop wrapper around the amend command

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 3:55 p.m.
Message ID <07187b8c00f1f5d01a03c732938e2bab@localhost.localdomain>
Download mbox | patch
Permalink /patch/33341/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 3:55 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8460c3cbca7e: absorb: drop wrapper around the amend command (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3992?vs=9765&id=9992

REVISION DETAIL
  https://phab.mercurial-scm.org/D3992

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb.t

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -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
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -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'))