comparison mercurial/copies.py @ 34366:d00910b286cd

copytrace: use ctx.mutable() instead of adhoc constant of non-public phases
author Yuya Nishihara <yuya@tcha.org>
date Fri, 22 Sep 2017 22:45:02 +0900
parents 1a5abc45e2fa
children e79b3611223b
comparison
equal deleted inserted replaced
34365:cd3f39716fd3 34366:d00910b286cd
13 13
14 from . import ( 14 from . import (
15 match as matchmod, 15 match as matchmod,
16 node, 16 node,
17 pathutil, 17 pathutil,
18 phases,
19 scmutil, 18 scmutil,
20 util, 19 util,
21 ) 20 )
22 21
23 def _findlimit(repo, a, b): 22 def _findlimit(repo, a, b):
366 # because the logic above is required for a simple copy to be kept across a 365 # because the logic above is required for a simple copy to be kept across a
367 # rebase. 366 # rebase.
368 if copytracing == 'off': 367 if copytracing == 'off':
369 return {}, {}, {}, {}, {} 368 return {}, {}, {}, {}, {}
370 elif copytracing == 'heuristics': 369 elif copytracing == 'heuristics':
371 # Do full copytracing if only drafts are involved as that will be fast 370 # Do full copytracing if only non-public revisions are involved as
372 # enough and will also cover the copies which can be missed by 371 # that will be fast enough and will also cover the copies which could
373 # heuristics 372 # be missed by heuristics
374 if _isfullcopytraceable(repo, c1, base): 373 if _isfullcopytraceable(repo, c1, base):
375 return _fullcopytracing(repo, c1, c2, base) 374 return _fullcopytracing(repo, c1, c2, base)
376 return _heuristicscopytracing(repo, c1, c2, base) 375 return _heuristicscopytracing(repo, c1, c2, base)
377 else: 376 else:
378 return _fullcopytracing(repo, c1, c2, base) 377 return _fullcopytracing(repo, c1, c2, base)
379 378
380 def _isfullcopytraceable(repo, c1, base): 379 def _isfullcopytraceable(repo, c1, base):
381 """ Checks that if base, source and destination are all draft branches, if 380 """ Checks that if base, source and destination are all no-public branches,
382 yes let's use the full copytrace algorithm for increased capabilities since 381 if yes let's use the full copytrace algorithm for increased capabilities
383 it will be fast enough. 382 since it will be fast enough.
384 """ 383 """
385 if c1.rev() is None: 384 if c1.rev() is None:
386 c1 = c1.p1() 385 c1 = c1.p1()
387 386 if c1.mutable() and base.mutable():
388 nonpublicphases = set([phases.draft, phases.secret])
389
390 if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
391 sourcecommitlimit = repo.ui.configint('experimental', 387 sourcecommitlimit = repo.ui.configint('experimental',
392 'copytrace.sourcecommitlimit') 388 'copytrace.sourcecommitlimit')
393 commits = len(repo.revs('%d::%d', base.rev(), c1.rev())) 389 commits = len(repo.revs('%d::%d', base.rev(), c1.rev()))
394 return commits < sourcecommitlimit 390 return commits < sourcecommitlimit
395 return False 391 return False