Comments
Patch
@@ -478,6 +478,7 @@ def branch(repo, subset, x):
a regular expression. To match a branch that actually starts with `re:`,
use the prefix `literal:`.
"""
+ branch = repo.revbranchcache.branch
try:
b = getstring(x, '')
except error.ParseError:
@@ -489,16 +490,16 @@ def branch(repo, subset, x):
# note: falls through to the revspec case if no branch with
# this name exists
if pattern in repo.branchmap():
- return subset.filter(lambda r: matcher(repo[r].branch()))
+ return subset.filter(lambda r: matcher(branch(r)))
else:
- return subset.filter(lambda r: matcher(repo[r].branch()))
+ return subset.filter(lambda r: matcher(branch(r)))
s = getset(repo, spanset(repo), x)
b = set()
for r in s:
- b.add(repo[r].branch())
+ b.add(branch(r))
c = s.__contains__
- return subset.filter(lambda r: c(r) or repo[r].branch() in b)
+ return subset.filter(lambda r: c(r) or branch(r) in b)
def bumped(repo, subset, x):
"""``bumped()``
@@ -1431,7 +1432,7 @@ def matching(repo, subset, x):
getfieldfuncs = []
_funcs = {
'user': lambda r: repo[r].user(),
- 'branch': lambda r: repo[r].branch(),
+ 'branch': repo.revbranchcache.branch,
'date': lambda r: repo[r].date(),
'description': lambda r: repo[r].description(),
'files': lambda r: repo[r].files(),
@@ -1532,9 +1533,9 @@ def sort(repo, subset, x):
elif k == '-rev':
e.append(-r)
elif k == 'branch':
- e.append(c.branch())
+ e.append(repo.revbranchcache.branch(r))
elif k == '-branch':
- e.append(invert(c.branch()))
+ e.append(invert(repo.revbranchcache.branch(r)))
elif k == 'desc':
e.append(c.description())
elif k == '-desc':
@@ -744,6 +744,64 @@ issue2437
$ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(é)))'
4
+branchname caching
+
+ cache creation
+ $ rm .hg/cache/branchnames
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ c31b7e7bdc4e1f69133685cf82550eac .hg/cache/branchnames
+ handling of invalid cache file
+ $ echo > .hg/cache/branchnames
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ c31b7e7bdc4e1f69133685cf82550eac .hg/cache/branchnames
+ handling of extra trailing data
+ $ echo >> .hg/cache/branchnames
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ c31b7e7bdc4e1f69133685cf82550eac .hg/cache/branchnames
+ update after commit
+ $ hg tag tag
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ c31b7e7bdc4e1f69133685cf82550eac .hg/cache/branchnames
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ 77d75afbf592f045b609c3a68986a908 .hg/cache/branchnames
+ $ update after rollback
+ $ hg up -qr '.^'
+ $ hg rollback -qf
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ 77d75afbf592f045b609c3a68986a908 .hg/cache/branchnames
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ c31b7e7bdc4e1f69133685cf82550eac .hg/cache/branchnames
+ handle non-tip node change (could be a problem with some cache invalidation schemes)
+ $ hg bundle -q --all bu.hg
+ $ hg --config extensions.strip= strip --no-b -qr 8
+ $ hg up -q 7
+ $ hg branch -q hacked
+ $ hg ci --amend -qm 'hacked'
+ $ hg pull -q bu.hg -r 24286f4ae135
+ $ log 'branch("hacked")'
+ 7
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ 7e7547be03cd3badb5053899aea5c532 .hg/cache/branchnames
+ $ hg --config extensions.strip= strip --no-b -qr 7:
+ $ hg pull -q bu.hg
+ $ rm bu.hg
+ $ hg up -qr tip
+ $ log 'branch("-a-b-c-")'
+ 4
+ $ "$TESTDIR/md5sum.py" .hg/cache/branchnames
+ 753e486275e544c562da095fd116a441 .hg/cache/branchnames
+(the cache file still contains the now unused 'hacked' branch name)
+
issue2654: report a parse error if the revset was not completely parsed
$ log '1 OR 2'