How I deleted my new files with good help from Mercurial

Steve Borho steve at borho.org
Wed Jun 30 18:48:29 UTC 2010


On Wed, Jun 30, 2010 at 1:41 PM, Daniel Carrera <dcarrera at gmail.com> wrote:
> On Wed, Jun 30, 2010 at 6:12 PM, Martin Geisler <mg at aragost.com> wrote:
>> Please give it a go -- you wont be the first who learned Python for this
>> exact reason :) We'll all be here to help you with the extension and you
>> are also welcome to ask in #mercurial.
>
> Is it difficult to extend Mercurial?

Probably too easy :)

>> What about calling it "cancel"? You use the command to cancel one or
>> more changesets. The backout command can only handle a single changeset,
>> but people often need to cancel several changesets. As long as they are
>> in sequence, the technique by Greg will work just fine.
>
> Actually, you can extend Greg's technique to non-sequential
> changesets, as long as they all line in a single branch. Here it is in
> Perl pseudo-code:
>
> 1) Let @revs be the list of revisions to cancel.
>
> ex: @revs = (7, 3, 6, 9, 12);
>
> 2) Sort @revs so the earliest revision is first:
>
> ex: @revs = (3, 6, 7, 9, 12);
>
> 3) Apply the Greg Manoeuvre inside a for loop:
>
> foreach $rev (@revs) {
>    hg update -c $rev
>    hg diff -c $rev --reverse | hg patch --no-commit -
> }
> # All done.
> hg update <original working directory>
> hg commit -m "Backout revisions: @revs"
>
>
> We just need to check that all the revisions are ancestors of the
> current working directory. As long as that is true, the above should
> work. Am I right?

I think you're making it more difficult than it needs be.  The user
could specify a revision range:

% hg cancel -r 3:12
{
hg up -c 12
hg diff -r 12:3 | hg patch --no-commit -
hg up orig
hg ci -m 'Backed out range...'
}

-- 
Steve Borho



More information about the Mercurial mailing list