Subversion svn:externals file override?

余生颓废 提交于 2019-12-17 19:29:23

问题


I have a repository for one of my projects that has a nested repository using the svn:externals property to update files from an external library. The problem is that I need to comment out one of the function declarations from one of the headers in this library, and carry around the modified header with the root repository.

Is there a way that this could be done, so that when the library is updated, it overrides that specific file with my version of it?


回答1:


What you want sounds like a "vendor branch" scenario to me.

current repository

root
|-- myproject
    |
    -- mycode
    |
    -- library -> svn:externals to a remote svn or your own libraryproject

suggested repository

root
|-- myproject
    |
    -- mycode
    |
    -- library -> copied/branched from ^/vendor/library/current (modified at this location as much as you like)

|
-- vendor
   |
   --library
     |
     --current
     |
     --imported-version-1.0
     |
     --imported-version-1.1

How to create the layout

Create ^/vendor/library/current and DOWNLOAD the original unmodified library code into it.

svn commit ^/vendor/library/current
svn cp ^/vendor/library/current ^/vendor/library/imported-version-1.0 (tag the import)
svn cp ^/vendor/library/current ^/myproject/library (branch the code into your project)

modify ^/myproject/library and commit


How to update the library without losing your modifications

Download the latest original release of the library into ^/vendor/library/current OVERWRITING files.

svn commit ^/vendor/library/current (checks in the difference between the two library releases)
svn cp ^/vendor/library/current ^/vendor/library/imported-version-1.1 (tag the change)
cd /your-local-workspace/myproject/library (will be merge target)
svn merge ^/vendor/library/current (get all CHANGES from the upstream branch and apply them to your modified library)
svn commit

profit


Instead of branching "current" directly into your project you could branch to a "my-modified-libs" directory and make use of it via externals. This would be advised if you have multiple projects that need the same modified version of a library.

Keep in mind that vendor branches will have problems dealing with renames and deletes as those can not be tracked by overwriting. Cross-repository merging is a different and rather young topic for SVN.

If you try it out, give us feedback how it went :)

Christoph




回答2:


There isn't a built in feature to help you with this.

The general practice way of dealing with this would be: Make a branch of the library you're using then make the changes you need there and use the newly created branch as the external for the root project. In my experience I've found this to be a simple and effective solution to the problem you describe.



来源:https://stackoverflow.com/questions/3754459/subversion-svnexternals-file-override

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