I created various branches which I closed as they were leading to nowhere. One of these branches is called v2
. It was closed at some time in the past.
When developing further, I created another branch also called v2
. Tortoise Hg warned me that this branch already exists and whether I would like to "restart it" or "commit to current branch". I asked to restart it.
More dev happens on v2
(several commits) and I decide to push to a remote repository which already has my project (including the previously closed v2
). I then get the message
abort: push creates new remote head fce4441f5150 on branch 'v2'!
hint: merge or see "hg help push" for details about pushing new heads
I do not really want to merge (I assume that the message means "merge the old v2
with the new v2
") as these branches do not have much in common. I closed v2
as opposed to leaving it hanging because I was not expecting to use it anymore. (the self whipping about reusing names comes later in the question, no worries about that)
This leaves me with new heads. hg outgoing
shows me what I expected to happen ...
# this is the first commit for the new v2
changeset: 221:ba47b76010ef
branch: v2
user: w <w@home>
date: Fri Jul 18 14:42:08 2014 +0200
summary: New version: all frames are subclasses, frames are organiz
# some more commits for the new v2
# last commit for the new v2
changeset: 225:fce4441f5150
branch: v2
tag: tip
user: w <w@home>
date: Wed Jul 23 13:17:19 2014 +0200
summary: added manualstart.sh
... but v2
(the old one, closed) is already present in the repository:
Where should I go from now?
--force
parameter as it costed me a lot of cursing in the past. I want to make sure that it is OK this time.Overall I learned that it is not a good thing to reuse branches previously closed, is that correct? Or is it OK provided I take some precautions?
You are right, that it isn't a good thing to reuse branch names.
I see two ways to accomplish what you need - none of them is really "nice".
1) There is the -f option you already mentioned. If you are afraid of pushing multiple heads, try pushing in steps:
hg push -r <close commit of old branch>
hg push -r <parent of 221>
hg push -f -r 221 --new-branch
hg push
2) The other option would be to do a No-Op-Merge from the old to the new branch.
hg update -C 221
hg merge v2
hg revert -a -r 221
hg commit -m "old is marked as commited"
But be aware that this might cause problems with future merges, because all changes that are in the old v2 are marked as merged, even if they came from sidebranches or similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With