D3992: absorb: drop wrapper around the amend command

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Wed Aug 1 15:17:40 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We can reinstate this later if we want.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

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
@@ -36,7 +36,6 @@
     context,
     crecord,
     error,
-    extensions,
     linelog,
     mdiff,
     node,
@@ -969,73 +968,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'))



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


More information about the Mercurial-devel mailing list