##// END OF EJS Templates
revset: add optimization for heads(commonancestors())...
Sean Farley -
r38644:52f19a84 default
parent child Browse files
Show More
@@ -608,6 +608,19 b' def closed(repo, subset, x):'
608 608 return subset.filter(lambda r: repo[r].closesbranch(),
609 609 condrepr='<branch closed>')
610 610
611 # for internal use
612 @predicate('_commonancestorheads(set)', safe=True)
613 def _commonancestorheads(repo, subset, x):
614 # This is an internal method is for quickly calculating "heads(::x and
615 # ::y)"
616
617 # These greatest common ancestors are the same ones that the consesus bid
618 # merge will find.
619 h = heads(repo, fullreposet(repo), x, defineorder)
620
621 ancs = repo.changelog._commonancestorsheads(*list(h))
622 return subset & baseset(ancs)
623
611 624 @predicate('commonancestors(set)', safe=True)
612 625 def commonancestors(repo, subset, x):
613 626 """Returns all common ancestors of the set.
@@ -459,6 +459,12 b' def _optimize(x):'
459 459 f = getsymbol(x[1])
460 460 wa, ta = _optimize(x[2])
461 461 w = getattr(symbols.get(f), '_weight', 1)
462 m = _match('commonancestors(_)', ta)
463
464 # Optimize heads(commonancestors(_)) because we have a fast version
465 if f == 'heads' and m:
466 return w + wa, _build('_commonancestorheads(_)', m[1])
467
462 468 return w + wa, (op, x[1], ta)
463 469 raise ValueError('invalid operator %r' % op)
464 470
@@ -410,6 +410,21 b' Verify how the output looks and and how '
410 410 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 411 (branch merge, don't forget to commit)
412 412
413 Test the greatest common ancestor returning multiple changesets
414
415 $ hg log -r 'heads(commonancestors(head()))'
416 changeset: 1:0f6b37dbe527
417 user: test
418 date: Thu Jan 01 00:00:00 1970 +0000
419 summary: 1 first change f1
420
421 changeset: 2:d1d156401c1b
422 parent: 0:40494bf2444c
423 user: test
424 date: Thu Jan 01 00:00:00 1970 +0000
425 summary: 2 first change f2
426
427
413 428 $ cd ..
414 429
415 430 http://stackoverflow.com/questions/9350005/how-do-i-specify-a-merge-base-to-use-in-a-hg-merge/9430810
@@ -1834,3 +1834,21 b' Test `draft() & ::x` optimization'
1834 1834 (keyvalue
1835 1835 (symbol 'depth')
1836 1836 (symbol '1')))))
1837
1838 test commonancestors and its optimization
1839
1840 $ hg debugrevspec --verify -p analyzed -p optimized 'heads(commonancestors(head()))'
1841 * analyzed:
1842 (func
1843 (symbol 'heads')
1844 (func
1845 (symbol 'commonancestors')
1846 (func
1847 (symbol 'head')
1848 None)))
1849 * optimized:
1850 (func
1851 (symbol '_commonancestorheads')
1852 (func
1853 (symbol 'head')
1854 None))
General Comments 0
You need to be logged in to leave comments. Login now