comparison mercurial/copies.py @ 34311:1826d695ad58

copytrace: add a a new config to limit the number of drafts in heuristics The heuristics options tries to the default full copytracing algorithm if both the source and destination branches contains of non-public changesets only. But this can be slow in cases when we have a lot of drafts. This patch adds a new config option experimental.copytrace.sourcecommitlimit which defaults to 100. This value will be the limit of number of drafts from c1 to base. Incase there are more changesets even though they are draft, the heuristics algorithm will be used. Differential Revision: https://phab.mercurial-scm.org/D763
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 21 Sep 2017 15:58:44 +0530
parents fc3b8483c6cb
children 1a5abc45e2fa
comparison
equal deleted inserted replaced
34310:2d0c306a88c2 34311:1826d695ad58
369 return {}, {}, {}, {}, {} 369 return {}, {}, {}, {}, {}
370 elif copytracing == 'heuristics': 370 elif copytracing == 'heuristics':
371 # Do full copytracing if only drafts are involved as that will be fast 371 # Do full copytracing if only drafts are involved as that will be fast
372 # enough and will also cover the copies which can be missed by 372 # enough and will also cover the copies which can be missed by
373 # heuristics 373 # heuristics
374 if _isfullcopytraceable(c1, base): 374 if _isfullcopytraceable(repo, c1, base):
375 return _fullcopytracing(repo, c1, c2, base) 375 return _fullcopytracing(repo, c1, c2, base)
376 return _heuristicscopytracing(repo, c1, c2, base) 376 return _heuristicscopytracing(repo, c1, c2, base)
377 else: 377 else:
378 return _fullcopytracing(repo, c1, c2, base) 378 return _fullcopytracing(repo, c1, c2, base)
379 379
380 def _isfullcopytraceable(c1, base): 380 def _isfullcopytraceable(repo, c1, base):
381 """ Checks that if base, source and destination are all draft branches, if 381 """ Checks that if base, source and destination are all draft branches, if
382 yes let's use the full copytrace algorithm for increased capabilities since 382 yes let's use the full copytrace algorithm for increased capabilities since
383 it will be fast enough. 383 it will be fast enough.
384 """ 384 """
385 if c1.rev() is None:
386 c1 = c1.p1()
385 387
386 nonpublicphases = set([phases.draft, phases.secret]) 388 nonpublicphases = set([phases.draft, phases.secret])
387 389
388 if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases): 390 if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
389 return True 391 sourcecommitlimit = repo.ui.configint('experimental',
392 'copytrace.sourcecommitlimit')
393 commits = len(repo.revs('%d::%d', base.rev(), c1.rev()))
394 return commits < sourcecommitlimit
390 return False 395 return False
391 396
392 def _fullcopytracing(repo, c1, c2, base): 397 def _fullcopytracing(repo, c1, c2, base):
393 """ The full copytracing algorithm which finds all the new files that were 398 """ The full copytracing algorithm which finds all the new files that were
394 added from merge base up to the top commit and for each file it checks if 399 added from merge base up to the top commit and for each file it checks if