d42bf856ee09 — Martijn Pieters 8 years ago
Make fbamend responsible for supporting automv.

Summary:
This facilitates moving automv out of this repository to Mercurial proper.
Use extensions.afterloaded() to avoid relying on module load order.

Test Plan: Run the test suite with ../../hg/tests/run-tests.py

Reviewers: rmcelroy, durham

Differential Revision: https://phabricator.fb.com/D2896456
2 files changed, 11 insertions(+), 7 deletions(-)

M automv.py
M fbamend.py
M automv.py +0 -7
@@ 19,13 19,6 @@ def extsetup(ui):
     entry = wrapcommand(commands.table, 'commit', mvcheck)
     entry[1].append(('', 'no-move-detection', None,
          _('disable automatic' + 'file move detection')))
-    try:
-        module = extensions.find('fbamend')
-        entry = wrapcommand(module.cmdtable, 'amend', mvcheck)
-        entry[1].append(('', 'no-move-detection', None,
-             _('disable automatic' + 'file move detection')))
-    except KeyError:
-        pass
 
 def mvcheck(orig, ui, repo, *pats, **opts):
     if not opts.get('no_move_detection'):

          
M fbamend.py +11 -0
@@ 58,6 58,17 @@ def uisetup(ui):
        ] + amendopts + commands.walkopts + commands.commitopts,
        _('hg amend [OPTION]...'))(amend)
 
+    def has_automv(loaded):
+        if not loaded:
+            return
+        automv = extensions.find('automv')
+        entry = extensions.wrapcommand(cmdtable, 'amend', automv.mvcheck)
+        entry[1].append(
+            ('', 'no-move-detection', None,
+             _('disable automatic file move detection')))
+    extensions.afterloaded('automv', has_automv)
+
+
 def commit(orig, ui, repo, *pats, **opts):
     if opts.get("amend"):
         # commit --amend default behavior is to prompt for edit