Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGb6a6dc1a14bd: remotefilelog: use progress helper in shallowrepo
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/remotefilelog/shallowrepo.py (11 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Dec 4 2018, 7:32 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
if util.safehasattr(util, '_hgexecutable'): | if util.safehasattr(util, '_hgexecutable'): | ||||
# Before 5be286db | # Before 5be286db | ||||
_hgexecutable = util.hgexecutable | _hgexecutable = util.hgexecutable | ||||
else: | else: | ||||
from mercurial.utils import procutil | from mercurial.utils import procutil | ||||
_hgexecutable = procutil.hgexecutable | _hgexecutable = procutil.hgexecutable | ||||
_prefetching = _('prefetching') | |||||
# These make*stores functions are global so that other extensions can replace | # These make*stores functions are global so that other extensions can replace | ||||
# them. | # them. | ||||
def makelocalstores(repo): | def makelocalstores(repo): | ||||
"""In-repo stores, like .hg/store/data; can not be discarded.""" | """In-repo stores, like .hg/store/data; can not be discarded.""" | ||||
localpath = os.path.join(repo.svfs.vfs.base, 'data') | localpath = os.path.join(repo.svfs.vfs.base, 'data') | ||||
if not os.path.exists(localpath): | if not os.path.exists(localpath): | ||||
os.makedirs(localpath) | os.makedirs(localpath) | ||||
skip = set() | skip = set() | ||||
# Copy the skip set to start large and avoid constant resizing, | # Copy the skip set to start large and avoid constant resizing, | ||||
# and since it's likely to be very similar to the prefetch set. | # and since it's likely to be very similar to the prefetch set. | ||||
files = skip.copy() | files = skip.copy() | ||||
serverfiles = skip.copy() | serverfiles = skip.copy() | ||||
visited = set() | visited = set() | ||||
visited.add(nullrev) | visited.add(nullrev) | ||||
revnum = 0 | |||||
revcount = len(revs) | revcount = len(revs) | ||||
self.ui.progress(_prefetching, revnum, total=revcount) | progress = self.ui.makeprogress(_('prefetching'), total=revcount) | ||||
progress.update(0) | |||||
for rev in sorted(revs): | for rev in sorted(revs): | ||||
ctx = repo[rev] | ctx = repo[rev] | ||||
if pats: | if pats: | ||||
m = scmutil.match(ctx, pats, opts) | m = scmutil.match(ctx, pats, opts) | ||||
sparsematch = repo.maybesparsematch(rev) | sparsematch = repo.maybesparsematch(rev) | ||||
mfnode = ctx.manifestnode() | mfnode = ctx.manifestnode() | ||||
mfrev = mfrevlog.rev(mfnode) | mfrev = mfrevlog.rev(mfnode) | ||||
if sparsematch: | if sparsematch: | ||||
diff = (pf for pf in diff if sparsematch(pf[0])) | diff = (pf for pf in diff if sparsematch(pf[0])) | ||||
if rev not in localrevs: | if rev not in localrevs: | ||||
serverfiles.update(diff) | serverfiles.update(diff) | ||||
else: | else: | ||||
files.update(diff) | files.update(diff) | ||||
visited.add(mfrev) | visited.add(mfrev) | ||||
revnum += 1 | progress.increment() | ||||
self.ui.progress(_prefetching, revnum, total=revcount) | |||||
files.difference_update(skip) | files.difference_update(skip) | ||||
serverfiles.difference_update(skip) | serverfiles.difference_update(skip) | ||||
self.ui.progress(_prefetching, None) | progress.complete() | ||||
# Fetch files known to be on the server | # Fetch files known to be on the server | ||||
if serverfiles: | if serverfiles: | ||||
results = [(path, hex(fnode)) for (path, fnode) in serverfiles] | results = [(path, hex(fnode)) for (path, fnode) in serverfiles] | ||||
repo.fileservice.prefetch(results, force=True) | repo.fileservice.prefetch(results, force=True) | ||||
# Fetch files that may or may not be on the server | # Fetch files that may or may not be on the server | ||||
if files: | if files: |