SVN diff across 2 different repositories

和自甴很熟 提交于 2019-11-28 16:53:43

I don't know of a built-in subversion feature that would allow this, but you could create a complete checkout of both repositories and use the command line diff utility to compare both working copies:

diff -w -u -r -N WorkingCopy1 WorkingCopy2

-w to ignore all Whitespace -u to use the unified diff format (like subversion) -r for recursive -N to let new files appear in the patch

It's surely not the fastest approach, but might be acceptable for a one-time process. You can also create a patch by redirecting the output to a file diff -w -u -r -N WorkingCopy1 WorkingCopy2 > wc1-to-wc2.patch

If you're running windows, win32 builds of diff and patch can be found here: http://gnuwin32.sourceforge.net/packages/diffutils.htm

Lyle Ziegelmiller
svn diff --old=URL1@rev1 --new=URL2@rev2

Example:

svn diff --old=http://svn.whatever.com/trunk/myfile.txt@1234 --new=http://svn.whatever.com/branch/myfile.txt@5678

This allows you to specify both the branches and the revision numbers for both files. I know it works because I just executed it.

The best tool for doing this merge may be git-svn. If the URL of the two repositories are $URL1 and $URL2, then try:

$ git svn clone $URL1 svn1
$ git svn clone $URL2 svn2
$ cd svn1
$ git fetch ../svn2
$ git diff FETCH_HEAD master

To ignore whitespace changes, use git diff -w

You could use a tool like kdiff3 to simply compare checked-out working copies from both repositories. (Just point it at the two directories and it'll recursively compare all files in them.)

Probably the simplest thing is to check out both branches and use a tool like winmerge (which will allow you to ignore spaces and do a multi compare)

Copy the second repository into the first using something along the following in a working copy of the first repository:

svn cp svn://url/to/the/second/repo branches/second_repo

Checkin and do a regular merge from the new branch to your trunk.

This explanation assumes that you use the most common svn repository layout (branches/, tags/ and /trunk as top level directories) and so it may be necessary to adapt the copy command.

Also note that some GUIs for SVN support this copy mode, too. In SmartSVN the command is called "Copy from URL".

If you are on linux you could also use "meld" tool... It makes great diff, and you can easily do a merge...

Jonathan

The following works but it slow:

svn diff [url1] [url2]

Anytime I get in to this situation I use Meld. It's a multi-platform GUI compare tool. it can compare file to file or directory to directory. In your case you could checkout both projects into separate directories and use meld to compare. You can move changes (linesa or blocks) from one file to another very easily.

diff is good too!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!