简体   繁体   中英

Sharing files in a managed approach between hg repos

Problem: One hg repository has a file I want to update & maintain in another hg repository, and I do not want to copy & paste. I do want to have the file available in both repos.

Scenario:

Working on Product 0001

Project A has an hg repository.

Down the road, a Project B is spun up. There is largely no coupling between Project A and B, but there are some files that could be shared.

Version controlling files in a managed approach is critical: copy & pasting is not a viable solution.

There are some solutions that may work -

  • Merging both repos into a product repo . But, this means the version numbers for a set of files will be changing due to churn elsewhere. Plus, the different projects aren't terribly related.
  • Convert both into a subrepo. I am not sure this is the right approach, subrepos seem to have some funky behavior relating with the parent repo. (Or they used to?)

Extending this issue is the concept of sharing certain files between Products. Somehow, a file needs to be shared and correctly tracked as being a singular file, but in two different Products.

The general problem might be stated as this -

Given a set of products, each with their own repository, under development which share and develop upon files living in each other's repositories (think utility routines and frameworks), what is the hg solution to maintaining file-version consistently between products.

What is a good solution here?

Your second call is correct. You should extract the files that would be in both repositories and make that a third repo, which you in turn make a sub repo for each of project A and project B.

I don't know when you first looked at subrepos, but they've been around for a year now and are supported quite well.

Read a few of the subrepo related answers here on stack overflow, make sure to make your subrepo paths relative (not absolute w/ http:// etc.) in them and they'll treat you very well.

Update:

Today's 1.7 release of mercurial includes these enhancements for subrepos:

  • support remapping of subrepository source paths (see [subpaths] in hgrc(5))
  • make add, diff, incoming, outgoing and status commands recurse into subrepos with --subrepos/-S
  • subrepo: add support for 'hg archive'
  • subrepo: fix status check on SVN subrepos (issue2445)

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