简体   繁体   中英

Subversion: Using only some of the files from a vendor branch

In " Version Control with Subversion ", the Vendor Branches section sets up a vendor branch for "libcomplex" and then uses the following command to copy libcomplex into the main development branch:

$ svn copy http://svn.example.com/repos/vendor/libcomplex/1.0  \
           http://svn.example.com/repos/calc/libcomplex        \
           -m "bringing libcomplex-1.0 into the main branch"

However, what if we only require a subset of the functionality (and thus a subset of the files) of libcomplex?

Is it OK to copy only part of libcomplex into the main branch? Or is this likely to cause problems (particularly when it comes to upgrading libcomplex)?

I won't recommend splitting up libraries imported from other sources.

You'll land in a dependency merge + upgrade nightmare if the libcomplex anything, but trivial.

Perhaps the easiest way to approach this is to only commit the files that you need into your repository in the first place. This makes the Subversion side of the problem trivial. If you can write a script that extracts the library subset that you need from the drop that you get from your vendor, then the entire process can be automated away. This is still doable if the extraction has to be done manually, but it's a bit more annoying. Either way, it will most likely turn into a maintenance headache. Third-party libraries typically aren't designed to be split up, so you'll risk having to make manual changes whenever the library makes any structural changes.

A completely different approach is to compile the library (or a subset of it) into a binary file, and then only commit that binary file into your source tree. This is what I do on a project that I work on. We have a separate repository for libraries from vendors. A custom makefile will build svn://vendor_repo/trunk and generate svn://vendor_repo/trunk/libs (which are committed along with each new drop), and it is this libs subfolder that we pull into our main repository using svn:externals . With this method, our code doesn't know (or care) whether the libs are a subset or the entire library. All they see is a binary file to link against. The extent of the code that we have to manually maintain is the custom makefile that we use to build the vendor library.

You use sparse directories .

Its much more geared to extracting a directory rather than individual files at the moment, but assuming this is ok, use the --depth option to restrict the amount of stuff you check out.

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