Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG312afd164009: remotefilelog: do file IO in terms of bytes
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/remotefilelog/__init__.py (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Augie Fackler | Jan 16 2019, 10:55 AM |
def gcclient(ui, cachepath): | def gcclient(ui, cachepath): | ||||
# get list of repos that use this cache | # get list of repos that use this cache | ||||
repospath = os.path.join(cachepath, 'repos') | repospath = os.path.join(cachepath, 'repos') | ||||
if not os.path.exists(repospath): | if not os.path.exists(repospath): | ||||
ui.warn(_("no known cache at %s\n") % cachepath) | ui.warn(_("no known cache at %s\n") % cachepath) | ||||
return | return | ||||
reposfile = open(repospath, 'r') | reposfile = open(repospath, 'rb') | ||||
repos = set([r[:-1] for r in reposfile.readlines()]) | repos = set([r[:-1] for r in reposfile.readlines()]) | ||||
reposfile.close() | reposfile.close() | ||||
# build list of useful files | # build list of useful files | ||||
validrepos = [] | validrepos = [] | ||||
keepkeys = set() | keepkeys = set() | ||||
sharedcache = None | sharedcache = None | ||||
return fileserverclient.getcachekey(reponame, fname, hex(fnode)) | return fileserverclient.getcachekey(reponame, fname, hex(fnode)) | ||||
keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys) | keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys) | ||||
progress.complete() | progress.complete() | ||||
# write list of valid repos back | # write list of valid repos back | ||||
oldumask = os.umask(0o002) | oldumask = os.umask(0o002) | ||||
try: | try: | ||||
reposfile = open(repospath, 'w') | reposfile = open(repospath, 'wb') | ||||
reposfile.writelines([("%s\n" % r) for r in validrepos]) | reposfile.writelines([("%s\n" % r) for r in validrepos]) | ||||
reposfile.close() | reposfile.close() | ||||
finally: | finally: | ||||
os.umask(oldumask) | os.umask(oldumask) | ||||
# prune cache | # prune cache | ||||
if sharedcache is not None: | if sharedcache is not None: | ||||
sharedcache.gc(keepkeys) | sharedcache.gc(keepkeys) |