I am using Source Tree on Snow Leopard and my collaborator is using TortoiseHg on a Windows machine. They sent me a patch file they created. When I try to apply the patch through Source Tree I get the following error:
patch -f -p0 --input=/Users/bobsmith/Examples/Test.repos/2.patch
can't find file to patch at input line 11
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|# HG changeset patch
|# User Bob Dobbsr <email@example.com>
|# Date 1323115006 18000
|# Node ID 542abe6c0a14a38eb7da674768d7eba26de52f58
|# Parent 9a0d93cd89a62635aa5272a917910529b3d30b64
|Made two changes and added a conclusion section.
|diff -r 9a0d93cd89a6 -r 542abe6c0a14 Example.tex
|--- a/Example.texFri Dec 02 12:12:43 2011 +1000
|+++ b/Example.texMon Dec 05 14:56:46 2011 -0500
No file to patch. Skipping patch.
2 out of 2 hunks ignored
Completed with errors, see above
I previously ran the patch file through dos2unix to see if that helps.
I can get the file to work with the CLI command:
patch Example.tex 2patch.diff
Any ideas on why the GUI version through Source Tree isn't working?
The 'Apply Patch' UI in SourceTree includes the 'strip' option. SourceTree tries to figure this out automatically - I wrote a bunch of parsing routines and regexes to detect the strip options and base path so you wouldn't have to figure this out on your own like you do on the command line. The Apply Patch window should say in the text area in the middle whether it has figured out the base path & strip options correctly - it also tells you whether it's detected a plain GNU patch or a patch with full commit info.
I've got a bunch of tests for this and it's picked up the strip options correctly when I've tried it.
So when you pick this patch, what does the text area say about detecting the strip option? It should tell you if it can't figure it out. If that's the case you can specify it yourself, but I'm curious why it couldn't do it - I've fed it quite a lot of variations so if there's one it can't understand I'd like to have an example.
Steve -- thanks for the reply. I download the patch to the repository from an e-mail and then use the 'Apply Patch' UI. I get the message "Patch contains a Mercurial changeset. Could not determine strip/base path options from patch file entry: a/Example.tex" If I then use the toggle on the UI to set the Strip to 1 and click 'OK' the file works fine.
My collaborator noted that the patch I sent them in TortoiseHg on a Windows machine gives a "Bad Hunk" error, but if they cut and paste the file contents to the clipboard it works fine. I believe that migth be a end of line character issue, but it seems to be a work araound.
I'd say my problem is solved, but I can give you some more precise code if you like, I can send you the repository as well, it is a small toy example we are playing with to learn the system.
Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot