comparison mercurial/localrepo.py @ 11662:a3bfdf212094

changegroupsubset: simplify knownheads/has_cl_set computation
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 23 Jul 2010 00:04:18 +0200
parents b16fb5d55b83
children 8b3fea709bd2
comparison
equal deleted inserted replaced
11661:b16fb5d55b83 11662:a3bfdf212094
1303 # slow path 1303 # slow path
1304 self.hook('preoutgoing', throw=True, source=source) 1304 self.hook('preoutgoing', throw=True, source=source)
1305 1305
1306 self.changegroupinfo(msng_cl_lst, source) 1306 self.changegroupinfo(msng_cl_lst, source)
1307 1307
1308 # Known heads are the list of heads that it is assumed the recipient 1308 # We assume that all ancestors of bases are known
1309 # of this changegroup will know about. 1309 commonrevs = set(cl.ancestors(*[cl.rev(n) for n in bases]))
1310 knownheads = set()
1311 # We assume that all parents of bases are known heads.
1312 for n in bases:
1313 knownheads.update(cl.parents(n))
1314 knownheads.discard(nullid)
1315 if knownheads:
1316 # Now that we know what heads are known, we can compute which
1317 # changesets are known. The recipient must know about all
1318 # changesets required to reach the known heads from the null
1319 # changeset.
1320 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1321 junk = None
1322 # Transform the list into a set.
1323 has_cl_set = set(has_cl_set)
1324 else:
1325 # If there were no known heads, the recipient cannot be assumed to
1326 # know about any changesets.
1327 has_cl_set = set()
1328 1310
1329 # Make it easy to refer to self.manifest 1311 # Make it easy to refer to self.manifest
1330 mnfst = self.manifest 1312 mnfst = self.manifest
1331 # We don't know which manifests are missing yet 1313 # We don't know which manifests are missing yet
1332 msng_mnfst_set = {} 1314 msng_mnfst_set = {}
1393 hasset = set() 1375 hasset = set()
1394 # If a 'missing' filenode thinks it belongs to a changenode we 1376 # If a 'missing' filenode thinks it belongs to a changenode we
1395 # assume the recipient must have, then the recipient must have 1377 # assume the recipient must have, then the recipient must have
1396 # that filenode. 1378 # that filenode.
1397 for n in missingnodes: 1379 for n in missingnodes:
1398 clnode = cl.node(revlog.linkrev(revlog.rev(n))) 1380 clrev = revlog.linkrev(revlog.rev(n))
1399 if clnode in has_cl_set: 1381 if clrev in commonrevs:
1400 hasset.add(n) 1382 hasset.add(n)
1401 for n in hasset: 1383 for n in hasset:
1402 missingnodes.pop(n, None) 1384 missingnodes.pop(n, None)
1403 for r in revlog.ancestors(*[revlog.rev(n) for n in hasset]): 1385 for r in revlog.ancestors(*[revlog.rev(n) for n in hasset]):
1404 missingnodes.pop(revlog.node(r), None) 1386 missingnodes.pop(revlog.node(r), None)