Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wan to manage some profiles as XML files in Mercurial repos.

The setup I'm thinking of: Each user has a repo with a branch where he manages his own profile, and a number of branches where he can pull and merge other profiles from that branch of another user.

So for example I have my own profile branch and a branch labeled friends, in which I want to pull the profile branches of a few remote repos, to collect like a collection of profiles.

I figured out that since the repos are unrelated I need to use -f, but I can't figure out how to pull and merge only a single branch into another.

So I want like

me           friend       someone

profile ---> friends <--- profile
         \-> family

friends <--- profile

Is this even possible? Should I use separate repos instead? Is there a better solution?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I think the trick here is to use named branches.

For each user create a seperate named branch. When they push/pull between their repos and anyone elses they get all the changesets other people have committed, but they will only update to their own branch's changesets and commit into their own branch.

If a user wants to incorporate changes from another user, then they merge that changeset into their own branch, backing out any changesets they don't actually want.

For instance:

    --> B1 ---> B2 ---> B3
   /                \
A1 ---> A2 ---> A3 ---> A4 ---> A5 ---> A6
   \                        X
    --> C1 ---> C2 ---> C3 ---> C4

The user of branch A wants the changes B added in revisions B1 & B2, so merges B2 into A3, comitting it as A4. User B doesn't want A's changes though, so doesn't merge in A3 or A4 and just creates a new B3.

User C wants all of the changes from A4, so merges it into C3 to create C4.

User A however, wants everything C did apart from C1, so A merges C3 into A4, creating A5 and then uses back-out to undo the changes in C1, creating A6. From then on, whenever the C branch is merged into the A branch it will be missing the changes in C1.

User C now has to be careful though. If A6, or one of it's decendents, is merged back in to C4, then the backout of C1 will be merged in too.

Hope this helps,

Edit: For more info on Mercurial branching and merging, you could do worse than check out Steve Losh's blog entry.

Of those options listed, the clone technique is the easiest to get started with, but all it takes is one inappropriate pull and you stop being able to tell which parts of the branch are which and it all gets confusing. Named branches make it much easier once you get the hang of them.

share|improve this answer
    
That should work... I guess I should either have completely separate repos or completely integrated ones. I think I can't merge separate remote branches, only complete repos. –  Pepijn Mar 25 '10 at 14:57
    
If you want to share changes between different configurations, all configurations need to be in the same repo. This allows you to pull from another configuration and merge. Named branches just allow you to manage things which legitimately need to be different by naming those branches. Another option you might want to consider is to have a single mainline configuration and use patches to define the differences between the configurations. Check out the hgbook chapters on Mercurial Queues. I've not done this, but it looks pretty powerfull. –  Mark Booth Mar 25 '10 at 20:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.