开发者

'bzr update' wiped all my local commits. Help!

I think something bad might have happened to my changesets.

For the record, I have used git, hg and svn with general success before. My understanding of bzr is less complete.

Here's what I had (Windows XP):

1) A folder created using bzr's svn checkout. Call开发者_开发知识库 it stable

2) A folder branched from that which I was using for development. Call it development

My plan was to use commit --local on the development branch to keep track of changes, and it was working swell.

Then, I did a 'bzr update' on (because it complained when I tried to push). At the time, stable had a much older copy of the code. Well, now development has that same old copy. 'bzr log' shows no evidence whatsoever of my local commits!

Can someone explain to me what happened, and what I can do to recover my old code?


Ok, I found it. After some frantic searching, I uncovered the secret code word, "dead head," after viewing this other stackoverflow question: Some code was lost after doing bzr commit --local, bzr pull, bzr commit

However, the solution they proposed didn't work for me. What did work, was found at http://chrismarinos.com/don-t-loose-your-head-with-bazaar/

The final answer was to find the revision id using heads --all, and then use pull get get all the revisions:

bzr heads --all
bzr pull --overwrite -r revid:<revision-id>

All my code is back, and now backed up 3 or 4 times.


I honestly cannot say how that would have happened—it honestly looks like that would be the behavior of a (sounds pretty catastrophic bug), unless you did something like bzr pull --overwrite or did a bzr revert after a bzr pull that had conflicts.

First things first, see if you can reliably replicate this problem. Whether or not that is possible, though, file a bug report against bzr so that this issue can be tracked. Also, before doing ANYTHING ELSE AT ALL, back up the data that you have in these branches. If you have been working in a shared repository, back up the whole thing. That way it is available for forensic recovery if such drastic efforts are necessary. For more help on that, though, you'll have to work with the Bazaar developers. It might be helpful to hang out in the #bzr room on FreeNode's IRC network to ask for help. As is the usual for seeking out support on IRC, patience is key even if the situation you're in is pretty urgent. They may be able to give you some Python code or instructions on how to dig up those commits, and they also may be able to tell you how to find out what happened.

That said, what I typically do when doing development like this, is I have an unbound "upstream" branch, and then whatever branch I am working in. When I am finished with my changes, I'll pull from the upstream, merge my branch into the resulting tree, then push back up. For example:

$ bzr init-repo project; cd project
$ bzr branch bzr+ssh://example.org/srv/bzr/project/trunk trunk
$ bzr branch trunk my-feature-branch
$ cd my-feature-branch
 ... work, commit; work, commit; ...
$ cd ../trunk
$ bzr pull
$ bzr merge ../my-feature-branch
 ... resolve any merge conflicts here, if any ...
$ bzr ci -m 'Merge in my-feature-branch'
$ bzr push :parent

Doing it that way also keeps your work separate from the upsteam branch until you're ready to merge and push it. And it ensures that your local branch never has the chance to be overwritten.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜