Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 8156:9fd0822c2ec3
localrepo: use sets in findcommonincoming
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Fri, 24 Apr 2009 17:32:18 +0200 |
parents | 08e1baf924ca |
children | d2899a856f9f |
comparison
equal
deleted
inserted
replaced
8155:b7cdfa2527be | 8156:9fd0822c2ec3 |
---|---|
1303 | 1303 |
1304 All the ancestors of base are in self and in remote. | 1304 All the ancestors of base are in self and in remote. |
1305 """ | 1305 """ |
1306 m = self.changelog.nodemap | 1306 m = self.changelog.nodemap |
1307 search = [] | 1307 search = [] |
1308 fetch = {} | 1308 fetch = set() |
1309 seen = {} | 1309 seen = set() |
1310 seenbranch = {} | 1310 seenbranch = set() |
1311 if base == None: | 1311 if base == None: |
1312 base = {} | 1312 base = {} |
1313 | 1313 |
1314 if not heads: | 1314 if not heads: |
1315 heads = remote.heads() | 1315 heads = remote.heads() |
1359 continue | 1359 continue |
1360 elif n[1] and n[1] in m: # do we know the base? | 1360 elif n[1] and n[1] in m: # do we know the base? |
1361 self.ui.debug(_("found incomplete branch %s:%s\n") | 1361 self.ui.debug(_("found incomplete branch %s:%s\n") |
1362 % (short(n[0]), short(n[1]))) | 1362 % (short(n[0]), short(n[1]))) |
1363 search.append(n[0:2]) # schedule branch range for scanning | 1363 search.append(n[0:2]) # schedule branch range for scanning |
1364 seenbranch[n] = 1 | 1364 seenbranch.add(n) |
1365 else: | 1365 else: |
1366 if n[1] not in seen and n[1] not in fetch: | 1366 if n[1] not in seen and n[1] not in fetch: |
1367 if n[2] in m and n[3] in m: | 1367 if n[2] in m and n[3] in m: |
1368 self.ui.debug(_("found new changeset %s\n") % | 1368 self.ui.debug(_("found new changeset %s\n") % |
1369 short(n[1])) | 1369 short(n[1])) |
1370 fetch[n[1]] = 1 # earliest unknown | 1370 fetch.add(n[1]) # earliest unknown |
1371 for p in n[2:4]: | 1371 for p in n[2:4]: |
1372 if p in m: | 1372 if p in m: |
1373 base[p] = 1 # latest known | 1373 base[p] = 1 # latest known |
1374 | 1374 |
1375 for p in n[2:4]: | 1375 for p in n[2:4]: |
1376 if p not in req and p not in m: | 1376 if p not in req and p not in m: |
1377 r.append(p) | 1377 r.append(p) |
1378 req.add(p) | 1378 req.add(p) |
1379 seen[n[0]] = 1 | 1379 seen.add(n[0]) |
1380 | 1380 |
1381 if r: | 1381 if r: |
1382 reqcnt += 1 | 1382 reqcnt += 1 |
1383 self.ui.debug(_("request %d: %s\n") % | 1383 self.ui.debug(_("request %d: %s\n") % |
1384 (reqcnt, " ".join(map(short, r)))) | 1384 (reqcnt, " ".join(map(short, r)))) |
1400 self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i))) | 1400 self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i))) |
1401 if i in m: | 1401 if i in m: |
1402 if f <= 2: | 1402 if f <= 2: |
1403 self.ui.debug(_("found new branch changeset %s\n") % | 1403 self.ui.debug(_("found new branch changeset %s\n") % |
1404 short(p)) | 1404 short(p)) |
1405 fetch[p] = 1 | 1405 fetch.add(p) |
1406 base[i] = 1 | 1406 base[i] = 1 |
1407 else: | 1407 else: |
1408 self.ui.debug(_("narrowed branch search to %s:%s\n") | 1408 self.ui.debug(_("narrowed branch search to %s:%s\n") |
1409 % (short(p), short(i))) | 1409 % (short(p), short(i))) |
1410 newsearch.append((p, i)) | 1410 newsearch.append((p, i)) |
1411 break | 1411 break |
1412 p, f = i, f * 2 | 1412 p, f = i, f * 2 |
1413 search = newsearch | 1413 search = newsearch |
1414 | 1414 |
1415 # sanity check our fetch list | 1415 # sanity check our fetch list |
1416 for f in fetch.keys(): | 1416 for f in fetch: |
1417 if f in m: | 1417 if f in m: |
1418 raise error.RepoError(_("already have changeset ") | 1418 raise error.RepoError(_("already have changeset ") |
1419 + short(f[:4])) | 1419 + short(f[:4])) |
1420 | 1420 |
1421 if base.keys() == [nullid]: | 1421 if base.keys() == [nullid]: |
1427 self.ui.debug(_("found new changesets starting at ") + | 1427 self.ui.debug(_("found new changesets starting at ") + |
1428 " ".join([short(f) for f in fetch]) + "\n") | 1428 " ".join([short(f) for f in fetch]) + "\n") |
1429 | 1429 |
1430 self.ui.debug(_("%d total queries\n") % reqcnt) | 1430 self.ui.debug(_("%d total queries\n") % reqcnt) |
1431 | 1431 |
1432 return base.keys(), fetch.keys(), heads | 1432 return base.keys(), list(fetch), heads |
1433 | 1433 |
1434 def findoutgoing(self, remote, base=None, heads=None, force=False): | 1434 def findoutgoing(self, remote, base=None, heads=None, force=False): |
1435 """Return list of nodes that are roots of subsets not in remote | 1435 """Return list of nodes that are roots of subsets not in remote |
1436 | 1436 |
1437 If base dict is specified, assume that these nodes and their parents | 1437 If base dict is specified, assume that these nodes and their parents |