简体   繁体   中英

In Mercurial, how can a line disappear without a merge?

Using mercurial, I've run into an odd problem where a line from one committer vanished at some point in the timeline and I can't explain why it is.

Log looks like this:

changeset:   172:xyz123
parent:      76:pqr345
user:        barry baggings
date:        Mon Jan 16 0:12:43 2012 +0000
summary:     blah blah blah

changeset:   171:opq123
parent:      165:abc234
user:        mary moggings
date:        Mon Feb 01 1:12:41 2012 +0000
summary:     naw naw naw

Running: hg diff -r 171 -r 172 gives this for abc.py (header omitted):

print "context line1"
- print "i need this line!"
print "context line2"

The mod in question print "i need this line! was definitely introduced in 171:opq123 but it's gone again in 172:xyz123,

But a diff between 76 and 172 shows no mods to abc.py! How can Barry leapfrog Mary's change like this?

Am I just misunderstanding how all this works? I have a pretty decent background in things like CVS and SVN but DVCSs make my head hurt sometimes... can someone explain?

I am slightly suspicious that it's because we're on mercurial 1.7.1 - could it be a bug?

These are separate heads, with 172 not based on 171. The graph, as produced if you have the graphlog extension enabled and run hg glog , or as you can see visually from hgweb if you run hg serve , open it in a browser and click on the "graph" link, shows it perhaps more clearly than the "parent" values of the changesets.

o    changeset:   172:xyz123
|    parent:      76:pqr345
|    user:        barry baggings
|    date:        Mon Jan 16 0:12:43 2012 +0000
|    summary:     blah blah blah
|    
| o  changeset:   171:opq123
| |  parent:      165:abc234
| |  user:        mary moggings
| |  date:        Mon Feb 01 1:12:41 2012 +0000
| |  summary:     naw naw naw
| |

This shows clearly that changeset 172 is not based on changeset 171.Thus in comparing them, the change can have taken place elsewhere. You're not comparing an ancestor and descendant, you're comparing cousins of some degree.

So, while you introduced it in 171, because 172 is not based on 171, it doesn't get the addition of the line. A merge is in fact what you need to get the change, to make a changeset which is based both on 171 and 172 (and their ancestors, until they converge).

You may well have more heads that you want merged in; you can use hg heads to look at them. hg serve can also be very helpful for comprehending such things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM