开发者

Mercurial Change Conflicts

I'm now working with Mercurial from SVN.... with SVN I never lost any changes, the merging was very intelligent. With Mercurial, I just did a pull from the main repo when I've committed local changes and it overwrote my local changes. Here's the scenario...

with file.php the first 250 lines were identical. Locally I added 3 functions c开发者_如何转开发ause I was working a specific feature. I committed my changes and forgot to push up to DEV. So on DEV I added 3 new functions as well. The local 3 functions (despite being completely different) were overwritten by the 3 functions on DEV...

I can't seem to think of a logical reason why this is happening...

I'm using TortoiseHG, not command line.


There's a step missing in your description. By the description, DEV never saw the supposedly lost functions; it can't have overwritten them. You can, however, pull changes from DEV, getting a working branch identical to DEV while your local commits are another leaf. In this case, you can get them back by doing a merge of the two branches. Use hg heads to find out if you have another unfinished (not merged) branch. The crucial step would be an update, such as hg pull -u or hg update -c, which would hide (but not damage) the locally commited work.

Edit since I saw you use TortoiseHg:

The TortoiseHg workbench shows the tree quite nicely. A pull does create branches as I expected, and the new tip was indeed the one I pulled from the separate repository. The workbench shows the current working directory (as something like 1+), so you can see which branch it came from; try selecting the other branch and choosing "Merge with local" to collect all the changes.

The reason Mercurial doesn't merge things automatically for you is philosophical rather than technical. The cvs/svn workflow has branches taking an administrative procedure and every commit into a branch has to be current with the central repository; therefore all updates do merges. Mercurial and git instead take the approach that branching should be easy, and you may choose when and if to join each branch to any other branch, and giving a name to a branch is a separate task. The pull dialog in TortoiseHg can attempt to behave more like cvs using the Post Pull settings Update and Automatically resolve merge conflicts.

The Mercurial wiki has an article on Mercurial workflows. In particular, CvsLikePractice probably explains the branching better than I.


What Mercurial command did you run before noticing that the lines in your local version were missing?

Did you do an hg pull from DEV?

I haven't seen Mercurial lose changesets like this before, I imagine that if you committed everything as you've said that the changes are at a minimum in the file history somewhere.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜