comparison mercurial/hg.py @ 1072:05dc7aba22eb

Fixes for push corner case TAH found a bug where push would push things the remote already had, raising an assertion. This turned out to be because the changeset protocol was not recording a common subset node in one case. Also discovered was that the protocol was queueing multiple copies of a node for pull. Fixed by changing fetch to a hash. Add some more debugging output.
author mpm@selenic.com
date Fri, 26 Aug 2005 16:49:23 -0700
parents 4337cd845a2a
children 142b5d5ec9cc
comparison
equal deleted inserted replaced
1071:8f0ac653f85e 1072:05dc7aba22eb
1308 return nl 1308 return nl
1309 1309
1310 def findincoming(self, remote, base=None, heads=None): 1310 def findincoming(self, remote, base=None, heads=None):
1311 m = self.changelog.nodemap 1311 m = self.changelog.nodemap
1312 search = [] 1312 search = []
1313 fetch = [] 1313 fetch = {}
1314 seen = {} 1314 seen = {}
1315 seenbranch = {} 1315 seenbranch = {}
1316 if base == None: 1316 if base == None:
1317 base = {} 1317 base = {}
1318 1318
1362 else: 1362 else:
1363 if n[1] not in seen and n[1] not in fetch: 1363 if n[1] not in seen and n[1] not in fetch:
1364 if n[2] in m and n[3] in m: 1364 if n[2] in m and n[3] in m:
1365 self.ui.debug("found new changeset %s\n" % 1365 self.ui.debug("found new changeset %s\n" %
1366 short(n[1])) 1366 short(n[1]))
1367 fetch.append(n[1]) # earliest unknown 1367 fetch[n[1]] = 1 # earliest unknown
1368 base[n[2]] = 1 # latest known 1368 base[n[2]] = 1 # latest known
1369 continue 1369 continue
1370 1370
1371 for a in n[2:4]: 1371 for a in n[2:4]:
1372 if a not in rep: 1372 if a not in rep:
1381 (reqcnt, " ".join(map(short, r)))) 1381 (reqcnt, " ".join(map(short, r))))
1382 for p in range(0, len(r), 10): 1382 for p in range(0, len(r), 10):
1383 for b in remote.branches(r[p:p+10]): 1383 for b in remote.branches(r[p:p+10]):
1384 self.ui.debug("received %s:%s\n" % 1384 self.ui.debug("received %s:%s\n" %
1385 (short(b[0]), short(b[1]))) 1385 (short(b[0]), short(b[1])))
1386 if b[0] not in m and b[0] not in seen: 1386 if b[0] in m:
1387 self.ui.debug("found base node %s\n" % short(b[0]))
1388 base[b[0]] = 1
1389 elif b[0] not in seen:
1387 unknown.append(b) 1390 unknown.append(b)
1388 1391
1389 # do binary search on the branches we found 1392 # do binary search on the branches we found
1390 while search: 1393 while search:
1391 n = search.pop(0) 1394 n = search.pop(0)
1398 self.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i))) 1401 self.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i)))
1399 if i in m: 1402 if i in m:
1400 if f <= 2: 1403 if f <= 2:
1401 self.ui.debug("found new branch changeset %s\n" % 1404 self.ui.debug("found new branch changeset %s\n" %
1402 short(p)) 1405 short(p))
1403 fetch.append(p) 1406 fetch[p] = 1
1404 base[i] = 1 1407 base[i] = 1
1405 else: 1408 else:
1406 self.ui.debug("narrowed branch search to %s:%s\n" 1409 self.ui.debug("narrowed branch search to %s:%s\n"
1407 % (short(p), short(i))) 1410 % (short(p), short(i)))
1408 search.append((p, i)) 1411 search.append((p, i))
1409 break 1412 break
1410 p, f = i, f * 2 1413 p, f = i, f * 2
1411 1414
1412 # sanity check our fetch list 1415 # sanity check our fetch list
1413 for f in fetch: 1416 for f in fetch.keys():
1414 if f in m: 1417 if f in m:
1415 raise RepoError("already have changeset " + short(f[:4])) 1418 raise RepoError("already have changeset " + short(f[:4]))
1416 1419
1417 if base.keys() == [nullid]: 1420 if base.keys() == [nullid]:
1418 self.ui.warn("warning: pulling from an unrelated repository!\n") 1421 self.ui.warn("warning: pulling from an unrelated repository!\n")
1419 1422
1420 self.ui.note("adding new changesets starting at " + 1423 self.ui.note("found new changesets starting at " +
1421 " ".join([short(f) for f in fetch]) + "\n") 1424 " ".join([short(f) for f in fetch]) + "\n")
1422 1425
1423 self.ui.debug("%d total queries\n" % reqcnt) 1426 self.ui.debug("%d total queries\n" % reqcnt)
1424 1427
1425 return fetch 1428 return fetch.keys()
1426 1429
1427 def findoutgoing(self, remote, base=None, heads=None): 1430 def findoutgoing(self, remote, base=None, heads=None):
1428 if base == None: 1431 if base == None:
1429 base = {} 1432 base = {}
1430 self.findincoming(remote, base, heads) 1433 self.findincoming(remote, base, heads)
1434
1435 self.ui.debug("common changesets up to "
1436 + " ".join(map(short, base.keys())) + "\n")
1431 1437
1432 remain = dict.fromkeys(self.changelog.nodemap) 1438 remain = dict.fromkeys(self.changelog.nodemap)
1433 1439
1434 # prune everything remote has from the tree 1440 # prune everything remote has from the tree
1435 del remain[nullid] 1441 del remain[nullid]