简体   繁体   中英

svn merge on renamed files

First I make a branch from the main project

$ svn cp project branched

Then I rename some files in the branch:

$ svn mv branched/file.c branched/file.cpp

After commit/update, somebody else makes changes to the original file in the original project, how can I merge those changes ?

$ svn merge project/file.c branched/file.cpp
svn: E195002: Invalid merge source 'project/file.c'; a working copy path can only be used with a repository revision (a number, a date, or head)

Is it only a syntax problem, or as a colleague is suggesting, a deeper problem making it basically impossible to keep renamed files in sync ? If so what is the correct approach to renaming files and keeping them in sync ?

"Invalid merge source 'project/file.c'; a working copy path can only be used with a repository revision"

Let's break that down.

"Invalid merge source 'project/file.c'"

SVN is having a problem understanding what you mean by "project/file.c". Note SVN is attempting to use the same file you told it to use, and this file apparently exists on your system. No problems with the rename here.

"a working copy path"

You're telling SVN to merge from a file that already exists on your machine in your working copy. This is NOT the normal use. Normally, you specify a repository URL to merge from. This use is supported, but:

"can only be used with a repository revision"

...if you try merging from a working copy, you you're actually only telling SVN what file you're talking about, and SVN will still use the repository server to get the data for the merge. Thus you need to tell SVN what version to merge. Eg:

$ svn merge -r HEAD project/file.c branched/file.cpp

HOWEVER, the other weird thing you're doing here is merging a single file. Normally you want to merge entire directory trees, not individual files. So, I'd recommend a variation on the following instead:

$ svn merge http://example.com/svn/path/to/project branched

Read up on merges here:

http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.merge.html

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