# HG changeset patch # User Pierre-Yves David # Date 1472236498 -7200 # Node ID 478e4a2a9952aafb31269691f231546a5ad4b725 # Parent 0099e29fc95ce5108d616e3d2fdaa5e7c333fde0 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. diff -r 0099e29fc95c -r 478e4a2a9952 hgext/histedit.py --- 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"') %