简体   繁体   中英

Problems while applying an svn patch to a mercurial repository

Patch file is made with TortoiseSVN-> Create Patch...

Attempting to import patch into the mercurial repository using hg import patchfile .

There seem to be problems with how hg looks for files referenced in the patch file:

unable to find 'gui/gui/RemoteFramework.cpp' for patching
2 out of 2 hunks FAILED -- saving rejects to file gui/gui/RemoteFramwork.cpp.rej

This seems to be an issue of where the patch was made in terms of directories and where it should be applied. I have tried playing with the --base option for hg import, but haven't gotten anywhere just yet.

Anyone have any tips?

I suspect you need to do hg import --strip 0 patchfile since Subversion doesn't include any prefix on the file path. --base specifies where it should search for files, and --strip says how many (default 1) path elements to ignore on the beginning of the diff headers.

I've had the same problem moving my project, CartoType, from Subversion to Mercurial. I had the Subversion stuff checked out to C:\\CartoType, and a clone of the Mercurial repository in C:\\CartoType-mercurial.

I used TortoiseSVN to create unified diff files, and found that it was using paths like C:/CartoType/src/main/router/cartotype_router.h in them. Running hg patch in C:\\CartoType-mercurial, I found the right thing to do was to strip two elements from the path, thus:

hg patch -p2 c:\temp\patch1982.diff

The other important thing I needed to do was replace the 'Index' lines in the diff file with check-in comments, because that's where hg patch gets them from. So in this example I had to change the first line of my diff file from

Index: C:/CartoType/src/main/router/cartotype_router.h

to

Added an optional parameter to NewRoadOrWalkingRouter... (etc.)

If there are multiple Index lines in the diff file, change them all to the same check-in comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM