This is an archive of the discontinued Mercurial Phabricator instance.

branchmap: load branchmap as an iterable
ClosedPublic

Authored by mjpieters on Aug 13 2018, 4:26 PM.

Details

Summary

This avoids reading all the file into memory if the cache turns out to be
invalid.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjpieters created this revision.Aug 13 2018, 4:26 PM
durin42 accepted this revision.Aug 15 2018, 11:07 PM
This revision is now accepted and ready to land.Aug 15 2018, 11:07 PM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Aug 16 2018, 6:36 AM

def read(repo):

try:
    f = repo.cachevfs(_filename(repo))
  • lines = f.read().split('\n')
  • f.close()
  • except (IOError, OSError):
  • return None -
  • try:
  • cachekey = lines.pop(0).split(" ", 2)

+ cachekey = next(f).split(" ", 2)

Several tests fail, probably because of missed rstrip().

partial.setdefault(label, []).append(node)
if state == 'c':
    partial._closednodes.add(node)

+
+ except (IOError, OSError):
+ return None
+

except Exception as inst:
    if repo.ui.debugflag:
        msg = 'invalid branchheads cache'

Missed finally: f.close()?