changeset 29875:478e4a2a9952

histedit: make 'constraints' a class attribute instead of a method There does not seem to be a reason for this to be a method. So we initialise the class attribute once and for all at creation time and drop the instance method.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 26 Aug 2016 20:34:58 +0200
parents 0099e29fc95c
children 034d38b5f6fb
files hgext/histedit.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Fri Aug 26 20:31:33 2016 +0200
+++ b/hgext/histedit.py	Fri Aug 26 20:34:58 2016 +0200
@@ -392,6 +392,8 @@
         self.repo = state.repo
         self.node = node
 
+    constraints = set([_constraints.noduplicates, _constraints.noother])
+
     @classmethod
     def fromrule(cls, state, rule):
         """Parses the given rule, returning an instance of the histeditaction.
@@ -434,11 +436,6 @@
         """
         return "%s\n%s" % (self.verb, node.hex(self.node))
 
-    def constraints(self):
-        """Return a set of constrains that this action should be verified for
-        """
-        return set([_constraints.noduplicates, _constraints.noother])
-
     def run(self):
         """Runs the action. The default behavior is simply apply the action's
         rulectx onto the current parentctx."""
@@ -776,8 +773,7 @@
         return repo[n], replacements
 
 class base(histeditaction):
-    def constraints(self):
-        return set([_constraints.forceother])
+    constraints = set([_constraints.forceother])
 
     def run(self):
         if self.repo['.'].node() != self.node:
@@ -1383,7 +1379,7 @@
     for action in actions:
         action.verify(prev)
         prev = action
-        constraints = action.constraints()
+        constraints = action.constraints
         for constraint in constraints:
             if constraint not in _constraints.known():
                 raise error.ParseError(_('unknown constraint "%s"') %