D2394: histedit: make histedit's commands accept revsets (issue5746)
sangeet259 (Sangeet Kumar Mishra)
phabricator at mercurial-scm.org
Sat Mar 24 17:22:10 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3d3cff1f6bde: histedit: make histedit's commands accept revsets (issue5746) (authored by sangeet259, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D2394?vs=6324&id=7272
REVISION DETAIL
https://phab.mercurial-scm.org/D2394
AFFECTED FILES
hgext/histedit.py
tests/test-histedit-arguments.t
CHANGE DETAILS
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -236,10 +236,10 @@
$ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
> pick eb57da33312f 2 three
- > pick 0
+ > pick 0u98
> pick 08d98a8350f3 4 five
> EOF
- hg: parse error: invalid changeset 0
+ hg: parse error: invalid changeset 0u98
[255]
Test short version of command
@@ -552,3 +552,39 @@
#
$ cd ..
+
+Check that histedit's commands accept revsets
+ $ hg init bar
+ $ cd bar
+ $ echo w >> a
+ $ hg ci -qAm "adds a"
+ $ echo x >> b
+ $ hg ci -qAm "adds b"
+ $ echo y >> c
+ $ hg ci -qAm "adds c"
+ $ echo z >> d
+ $ hg ci -qAm "adds d"
+ $ hg log -G -T '{rev} {desc}\n'
+ @ 3 adds d
+ |
+ o 2 adds c
+ |
+ o 1 adds b
+ |
+ o 0 adds a
+
+ $ HGEDITOR=cat hg histedit "2" --commands - << EOF
+ > base -4 adds c
+ > pick 2 adds c
+ > pick tip adds d
+ > EOF
+ $ hg log -G -T '{rev} {desc}\n'
+ @ 5 adds d
+ |
+ o 4 adds c
+ |
+ | o 1 adds b
+ |/
+ o 0 adds a
+
+
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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):
To: sangeet259, durin42, #hg-reviewers
Cc: pulkit, tom.prince, krbullock, rishabhmadan96, mercurial-devel
More information about the Mercurial-devel
mailing list