Reputation: 88
I wonder if anyone can give me advice on how to cope with the aftermath of one of our disks being corrupted, and the restored to an old state. Here's the story:
I have some code I manage with Mercurial. There is a "master" repository on disk A, and a branch/clone on disk B. The timeline looks like this
What should I do?
Option1: - Very little has happened on the branch since the actual branching. So just blow away the master repo, and start using the new branch as my new master. If I do this, won't I have problems merging my old clones (mentioned at timepoint 0) back in?
Option2: - Just manually make the changes in my master that have been lost my diffing with the new branch. Even if I do this, how am I going to carry on pushing to the new branch?
Option3: - Just manually make the changes in my master that have been lost my diffing with the new branch. Then delete the new branch, and clone a new one.
Any advice welcome cheers Zam
Upvotes: 3
Views: 105
Reputation: 73798
I know you say the question is answered, but let me offer some advice anyway. You ask:
Option1: Very little has happened on the branch since the actual branching. So just blow away the master repo, and start using the new branch as my new master. If I do this, won't I have problems merging my old clones (mentioned at timepoint 0) back in?
You wont have any problems with merging old clones of the master repository. Imagine you have the master repo M
and clones X
and Y
. Let's say they contain changes like this (time flows to the right):
M: [m1] --- [m2] --- [m3]
X: [m1] --- [x1] --- [x2]
Y: [m1] --- [m2] --- [y1] --- [y2]
So X
was a clone of M
when only [m1]
existed, Y
is a clone of M
after [m2]
was made. Neither X
nor Y
has [m3]
— this changeset was apparently commited directly into the M
repository by working on the server.
You now discover that the disk with M
is faulty and you restore it from backup. The backup only has [m1]
. The world situation now looks like this:
M: [m1]
X: [m1] --- [x1] --- [x2]
Y: [m1] --- [m2] --- [y1] --- [y2]
When you compare the overall situations you'll see that only changeset [m3]
is missing: it's the one that was not in any of the clones (X
and Y
).
After the restore you can push [m2]
from Y
to M
to salvage as much data as possible. This is done with a simple
$ hg push -r m2
where m2
is the revision number or changeset hash in question.
So my advice is to look at the overall picture: find your clones and figure out what changesets you still have distributed among them and what is missing. Push what you need back to the master repository and setup a backup scheme with more frequent backups :-)
Note also that you only lost [m2]
because it only existed in a single clone. Normally, you will make new changesets in local clones and then push them to a master repository. That way, you automatically have a duplicate of all changesets in the master! That makes it harder to lose changesets since people can just push their work back after a restore.
Upvotes: 3