Handle renames in parallel branches

谁说我不能喝 提交于 2019-12-06 05:39:44

问题


I have a typical Subversion set-up:

/trunk
/branches/client-one
/branches/client-two
/branches/client-three

Trunk holds main development and branches hold client customizations. Now and then, I port changes from trunk into branches and viceversa:

[+] /trunk/readme-trunk.txt
[port] /trunk/readme-trunk.txt -> /branches/client-one/readme-trunk.txt
[port] /trunk/readme-trunk.txt -> /branches/client-two/readme-trunk.txt
[port] /trunk/readme-trunk.txt -> /branches/client-three/readme-trunk.txt

It works pretty flawlessly, except when I need to rename a file. Now matter how I do it, I always get tree conflicts and, depending on the steps I take, I lose local modifications or I can no longer port future changes.

Is it possible to rename a file and still be able to port changes back and forth?

[rename] /trunk/readme-trunk.txt -> /trunk/readme.txt
[port] /trunk/readme.txt -> /branches/client-one/readme.txt
[port] /trunk/readme.txt -> /branches/client-two/readme.txt
[port] /trunk/readme.txt -> /branches/client-three/readme.txt

[edit] /trunk/readme.txt
[port] /trunk/readme.txt -> /branches/client-one/readme.txt
[port] /trunk/readme.txt -> /branches/client-two/readme.txt
[port] /trunk/readme.txt -> /branches/client-three/readme.txt

(Most documentation on the subject implies that tree conflicts happen when two developers modify the same file; this is not the case since I'm the sole developer.)


回答1:


I've been reading a lot since I asked the question and it appears that file renaming is the weak point of most source control systems. As about Subversion, it's one of those things that just can't be done (like merges before 1.5).

This is the workaround that seems to work best:

  1. Perform regular rename (copy+delete) in trunk. Commit.
  2. For each branch:
    • Tag revision from #1 as merged, e.g., svn merge --record-only (command line) or [X] Only record the merge (TortoiseSVN).
    • Perform a regular rename (copy+delete).

You get no tree conflicts and, the best part, both files are still regarded as related, so you can still port and backport between branches.

(Not really tested on directories, just plain files. Comments welcome.)



来源:https://stackoverflow.com/questions/2896355/handle-renames-in-parallel-branches

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