comparison hgext/histedit.py @ 37106:3d3cff1f6bde

histedit: make histedit's commands accept revsets (issue5746) Earlier the code was only looking for rulehashes and neglecting all other revision identifiers, this code intercepts the fromrule function and calls scmutil.revsingle() on anything that is not a rulehash and then obtains the rulehash from the changectx object returned, rest of the pipeline follows as it was Differential Revision: https://phab.mercurial-scm.org/D2394
author Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
date Fri, 23 Feb 2018 11:48:58 +0530
parents f0b6fbea00cf
children 0351fb0153ba
comparison
equal deleted inserted replaced
37105:e7bc0667c521 37106:3d3cff1f6bde
423 423
424 @classmethod 424 @classmethod
425 def fromrule(cls, state, rule): 425 def fromrule(cls, state, rule):
426 """Parses the given rule, returning an instance of the histeditaction. 426 """Parses the given rule, returning an instance of the histeditaction.
427 """ 427 """
428 rulehash = rule.strip().split(' ', 1)[0] 428 ruleid = rule.strip().split(' ', 1)[0]
429 # ruleid can be anything from rev numbers, hashes, "bookmarks" etc
430 # Check for validation of rule ids and get the rulehash
429 try: 431 try:
430 rev = node.bin(rulehash) 432 rev = node.bin(ruleid)
431 except TypeError: 433 except TypeError:
432 raise error.ParseError("invalid changeset %s" % rulehash) 434 try:
435 _ctx = scmutil.revsingle(state.repo, ruleid)
436 rulehash = _ctx.hex()
437 rev = node.bin(rulehash)
438 except error.RepoLookupError:
439 raise error.ParseError("invalid changeset %s" % ruleid)
433 return cls(state, rev) 440 return cls(state, rev)
434 441
435 def verify(self, prev, expected, seen): 442 def verify(self, prev, expected, seen):
436 """ Verifies semantic correctness of the rule""" 443 """ Verifies semantic correctness of the rule"""
437 repo = self.repo 444 repo = self.repo