Show More
@@ -98,7 +98,7 b' def updatecache(repo):' | |||||
98 | partial.write(repo) |
|
98 | partial.write(repo) | |
99 |
|
99 | |||
100 | if repo._revbranchcache is not None: |
|
100 | if repo._revbranchcache is not None: | |
101 |
repo._revbranchcache.write( |
|
101 | repo._revbranchcache.write() | |
102 |
|
102 | |||
103 | assert partial.validfor(repo), filtername |
|
103 | assert partial.validfor(repo), filtername | |
104 | repo._branchcaches[repo.filtername] = partial |
|
104 | repo._branchcaches[repo.filtername] = partial | |
@@ -239,11 +239,9 b' class branchcache(dict):' | |||||
239 | cl = repo.changelog |
|
239 | cl = repo.changelog | |
240 | # collect new branch entries |
|
240 | # collect new branch entries | |
241 | newbranches = {} |
|
241 | newbranches = {} | |
242 | urepo = repo.unfiltered() |
|
|||
243 | ucl = urepo.changelog |
|
|||
244 | getbranchinfo = repo.revbranchcache().branchinfo |
|
242 | getbranchinfo = repo.revbranchcache().branchinfo | |
245 | for r in revgen: |
|
243 | for r in revgen: | |
246 |
branch, closesbranch = getbranchinfo( |
|
244 | branch, closesbranch = getbranchinfo(r) | |
247 | newbranches.setdefault(branch, []).append(r) |
|
245 | newbranches.setdefault(branch, []).append(r) | |
248 | if closesbranch: |
|
246 | if closesbranch: | |
249 | self._closednodes.add(cl.node(r)) |
|
247 | self._closednodes.add(cl.node(r)) | |
@@ -331,6 +329,7 b' class revbranchcache(object):' | |||||
331 |
|
329 | |||
332 | def __init__(self, repo, readonly=True): |
|
330 | def __init__(self, repo, readonly=True): | |
333 | assert repo.filtername is None |
|
331 | assert repo.filtername is None | |
|
332 | self._repo = repo | |||
334 | self._names = [] # branch names in local encoding with static index |
|
333 | self._names = [] # branch names in local encoding with static index | |
335 | self._rbcrevs = array('c') # structs of type _rbcrecfmt |
|
334 | self._rbcrevs = array('c') # structs of type _rbcrecfmt | |
336 | self._rbcsnameslen = 0 |
|
335 | self._rbcsnameslen = 0 | |
@@ -360,9 +359,10 b' class revbranchcache(object):' | |||||
360 | self._rbcnamescount = len(self._names) # number of good names on disk |
|
359 | self._rbcnamescount = len(self._names) # number of good names on disk | |
361 | self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) |
|
360 | self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) | |
362 |
|
361 | |||
363 |
def branchinfo(self, |
|
362 | def branchinfo(self, rev): | |
364 | """Return branch name and close flag for rev, using and updating |
|
363 | """Return branch name and close flag for rev, using and updating | |
365 | persistent cache.""" |
|
364 | persistent cache.""" | |
|
365 | changelog = self._repo.changelog | |||
366 | rbcrevidx = rev * _rbcrecsize |
|
366 | rbcrevidx = rev * _rbcrecsize | |
367 |
|
367 | |||
368 | # if requested rev is missing, add and populate all missing revs |
|
368 | # if requested rev is missing, add and populate all missing revs | |
@@ -371,7 +371,7 b' class revbranchcache(object):' | |||||
371 | self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize - |
|
371 | self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize - | |
372 | len(self._rbcrevs))) |
|
372 | len(self._rbcrevs))) | |
373 | for r in xrange(first, len(changelog)): |
|
373 | for r in xrange(first, len(changelog)): | |
374 |
self._branchinfo( |
|
374 | self._branchinfo(r) | |
375 |
|
375 | |||
376 | # fast path: extract data from cache, use it if node is matching |
|
376 | # fast path: extract data from cache, use it if node is matching | |
377 | reponode = changelog.node(rev)[:_rbcnodelen] |
|
377 | reponode = changelog.node(rev)[:_rbcnodelen] | |
@@ -384,10 +384,11 b' class revbranchcache(object):' | |||||
384 | return self._names[branchidx], close |
|
384 | return self._names[branchidx], close | |
385 | # fall back to slow path and make sure it will be written to disk |
|
385 | # fall back to slow path and make sure it will be written to disk | |
386 | self._rbcrevslen = min(self._rbcrevslen, rev) |
|
386 | self._rbcrevslen = min(self._rbcrevslen, rev) | |
387 |
return self._branchinfo( |
|
387 | return self._branchinfo(rev) | |
388 |
|
388 | |||
389 |
def _branchinfo(self, |
|
389 | def _branchinfo(self, rev): | |
390 | """Retrieve branch info from changelog and update _rbcrevs""" |
|
390 | """Retrieve branch info from changelog and update _rbcrevs""" | |
|
391 | changelog = self._repo.changelog | |||
391 | b, close = changelog.branchinfo(rev) |
|
392 | b, close = changelog.branchinfo(rev) | |
392 | if b in self._namesreverse: |
|
393 | if b in self._namesreverse: | |
393 | branchidx = self._namesreverse[b] |
|
394 | branchidx = self._namesreverse[b] | |
@@ -404,8 +405,9 b' class revbranchcache(object):' | |||||
404 | self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec |
|
405 | self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec | |
405 | return b, close |
|
406 | return b, close | |
406 |
|
407 | |||
407 |
def write(self |
|
408 | def write(self): | |
408 | """Save branch cache if it is dirty.""" |
|
409 | """Save branch cache if it is dirty.""" | |
|
410 | repo = self._repo | |||
409 | if self._rbcnamescount < len(self._names): |
|
411 | if self._rbcnamescount < len(self._names): | |
410 | try: |
|
412 | try: | |
411 | if self._rbcnamescount != 0: |
|
413 | if self._rbcnamescount != 0: |
@@ -528,10 +528,7 b' def branch(repo, subset, x):' | |||||
528 | a regular expression. To match a branch that actually starts with `re:`, |
|
528 | a regular expression. To match a branch that actually starts with `re:`, | |
529 | use the prefix `literal:`. |
|
529 | use the prefix `literal:`. | |
530 | """ |
|
530 | """ | |
531 | import branchmap |
|
531 | getbi = repo.revbranchcache().branchinfo | |
532 | urepo = repo.unfiltered() |
|
|||
533 | ucl = urepo.changelog |
|
|||
534 | getbi = branchmap.revbranchcache(urepo, readonly=True).branchinfo |
|
|||
535 |
|
532 | |||
536 | try: |
|
533 | try: | |
537 | b = getstring(x, '') |
|
534 | b = getstring(x, '') | |
@@ -544,16 +541,16 b' def branch(repo, subset, x):' | |||||
544 | # note: falls through to the revspec case if no branch with |
|
541 | # note: falls through to the revspec case if no branch with | |
545 | # this name exists |
|
542 | # this name exists | |
546 | if pattern in repo.branchmap(): |
|
543 | if pattern in repo.branchmap(): | |
547 |
return subset.filter(lambda r: matcher(getbi( |
|
544 | return subset.filter(lambda r: matcher(getbi(r)[0])) | |
548 | else: |
|
545 | else: | |
549 |
return subset.filter(lambda r: matcher(getbi( |
|
546 | return subset.filter(lambda r: matcher(getbi(r)[0])) | |
550 |
|
547 | |||
551 | s = getset(repo, fullreposet(repo), x) |
|
548 | s = getset(repo, fullreposet(repo), x) | |
552 | b = set() |
|
549 | b = set() | |
553 | for r in s: |
|
550 | for r in s: | |
554 |
b.add(getbi( |
|
551 | b.add(getbi(r)[0]) | |
555 | c = s.__contains__ |
|
552 | c = s.__contains__ | |
556 |
return subset.filter(lambda r: c(r) or getbi( |
|
553 | return subset.filter(lambda r: c(r) or getbi(r)[0] in b) | |
557 |
|
554 | |||
558 | def bumped(repo, subset, x): |
|
555 | def bumped(repo, subset, x): | |
559 | """``bumped()`` |
|
556 | """``bumped()`` |
General Comments 0
You need to be logged in to leave comments.
Login now