1

I have a project stored in mercurial which has grown well beyond its original remit, and now I want to split the repository into two separate projects. Say the file tree looks something like this:

src/
  a/
    a.h
    a.c
  b/
    b.h
    b.c

Say I've hg cloned this repository twice, and in the first clone I've performed an hg rm src/b/*, and in the second I've performed an hg rm src/a/*. This gives me the two separate source trees I want, with history and revision numbering preserved in each branch.

The problem I now have is what happens if, in the future, I ever accidentally pull from the a/ clone into the b/ clone. What I'd like is for mercurial to simply refuse to pull from, or push to, the other branch, if I ever try to do so, as if the two had never shared history.

Is this possible? If not, is there a canonical way to create two parallel projects from one original which preserves history and revision numbering?

regularfry
  • 3,248
  • 2
  • 21
  • 27

1 Answers1

3

The canonical way would be to use hg convert with a filemap like this:

exclude b
rename a .

(and afterwards with the roles of a and b reversed to create the second repository)

This way you end up with two unrelated repositories (which Mercurial will refuse to push/pull without the use of force) only containing the history of a single directory.

Also see this question for reference.

Community
  • 1
  • 1
Idan K
  • 20,443
  • 10
  • 63
  • 83