tla undo/redo like functionality for hg
Giorgos Keramidas
keramida at ceid.upatras.gr
Tue Nov 28 12:16:30 UTC 2006
On 2006-11-28 11:04, Stefan Reich?r <stefan at xsteve.at> wrote:
>"Benoit Boissinot" <bboissin at gmail.com> writes:
>> On 11/28/06, Stefan Reich?r <stefan at xsteve.at> wrote:
>>> Hi!
>>>
>>> One very useful of GNU Arch is that I can undo all current changes
>>> and store them in a directory.
>>>
>>> Later I can redo that saved changes.
>>>
>>>
>>> How can I do that with hg?
>>>
>>> I could start like this:
>>>
>>> % hg diff --git > changeset.diff
>>> % hg revert --no-backup
>>>
>>> ...
>>>
>>> How can I redo now my changes?
>>> % hg import changeset.diff
>>> That command will commit the changes. Is there a way to apply the
>>> changes without committing?
>>
>> patch -p1 < changeset.diff ? (this may have problem with git patches)
>
> Exactly. It would be nice, if mercurial has a command to apply a patch
> without committing it.
>
> What about "hg import --no-commit"
>
>> But the easiest way is with mq:
>>
>> hg qnew -f changeset.diff
>> hg qpop
>> hg qpush
>
> I have several questions to this suggestion:
>
> a) Can I save several changesets (changeset1.diff, changeset2.diff)
> and apply them in arbitrary order?
> b) Is the patch recorded in the repository? And if yes, can I
> delete this patch from the repository.
Yes. MQ is the Mercurial "patch queue" extension. It does *exactly*
what question (a) is about.
To answer question (b) with an example...
Patches are stored in .hg/patches/ and the .hg/patches/ directory is a
versioned Mercurial repository itself, so you can even apply normal SCM
practices to the patch queue itself.
For example, here's a patch queue with 3 patches stacked on top of each
other from a doc/ tree I am working on for FreeBSD:
% cd ~/hg/doc/keramida
% hg qseries -s
danger-jails-chapter: Add a new Handbook chapter about "Jails" by *danger*
danger-jails-fixups: Handbook "jails" chapter fixups by *keramida*
danger-jails-whitespace: Handbook "jails" chapter whitespace fixups by *keramida*
%
The first patch was mailed to me by Daniel Gerzo. I created an MQ patch
out of it and pushed it on top of a clean doc/ tree. The second and
third patches are my own changes which should be applied on top of
Daniel's work.
You can start with no patches applied:
% hg qapplied -s
%
and push them all in order:
% hg qpush -a
applying danger-jails-chapter
applying danger-jails-fixups
applying danger-jails-whitespace
Now at: danger-jails-whitespace
% hg qapplied -s
danger-jails-chapter: Add a new Handbook chapter about "Jails" by *danger*
danger-jails-fixups: Handbook "jails" chapter fixups by *keramida*
danger-jails-whitespace: Handbook "jails" chapter whitespace fixups by *keramida*
%
The patch queue itself is versioned, so I can keep a log of the progress
of the patches I've been working on (you can see some old patches in the
log too here):
% cd .hg/patches
% hg log
changeset: 6:c645c9eacc55
tag: tip
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Sat Nov 25 06:39:00 2006 +0200
summary: *danger-xxx* save patch state after some more fixes
changeset: 5:438767ef8af8
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Fri Nov 24 22:07:16 2006 +0200
summary: *danger-jails-chapter* record that this was posted by *danger*
changeset: 4:c54d24f2ec51
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Fri Nov 24 22:05:58 2006 +0200
summary: *danger-jails-fixups* save patch state
changeset: 3:8bf5fcd3d058
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Fri Nov 24 22:03:04 2006 +0200
summary: new patch: danger-jails-whitespace
changeset: 2:cb04be76904a
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Fri Nov 24 21:16:17 2006 +0200
summary: Save patch state for a review of the Handbook "jails"
chapter
changeset: 1:13103ba17d00
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Thu Nov 23 18:04:16 2006 +0200
summary: ganbold-handbook-config the patch has looped back through ncvs
changeset: 0:640f098ebe4f
user: Giorgos Keramidas <keramida at ceid.upatras.gr>
date: Wed Nov 22 18:12:24 2006 +0200
summary: ganbold-handbook-config save patch state after first patch version
%
More information about the Mercurial-devel
mailing list