comparison mercurial/copies.py @ 43786:421ea5772039

copies: split the combination of the copies mapping in its own function In some case, this part take up to 95% of the copy tracing that take about a hundred second. This poor performance comes from the fact we keep duplciating and merging dictionary that are mostly similar. I want to experiment with smarter native code to do this, so I need to isolate the function first.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 13 Nov 2019 20:42:13 +0100
parents 3b039e43a1e6
children acbb55b8e9dc
comparison
equal deleted inserted replaced
43785:3b039e43a1e6 43786:421ea5772039
279 279
280 iterrevs = set(from_head) 280 iterrevs = set(from_head)
281 iterrevs &= mrset 281 iterrevs &= mrset
282 iterrevs.update(roots) 282 iterrevs.update(roots)
283 iterrevs.remove(b.rev()) 283 iterrevs.remove(b.rev())
284 revs = sorted(iterrevs)
285 return _combinechangesetcopies(revs, children, b.rev(), revinfo, match)
286
287
288 def _combinechangesetcopies(revs, children, targetrev, revinfo, match):
289 """combine the copies information for each item of iterrevs
290
291 revs: sorted iterable of revision to visit
292 children: a {parent: [children]} mapping.
293 targetrev: the final copies destination revision (not in iterrevs)
294 revinfo(rev): a function that return (p1, p2, p1copies, p2copies, removed)
295 match: a matcher
296
297 It returns the aggregated copies information for `targetrev`.
298 """
284 all_copies = {} 299 all_copies = {}
285 alwaysmatch = match.always() 300 alwaysmatch = match.always()
286 for r in sorted(iterrevs): 301 for r in revs:
287 copies = all_copies.pop(r, None) 302 copies = all_copies.pop(r, None)
288 if copies is None: 303 if copies is None:
289 # this is a root 304 # this is a root
290 copies = {} 305 copies = {}
291 for i, c in enumerate(children[r]): 306 for i, c in enumerate(children[r]):
334 if parent == 1: 349 if parent == 1:
335 othercopies.update(newcopies) 350 othercopies.update(newcopies)
336 else: 351 else:
337 newcopies.update(othercopies) 352 newcopies.update(othercopies)
338 all_copies[c] = newcopies 353 all_copies[c] = newcopies
339 return all_copies[b.rev()] 354 return all_copies[targetrev]
340 355
341 356
342 def _forwardcopies(a, b, base=None, match=None): 357 def _forwardcopies(a, b, base=None, match=None):
343 """find {dst@b: src@a} copy mapping where a is an ancestor of b""" 358 """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
344 359