Restarting a branch
Becker, Mischa J
mischa.becker at fredmeyer.com
Tue Dec 3 19:33:56 UTC 2013
> -----Original Message-----
> From: mercurial-bounces at selenic.com [mailto:mercurial-
> bounces at selenic.com] On Behalf Of Angel Ezquerra
> Sent: Monday, December 02, 2013 7:52 AM
> To: Mercurial
> Subject: Restarting a branch
>
> Hi,
>
> apologies if this has been answered before. I seem to remember a
> discussion about this a while ago but I cannot find a quick Google
> search did not turn out any useful results.
>
> One of my colleagues asked me today what is the recommended way to
> "restart a branch" that has been "abandoned".
>
> For example, imagine that we had the following simple DAG:
>
> @ dev: last commit on the "dev" branch
> |
> ... a certain number of commits in the "dev" branch
> |
> o dev: commit 2 on the "dev" branch
> |
> o dev: first commit on the "dev" branch (default was abandoned here)
> |
> o default: last commit on the default branch
> |
> ...
>
>
> That is, at some point they stopped committing into default and instead
> they committed into dev. This went on for a while but now they would
> like to "convert" the dev branch into default.
>
> I see two possible options:
>
> 1. Call "hg branch default" before making the next commit on top of the
> head of "dev". They could even close "dev" first. This has the con that
> now default has two heads, but it results on a pretty clean history that
> shows exactly what happened.
>
> 2. Merge devel into default. Before committing the merge, do "hg revert
> -r devel". This has two problems:
> - You can only do this if the head of default is not an ancestor of
> the head of "dev". One solution would be to update to default, close it,
> and then merge dev into the "close default" commit.
This is only an issue when the two revisions you are merging are in the same branch. Since you are merging across branches it isn't a problem.
> - Even if you can do this the resulting history is less clean
> (specially if the default branch was "abandoned" a long time ago or if
> you need to close default first).
If you merge devel back into your existing default branch, you should be closing devel before the merge, not default.
> So, are there any other options? Is one of these options what they
> should do?
>
> Thanks,
>
> Angel
I don't know if it makes a whole lot of difference if you merge or close but I do think your end result should be one open default head and no open devel heads.
Personally, I would close the devel branch and merge it into the old default branch using hg revert to make sure the merged commit matches the closed devel branch.
If you don't want to merge devel into the old default branch, then definitely close the old default head. If you want the close commit next to the head it is closing, clone the existing repo up to the old default head then write a batch script to pull in the other revisions in the order you want to see them. (Alternately, clone the entire existing repo; in the clone, strip without backup all the revisions between the old default head and it's close commit; then re-pull in the stripped changesets.) Once it has all the revisions, you can replace the existing repo with the newly ordered one. If the users also want a cleaner graph, they can create new clones from the new repo.
Mischa
________________________________
This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is confidential and protected by law from unauthorized disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
More information about the Mercurial
mailing list