views:

43

answers:

2

The process of creating patches in Mercurial is as follows:

Create patch with qnew -> Make changes -> Refresh patch

What if I have already made (uncommited) changes and I want to add them to the queue?

+1  A: 

It depends on your version, and it looks like it changed in 1.5.1.

1.5.1 or later

The command will add any uncommitted changes by default

qnew creates a new patch on top of the currently-applied patch (if any). The patch will be initialized with any outstanding changes in the working directory.

earlier than 1.5.1

You want to use qnew -f. From the docs:

-f: Create a new patch if the contents of the working directory are modified. Any outstanding modifications are added to the newly created patch, so after this command completes, the working directory will no longer be modified.

Dennis
Thanks, I need to read man pages more carefully
Casebash
It looks like `hg qnew -f` is no longer supported (I have 1.6.4). Not sure when it was dropped. But the good news is that 'The patch will be initialized with any outstanding changes in the working directory' (from `hg help qnew`).
Niall C.
A: 

Actually, the patch process works the same whether there are uncommitted changes or not. I always do it as follows:

[... make changes ...]

hg qnew -m "foo bar changes" foobar.patch
--> new empty patch at top of queue
hg qrefresh
--> this adds all diffs from 'hg diff' into the current top patch

EDIT: @CaseBash has correctly pointed out that I'm wrong about the current default behavior!

leo grrr
In my version, it says "The patch will be initialized with any outstanding changes in the working directory" - not an empty patch
Casebash
You're right! I've been using it under a misapprehension!
leo grrr