質問

I am working on a mercurial repository and using pbrach for working on a set of patches.

Assume I have two files A and B, and two patches patchA (modifies A) and patchAB (modifies A and B). The pgraph looks like this:

o  patchAB
|
@  patchA
|
o  default

By mistake, I committed a change to file B into patchA.

How do I split the patch A into 2 parts, so that I end up with: patchA=patchA' + newPatch, where patchA=Original Patch, patchA'=changes of patchA in file A, P2=changes of patchA in file B.

o  patchAB
|
| o newPatch // rest of original patchA without changes already in patchA'
|/
@  patchA' // with only the changes to file A
|
o  default

(I search something similar to splitting patches with mq but for pbranch).

役に立ちましたか?

解決

Finally, I found a relatively short solution myself.

First I get the revision number of the last 'good' commit (say 1), and the wrong commit (say 2).

1) I update to patchA, revert the change on fileB, and commit it, and pmerge the changes upwards:

hg up patchA
hg revert -r1 fileB  // get fileB before the wrong change
hg commit -m"revert fileB"
hg pmerge -a

2) Update to patchA again, revert the wrong commit and create a new patch:

hg up patchA
hg revert -r2 fileB  // get fileB after the wrong change
hg pnew patchA2

We now have the changes of fileA in patchA and the rest in patchA2.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top