4

For Mercurial, can 2 clones function as two branches?

 2 years ago
source link: https://www.codesd.com/item/for-mercurial-can-2-clones-function-as-two-branches.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

For Mercurial, can 2 clones function as two branches?

advertisements

Since I want to diff all the changes I made since 7 or 10 days ago, without seeing the changes of other team members, so I keep a clone, say

c:\dev\proj1

and then I keep another clone that is

c:\dev\proj2

so I can change code for proj1, and then in another shell, pull code from it, and merge with other team members, and run test. And then 10 days later, I can still diff all the code made by me and nobody else by going to the shell of proj1 and do a hg diff or hg vdiff.

I think this can be done by using branch as well. Does having 2 clones like this work exactly the same as having 2 branches? Any advantage of one over the other method?


The short answer is: Yes.

Mercurial doesn't care where the changesets come from, when you merge. In that sense, branches and clones work equally well when it comes time to merge changes.

Even better: The workflow you described is exactly the strategy in Chapter 3 of the Mercurial book.

The only advantage of branches is that they have a name, so you have less incentive to merge right off. If you want to keep those proj2 changes separate, while still pushing and pulling them from proj1, give them a real branch. Again, functionally, they're the same.

And yes, this is characteristic of DVCS, not uniquely Mercurial.

Tags mercurial

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK