comparison mercurial/revlog.py @ 1351:0e2be889ccd7

Repair ancestor logic, fix up test cases
author Matt Mackall <mpm@selenic.com>
date Mon, 26 Sep 2005 16:52:47 -0700
parents 57220daf40e9
children 67779d34cb52 518da3c3b6ce
comparison
equal deleted inserted replaced
1350:3729e2773cca 1351:0e2be889ccd7
437 while h: 437 while h:
438 d, n = heapq.heappop(h) 438 d, n = heapq.heappop(h)
439 if n not in seen: 439 if n not in seen:
440 seen[n] = 1 440 seen[n] = 1
441 r = self.rev(n) 441 r = self.rev(n)
442 yield (-d, r, n) 442 yield (-d, n)
443 for p in self.parents(n): 443 for p in self.parents(n):
444 heapq.heappush(h, (-dist[p], p)) 444 heapq.heappush(h, (-dist[p], p))
445 445
446 x = ancestors(a) 446 def generations(node):
447 y = ancestors(b) 447 sg, s = None, {}
448 lx = x.next() 448 for g,n in ancestors(node):
449 ly = y.next() 449 if g != sg:
450 if sg:
451 yield sg, s
452 sg, s = g, {n:1}
453 else:
454 s[n] = 1
455 yield sg, s
456
457 x = generations(a)
458 y = generations(b)
459 gx = x.next()
460 gy = y.next()
450 461
451 # increment each ancestor list until it is closer to root than 462 # increment each ancestor list until it is closer to root than
452 # the other, or they match 463 # the other, or they match
453 while 1: 464 while 1:
454 if lx == ly: 465 #print "ancestor gen %s %s" % (gx[0], gy[0])
455 return lx[2] 466 if gx[0] == gy[0]:
456 elif lx < ly: 467 # find the intersection
457 ly = y.next() 468 i = [ n for n in gx[1] if n in gy[1] ]
458 elif lx > ly: 469 if i:
459 lx = x.next() 470 return i[0]
471 else:
472 #print "next"
473 gy = y.next()
474 gx = x.next()
475 elif gx[0] < gy[0]:
476 #print "next y"
477 gy = y.next()
478 else:
479 #print "next x"
480 gx = x.next()
460 481
461 def group(self, linkmap): 482 def group(self, linkmap):
462 """calculate a delta group 483 """calculate a delta group
463 484
464 Given a list of changeset revs, return a set of deltas and 485 Given a list of changeset revs, return a set of deltas and