[PATCH] histedit: do not check experimental.histediting in extsetup

Jun Wu quark at fb.com
Wed Mar 9 03:49:26 UTC 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1457490597 0
#      Wed Mar 09 02:29:57 2016 +0000
# Node ID 4886a03b8b2b779cf9cf69a5dc29a2b4e8b24c52
# Parent  ffd3ac07b1d79dda7f57bd826208fdaf92a76717
histedit: do not check experimental.histediting in extsetup

chgserver only hashes [extensions] as confighash. It expects extensions to not
have global side effects depending on configs in {ui,ext}setup. Otherwise,
if related configs are changed, but the [extensions] section remains same,
a same chgserver will be reused and the extensions will still have the old
behavior.

This patch fixes the issue by moving experimental.histediting check out from
extsetup.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -219,6 +219,13 @@
 secondaryactions = set()
 tertiaryactions = set()
 internalactions = set()
+hiddenactions = set()
+
+def _updatehiddenactions(ui):
+    hiddenactions.clear()
+    if not ui.configbool("experimental", "histeditng"):
+        hiddenactions.add('base')
+        hiddenactions.add('b')
 
 def geteditcomment(first, last):
     """ construct the editor comment
@@ -250,7 +257,8 @@
          sorted(secondaryactions) +
          sorted(tertiaryactions)
         ):
-        addverb(v)
+        if v not in hiddenactions:
+            addverb(v)
     actions.append('')
 
     return ''.join(['# %s\n' % l if l else '#\n'
@@ -782,6 +790,8 @@
             replacements.append((ich, (n,)))
         return repo[n], replacements
 
+ at action(['base', 'b'],
+        _('checkout changeset and apply further changesets from there'))
 class base(histeditaction):
     def constraints(self):
         return set([_constraints.forceother])
@@ -1048,6 +1058,7 @@
     state.keep = opts.get('keep', False)
 
     _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs)
+    _updatehiddenactions(ui)
 
     # rebuild state
     if goal == goalcontinue:
@@ -1321,7 +1332,7 @@
             raise error.ParseError(_('malformed line "%s"') % r)
         verb, rest = r.split(' ', 1)
 
-        if verb not in actiontable:
+        if verb not in actiontable or verb in hiddenactions:
             raise error.ParseError(_('unknown action "%s"') % verb)
 
         action = actiontable[verb].fromrule(state, rest)
@@ -1581,7 +1592,3 @@
          _("use 'hg histedit --continue' or 'hg histedit --abort'")])
     cmdutil.afterresolvedstates.append(
         ['histedit-state', _('hg histedit --continue')])
-    if ui.configbool("experimental", "histeditng"):
-        globals()['base'] = action(['base', 'b'],
-            _('checkout changeset and apply further changesets from there')
-        )(base)


More information about the Mercurial-devel mailing list