Using Mercurial to Cure Vault Merging
The two major issues I have with Vault are that it doesn’t do the metadata in the working directory (making it very hard to change from various local copies quickly) and the merge feature is pretty hard to figure out. Having said that, Vault is 100000000% better than Visual Source Safe (or as it was last time I looked which is a long time).
I have recently used mercurial to merge two parallel branches of code by doing this:
- Do a show history on the branch you want to merge and get the tree at the place where the branch was created (hint: choose the ‘show folder history by version’ option then click ‘get tree’)
- Assuming you have samba’d your working directory onto a linux box, you now need to get the shell going in your working dir (lets pretend this dir is called branch1).
- hg init
- optionally edit up a .hgignore file but you should be pretty safe if you did a clean get latest (i.e. you haven’t compiled anything yet)
- hg add .
- hg commit -m “initial branch”
- mkdir a second working dir let’s call it branch2 and cd to the dir that holds them both
- hg clone ./branch1 ./branch2
- now use vault to do a get latest into branch1
- hg add .
- also hg remove any files that have a ! next to them
- hg commit -m “updated from vault label blah”
- now get latest from the other branch into branch2 dir and cd there in linux
- hg add .
- also hg remove any files that have a ! next to them
- hg commit -m “updated from vault label blah”
At this stage you have a hg mirror of your two vault branches except without history.
Now to merge branch1 into branch2
- cd ../branch1
- chmod -R -u+rw .
- hg pull -u ../branch2
- resolve any merge conflicts using vim
- hg commit -m “merged from branch 1”
- In vault, do a recursive search for renegade files and check them out
- In vault, do the a recursive search for unknown to pick up any new files
- in vault do a search for missing files and delete them if need be
- commit changes in vault
Now maybe Vault already does all this and I’ve just misunderstood and this method obviously leaves a lot to be desired (e.g. It takes about an hour) so I hope Vault will fix up their merging GUI sometime soon.
[tags]mercurial, merging, methods, vault[/tags]
Matt, I’d love to comment on your blog more regularly, but I haven’t the faintest idea what the last two post mean. I’ll hire an interpreter, and get back to you.
Thanks for visiting anyway Catriona. I’ve posted something more accessible now. Those computer related posts are just for people googling specific problems and for for my own reference.
I think my tone went a little wonky in that last post; it wasn’t intended to be snarky, but rather admiring. (It would be a bit much to critique the contents of someone else’s blog when I’ve been known to update with pictures of my feet.)