Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

renaming instead of replacing files on a pull

gabrielle_anderson November 22, 2012

I have some custom diff software that I'd like to use to compare versions. To do this I need to have both the old (local) version of a file, and the pulled version, in the same folder. Is it possible to, on a pull, for any modified files (on the server) rename the local ones, and then pull the newest ones to the same names as before?

1 answer

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2012

Is there any reason you'd want to do this except in the case of a merge conflict? If there's a merge conflict, then both versions are available anyway via hg/git, you can 'resolve using theirs' or 'resolve using mine', or indeed use a merge tool.

If it's just because you want to diff the history, you can do this just by hooking up your diff tool as an external diff option. In Preferences > Diff you can select one of a number of pre-configured tools, or you can set up a custom tool if you want. Then, you can use that to diff from the log either for a single commit's changes, or for a range of commits (multi-select).

gabrielle_anderson November 25, 2012

OK, so I think what I actually want is to do an diff using an external program. I'm trying to use the latexdiff tool, which takes in two latex documents and returns a third which is the diff. Normal command line usage is:

latexdiff file1.tex file2.tex > diff.tex

I've tried a set up where I put latexdiff in the the "diff command" box and "$LOCAL $REMOTE > diff.tex" in the arguments box, but it doesn't seem to do anything. I'm running OS X 10.8.2 on a Macbook Air, and version 1.5.5 of SourceTree. The repository in question is a Mercurial repository, stored on Bitbucket.

gabrielle_anderson November 25, 2012

So in experimenting I've discovered that the external diff tool seems to open an external program that shows a diff, rather than creating an output file in the relevant directory, as I would like.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 25, 2012

Perhaps you want to create a patch instead? You can right-click a commit and select Create Patch to export the changes as a patch file.

gabrielle_anderson November 25, 2012

Unfortunately the diff program needs the old and the new files as input, not a patch file.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 25, 2012

OK, well the external diff tool should work then, because it will be called with 2 parameters, the file instances will just be extracted from the repo on demand and put in a temp folder before the ext diff is called. Although the intention is usually to display a visual tool, there's nothing to say that it has to be that. The only tricky part might be the pipe you're trying to use there, which won't work because it won't be called in a full shell. If there's an --output option or similar, that should work.

gabrielle_anderson November 25, 2012

There's not an output option. I tried writing a new shell script that did the piping inside the shell, but that doesn't seem to work either.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 26, 2012

This unfortunately may not be doable via the external diff features of git/hg then (ST essentially just sets these up in the ~/.gitconfig etc al). You may just have to use custom scripts to export file contents at given commits and execute your tool on them that way - you can hook up most external scripts to SourceTree via the Custom Action feature in Preferences, including the context of the commit and selected file.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events