Bug 5746 - hg histedit's base command should accept revsets
Summary: hg histedit's base command should accept revsets
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: histedit (show other bugs)
Version: unspecified
Hardware: PC Linux
: wish feature
Assignee: Bugzilla
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2017-11-18 11:08 UTC by Tom Prince
Modified: 2018-04-07 00:00 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Prince 2017-11-18 11:08 UTC
Often when I want rebase in histedit, I just know a symbolic name for the revision I want to base my changes on. I'd like to be able to specify it directly, without having to look it up and copy the node.
Comment 1 Augie Fackler 2017-11-20 17:43 UTC
This should be easy if someone wants to tackle it (it's bugged me too, so I'd be an enthusiastic mentor if someone wants to get into hg patching)
Comment 2 Sangeet Kumar Mishra 2018-02-10 10:13 UTC
Hey Augie, I would like to contribute, can you guide me?
Comment 3 Augie Fackler 2018-02-10 18:11 UTC
Sure. I think the change needs to happen in here:

    def verify(self, prev, expected, seen):
        """ Verifies semantic correctness of the rule"""
        repo = self.repo
        ha = node.hex(self.node)
        try:
            self.node = repo[ha].node()
        except error.RepoError:
            raise error.ParseError(_('unknown changeset %s listed')
                              % ha[:12])
        if self.node is not None:
            self._verifynodeconstraints(prev, expected, seen)

(hgext/histedit.py, around line 440). Specifically, the repo[ha].node() needs to switch to something else, probably mercurial.scmutil.revsingle(ha).node()? Then some testing needs to be added in one of the tests/test*histedit*.t files. Those test files are "literate" shell scripts - hopefully the format is self-documenting, but if it's not let me know and I'll see about documenting it some more.

Is that enough to get started?

Once you're ready, follow the steps on https://www.mercurial-scm.org/wiki/ContributingChanges (Phabricator is probably easiest for you, but if you want to try email that's great) to send the patch to us for review. Don't be shy about sending something that's not perfect: we've all been new to programming and still make mistakes on a regular basis, and we're happy to help you learn.
Comment 4 Sangeet Kumar Mishra 2018-02-17 12:10 UTC
Hey Augie,
I have been working on this,
Just to be sure of the problem, we want to be able to do stuff like :
"pick 5 adds a.py"
"pick 6 adds b.py"

and not just : 
"pick 1de6393a6654 adds a.py"
"pick 8f2c447dce28 adds b.py"

Am I correct?
Comment 5 Kevin Bullock 2018-02-17 17:43 UTC
(In reply to Sangeet Kumar Mishra from comment #4)
Nope, this isn't about specifying revisions in the plan -- it's about specifying the base revision on the command line, i.e. `hg histedit REV`. That REV should be able to accept a revset.
Comment 6 Augie Fackler 2018-02-17 19:21 UTC
Kevin, it's also about the `base` verb in the commands list. I think that one should take a revset, but probably not the other ones (eg pick and roll). Does that make sense?
Comment 7 Sangeet Kumar Mishra 2018-02-17 21:33 UTC
(In reply to Kevin Bullock from comment #5)
But it does accept REVSET from the command line.

ie if my log history is : 

changeset:   2:2543d74b14d5
tag:         tip
user:        Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
date:        Wed Feb 14 00:56:56 2018 +0530
summary:     adds c

changeset:   1:c364c46f4a04
user:        Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
date:        Wed Feb 14 00:56:34 2018 +0530
summary:     adds b

changeset:   0:51ebae99897b
user:        Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
date:        Wed Feb 14 00:56:03 2018 +0530
summary:     added a.py


Then, $hg histedit 0    | it does work!
Comment 8 Sangeet Kumar Mishra 2018-02-23 09:55 UTC
(In reply to Augie Fackler from comment #6)
Issue fixed in https://phab.mercurial-scm.org/D2394
Comment 9 HG Bot 2018-03-30 12:30 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/3d3cff1f6bde
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
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

(please test the fix)
Comment 10 Bugzilla 2018-04-07 00:00 UTC
Bug was set to TESTING for 7 days, resolving