##// END OF EJS Templates
revset: use localrepo revbranchcache for branch name filtering...
Mads Kiilerich -
r23787:678f5386 default
parent child Browse files
Show More
@@ -457,6 +457,11 b' def branch(repo, subset, x):'
457 a regular expression. To match a branch that actually starts with `re:`,
457 a regular expression. To match a branch that actually starts with `re:`,
458 use the prefix `literal:`.
458 use the prefix `literal:`.
459 """
459 """
460 import branchmap
461 urepo = repo.unfiltered()
462 ucl = urepo.changelog
463 getbi = branchmap.revbranchcache(urepo).branchinfo
464
460 try:
465 try:
461 b = getstring(x, '')
466 b = getstring(x, '')
462 except error.ParseError:
467 except error.ParseError:
@@ -468,16 +473,16 b' def branch(repo, subset, x):'
468 # note: falls through to the revspec case if no branch with
473 # note: falls through to the revspec case if no branch with
469 # this name exists
474 # this name exists
470 if pattern in repo.branchmap():
475 if pattern in repo.branchmap():
471 return subset.filter(lambda r: matcher(repo[r].branch()))
476 return subset.filter(lambda r: matcher(getbi(ucl, r)[0]))
472 else:
477 else:
473 return subset.filter(lambda r: matcher(repo[r].branch()))
478 return subset.filter(lambda r: matcher(getbi(ucl, r)[0]))
474
479
475 s = getset(repo, spanset(repo), x)
480 s = getset(repo, spanset(repo), x)
476 b = set()
481 b = set()
477 for r in s:
482 for r in s:
478 b.add(repo[r].branch())
483 b.add(getbi(ucl, r)[0])
479 c = s.__contains__
484 c = s.__contains__
480 return subset.filter(lambda r: c(r) or repo[r].branch() in b)
485 return subset.filter(lambda r: c(r) or getbi(ucl, r)[0] in b)
481
486
482 def bumped(repo, subset, x):
487 def bumped(repo, subset, x):
483 """``bumped()``
488 """``bumped()``
@@ -520,4 +520,79 b' template output:'
520 }
520 }
521 ]
521 ]
522
522
523 revision branch name caching implementation
524
525 cache creation
526 $ rm .hg/cache/rbc-revs-v1
527 $ hg debugrevspec 'branch("re:a ")'
528 7
529 $ [ -f .hg/cache/rbc-revs-v1 ] || echo no file
530 no file
531 recovery from invalid cache file
532 $ echo > .hg/cache/rbc-revs-v1
533 $ hg debugrevspec 'branch("re:a ")'
534 7
535 cache update NOT fully written from revset
536 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
537 68b329da9893e34099c7d8ad5cb9c940 .hg/cache/rbc-revs-v1
538 recovery from other corruption - extra trailing data
539 $ echo >> .hg/cache/rbc-revs-v1
540 $ hg debugrevspec 'branch("re:a ")'
541 7
542 cache update NOT fully written from revset
543 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
544 e1c06d85ae7b8b032bef47e42e4c08f9 .hg/cache/rbc-revs-v1
545 lazy update after commit
546 $ hg tag tag
547 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
548 d0c0166808ee0a1f0e8894915ad363b6 .hg/cache/rbc-revs-v1
549 $ hg debugrevspec 'branch("re:a ")'
550 7
551 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
552 d0c0166808ee0a1f0e8894915ad363b6 .hg/cache/rbc-revs-v1
553 update after rollback - cache keeps stripped revs until written for other reasons
554 $ hg up -qr '.^'
555 $ hg rollback -qf
556 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
557 d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
558 $ hg debugrevspec 'branch("re:a ")'
559 7
560 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
561 d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
562 handle history mutations that doesn't change the tip node - this is a problem
563 with the cache invalidation scheme used by branchmap
564 $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
565 14:f894c25619d3 c
566 13:e23b5505d1ad b
567 $ hg bundle -q --all bu.hg
568 $ hg --config extensions.strip= strip --no-b -qr -1:
569 $ hg up -q tip
570 $ hg branch
571 b
572 $ hg branch -q hacked
573 $ hg ci --amend -qm 'hacked'
574 $ hg pull -q bu.hg -r f894c25619d3
575 $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
576 14:f894c25619d3 c
577 12:e3d49c0575d8 b
578 $ hg debugrevspec 'branch("hacked")'
579 13
580 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
581 22424d7e106c894336d9d705b0241bc5 .hg/cache/rbc-revs-v1
582 cleanup, restore old state
583 $ hg --config extensions.strip= strip --no-b -qr -2:
584 $ hg pull -q bu.hg
585 $ rm bu.hg
586 $ hg up -qr tip
587 $ hg log -r tip -T'{rev}:{node|short}\n'
588 14:f894c25619d3
589 the cache file do not go back to the old state - it still contains the
590 now unused 'hacked' branch name)
591 $ hg debugrevspec 'branch("re:a ")'
592 7
593 $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
594 d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
595 $ cat .hg/cache/rbc-names-v1
596 default\x00a\x00b\x00c\x00a branch name much longer than the default justification used by branches\x00hacked (no-eol) (esc)
597
523 $ cd ..
598 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now