diff 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
line wrap: on
line diff
--- a/hgext/histedit.py	Sat Mar 17 17:54:33 2018 +0900
+++ b/hgext/histedit.py	Fri Feb 23 11:48:58 2018 +0530
@@ -425,11 +425,18 @@
     def fromrule(cls, state, rule):
         """Parses the given rule, returning an instance of the histeditaction.
         """
-        rulehash = rule.strip().split(' ', 1)[0]
+        ruleid = rule.strip().split(' ', 1)[0]
+        # ruleid can be anything from rev numbers, hashes, "bookmarks" etc
+        # Check for validation of rule ids and get the rulehash
         try:
-            rev = node.bin(rulehash)
+            rev = node.bin(ruleid)
         except TypeError:
-            raise error.ParseError("invalid changeset %s" % rulehash)
+            try:
+                _ctx = scmutil.revsingle(state.repo, ruleid)
+                rulehash = _ctx.hex()
+                rev = node.bin(rulehash)
+            except error.RepoLookupError:
+                raise error.ParseError("invalid changeset %s" % ruleid)
         return cls(state, rev)
 
     def verify(self, prev, expected, seen):