1

I need to merge the all new changesets of a mercurial repository (lets call it A) into a subdirectory of another mercurial repository (lets call it B) on a regular basis. This means, just copying all files is not an option, as the files in B may also be changed and a proper merge must be done.

The only thing I've found to far is http://hgtip.com/tips/advanced/2009-11-17-combining-repositories/, which is about combining repositories, and not really merging over and over again including changesets.

Any ideas? Thanks in advance.

loonytune
  • 1,775
  • 11
  • 22

1 Answers1

2

This sounds like a case where you want to make use of sub-repositories: Including repository A as a sub-repository into the parent repository B.

Let's assume, that everything of A is found in the path B/A. That way, you would have locally your repository B and inside it another repository. You can then go to repository A, pull from the other repository A' and do the merge however you see fit. Then go back to parent level, to repository B. Update the tracked status of A and that's it. If you want to make any local changes which affect both, A and B, use the recursive hg commit --subrepos. See https://www.mercurial-scm.org/wiki/Subrepository for a more verbose description.

Mind however, that sub-repositories are a feature of last resort; that means it has some rough edges. One of them is that it's virtually impossible to undo the entanglement of the two repositories.

Maybe similar features like Guest Repositories, HG Nested or Forest Extensions are better suited for your actual use case.

planetmaker
  • 5,884
  • 3
  • 28
  • 37
  • I've just experimented with the subrepo feature. It turn out, when i change a file in B/A it wants to push to the original A instead to B. But i want only import changes into my B repo, not push back to A. Am I doing something wrong or does this not work with subrepos? – loonytune Apr 22 '16 at 18:53