Ignore files/folders on merge

杀马特。学长 韩版系。学妹 提交于 2020-01-02 02:53:07

问题


I'm currently using SVN for versioning my software projects. On an ongoing project, I have the trunk, for client common features and specifications and branches, for client specific ones.

Is there any way to mark some files / folders that shouldn't be merge into branches each time I perform such operation?


回答1:


There is an option that you merge virtually meaning that the merge does not alter the files in the target but mark it in the merge tracking props. This way the changes will never occour in the files to be merged, ever!

The feature is called record-only in the command line version.

From link text

The --record-only option works with -r and does exactly what you think it does: it marks a revision as merged (or unmerged, if using the "-" revision number negation syntax), without actually changing anything besides the mergeinfo. For example, this would be useful when someone has hand-edited a file in such a way as to effectively incorporate a change that was already made somewhere else. Rather than have the original change be ported over in the next synchronization merge, thus risking textual conflicts wherever the two versions trivially differ, you can just record the change as already merged. (See the merge-tracking requirements, and Blocking Changes in the Subversion book, for more details.)




回答2:


I don't immediately see a solution, but it would be easy enough to script something up. What I give you is not bug tested.

First you would make a list of directories that you would want exclueded. Called ~/.svn-merge-excludes

#regexes to exclude
./helpfiles/
./deploy_scripts/
./models/customer_integration

Then you would write another script to revert those directories in the branch after you merge the turnk into them.

#/usr/bin/bash
# I am assuming that you made the excludes based on the root directory 
# so that relative paths will work
for dir in $(cat ~/.svn-merge-excludes) ; do
    svn revert -R $dir
done

That should work. The big thing here is the '-R' option in the revert acting recursively on the directory. Therefore your workflow will look something like.

# cd path/to/branch
# svn merge -r123:245 svn://svnserver.com/svn/trunk
# revert_excludes_from_branch.sh

Then you would handle the conflicts and then commit. If you are using windows then a batch file would work too, you could just type out the revert commands in series.



来源:https://stackoverflow.com/questions/2381116/ignore-files-folders-on-merge

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