A question about "hg patch/import": how to use a patch?
alex.w.y.wang
alex.w.y.wang at gmail.com
Thu Oct 29 20:33:22 CDT 2009
Hi everyone. I am new to Mercurial.
As mentioned in the captial, assuming I have one directory containing a simple source code file, which is empty:
A\simple.c
Then I clone it to B, and we have:
A\simple.c
B\simple.c
Now, I add a line to simple.c, and run command: "hg diff > patch.v1 ", the patch content is:
diff -r 664ebf7b0f2c simple.c
--- a/simple.c Fri Oct 30 08:57:26 2009 +0800
+++ b/simple.c Fri Oct 30 08:58:33 2009 +0800
@@ -0,0 +1,1 @@
+/* patch for a new line: 1 */
\ No newline at end of fil
cd to the B content, run command "hg import/patch [path/to/]patch.v1"
Everything works perfectly until now.
Then I add another line to A\simple.c, run command: "hg diff > patch.v2", the patch content is:
diff -r 664ebf7b0f2c simple.c
--- a/simple.c Fri Oct 30 08:57:26 2009 +0800
+++ b/simple.c Fri Oct 30 09:01:58 2009 +0800
@@ -0,0 +1,2 @@
+/* patch for a new line: 1 */
+/* patch for a new line: 2 */
\ No newline at end of file
cd to the B content, run command "hg import/patch [path/to/]patch.v2"
Now it works wrongly.
The content of A\simple.c is:
/* patch for a new line: 1 */
/* patch for a new line: 2 */
The content of B\simple.c is:
/* patch for a new line: 1 */
/* patch for a new line: 2 *//* patch for a new line: 1 */
Since this is a extremely simple case, which is guranteed to be sucessful. However, the result of B\simple.c is definitely not what we want.
Can anyone tell me how to solve this problem? Thank you very much.
PS: Although there is solution: we can just run "hg commit", "hg update" in directory A, and then run "hg pull" in directory B, (this method works perfectly), since I am working for a huge code base, it is not allowed to push modified codes directly to the base. The normal workflow is to modified the code and use "hg diff > patch" to generate patch file, and submit the patch to the commitee to review it. Just the first time I commited my first patch, the commitee complains they can't apply the patch to the source tree. That is really annoying. I hope anyone here can help me sincerely. Thank you again.
2009-10-30
alex.w.y.wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20091030/d6b9120b/attachment.htm
More information about the Mercurial
mailing list