hgext/histedit.py
changeset 29879 478e4a2a9952
parent 29878 0099e29fc95c
child 29880 034d38b5f6fb
equal deleted inserted replaced
29878:0099e29fc95c 29879:478e4a2a9952
   390     def __init__(self, state, node):
   390     def __init__(self, state, node):
   391         self.state = state
   391         self.state = state
   392         self.repo = state.repo
   392         self.repo = state.repo
   393         self.node = node
   393         self.node = node
   394 
   394 
       
   395     constraints = set([_constraints.noduplicates, _constraints.noother])
       
   396 
   395     @classmethod
   397     @classmethod
   396     def fromrule(cls, state, rule):
   398     def fromrule(cls, state, rule):
   397         """Parses the given rule, returning an instance of the histeditaction.
   399         """Parses the given rule, returning an instance of the histeditaction.
   398         """
   400         """
   399         rulehash = rule.strip().split(' ', 1)[0]
   401         rulehash = rule.strip().split(' ', 1)[0]
   431     def tostate(self):
   433     def tostate(self):
   432         """Print an action in format used by histedit state files
   434         """Print an action in format used by histedit state files
   433            (the first line is a verb, the remainder is the second)
   435            (the first line is a verb, the remainder is the second)
   434         """
   436         """
   435         return "%s\n%s" % (self.verb, node.hex(self.node))
   437         return "%s\n%s" % (self.verb, node.hex(self.node))
   436 
       
   437     def constraints(self):
       
   438         """Return a set of constrains that this action should be verified for
       
   439         """
       
   440         return set([_constraints.noduplicates, _constraints.noother])
       
   441 
   438 
   442     def run(self):
   439     def run(self):
   443         """Runs the action. The default behavior is simply apply the action's
   440         """Runs the action. The default behavior is simply apply the action's
   444         rulectx onto the current parentctx."""
   441         rulectx onto the current parentctx."""
   445         self.applychange()
   442         self.applychange()
   774         for ich in internalchanges:
   771         for ich in internalchanges:
   775             replacements.append((ich, (n,)))
   772             replacements.append((ich, (n,)))
   776         return repo[n], replacements
   773         return repo[n], replacements
   777 
   774 
   778 class base(histeditaction):
   775 class base(histeditaction):
   779     def constraints(self):
   776     constraints = set([_constraints.forceother])
   780         return set([_constraints.forceother])
       
   781 
   777 
   782     def run(self):
   778     def run(self):
   783         if self.repo['.'].node() != self.node:
   779         if self.repo['.'].node() != self.node:
   784             mergemod.update(self.repo, self.node, False, True)
   780             mergemod.update(self.repo, self.node, False, True)
   785             #                                     branchmerge, force)
   781             #                                     branchmerge, force)
  1381     seen = set()
  1377     seen = set()
  1382     prev = None
  1378     prev = None
  1383     for action in actions:
  1379     for action in actions:
  1384         action.verify(prev)
  1380         action.verify(prev)
  1385         prev = action
  1381         prev = action
  1386         constraints = action.constraints()
  1382         constraints = action.constraints
  1387         for constraint in constraints:
  1383         for constraint in constraints:
  1388             if constraint not in _constraints.known():
  1384             if constraint not in _constraints.known():
  1389                 raise error.ParseError(_('unknown constraint "%s"') %
  1385                 raise error.ParseError(_('unknown constraint "%s"') %
  1390                         constraint)
  1386                         constraint)
  1391 
  1387