Details
Details
Diff Detail
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.
pulkit |
hg-reviewers |
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/lfs/blobstore.py (7 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | D3806 lfs: use progess helper | |
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
sizes = {} | sizes = {} | ||||
for obj in objects: | for obj in objects: | ||||
sizes[obj.get('oid')] = obj.get('size', 0) | sizes[obj.get('oid')] = obj.get('size', 0) | ||||
topic = {'upload': _('lfs uploading'), | topic = {'upload': _('lfs uploading'), | ||||
'download': _('lfs downloading')}[action] | 'download': _('lfs downloading')}[action] | ||||
if len(objects) > 1: | if len(objects) > 1: | ||||
self.ui.note(_('lfs: need to transfer %d objects (%s)\n') | self.ui.note(_('lfs: need to transfer %d objects (%s)\n') | ||||
% (len(objects), util.bytecount(total))) | % (len(objects), util.bytecount(total))) | ||||
self.ui.progress(topic, 0, total=total) | progress = self.ui.makeprogress(topic, total=total) | ||||
progress.update(0) | |||||
def transfer(chunk): | def transfer(chunk): | ||||
for obj in chunk: | for obj in chunk: | ||||
objsize = obj.get('size', 0) | objsize = obj.get('size', 0) | ||||
if self.ui.verbose: | if self.ui.verbose: | ||||
if action == 'download': | if action == 'download': | ||||
msg = _('lfs: downloading %s (%s)\n') | msg = _('lfs: downloading %s (%s)\n') | ||||
elif action == 'upload': | elif action == 'upload': | ||||
msg = _('lfs: uploading %s (%s)\n') | msg = _('lfs: uploading %s (%s)\n') | ||||
else: | else: | ||||
oids = transfer(sorted(objects, key=lambda o: o.get('oid'))) | oids = transfer(sorted(objects, key=lambda o: o.get('oid'))) | ||||
processed = 0 | processed = 0 | ||||
blobs = 0 | blobs = 0 | ||||
for _one, oid in oids: | for _one, oid in oids: | ||||
processed += sizes[oid] | processed += sizes[oid] | ||||
blobs += 1 | blobs += 1 | ||||
self.ui.progress(topic, processed, total=total) | progress.update(processed) | ||||
self.ui.note(_('lfs: processed: %s\n') % oid) | self.ui.note(_('lfs: processed: %s\n') % oid) | ||||
self.ui.progress(topic, pos=None, total=total) | progress.complete() | ||||
if blobs > 0: | if blobs > 0: | ||||
if action == 'upload': | if action == 'upload': | ||||
self.ui.status(_('lfs: uploaded %d files (%s)\n') | self.ui.status(_('lfs: uploaded %d files (%s)\n') | ||||
% (blobs, util.bytecount(processed))) | % (blobs, util.bytecount(processed))) | ||||
elif action == 'download': | elif action == 'download': | ||||
self.ui.status(_('lfs: downloaded %d files (%s)\n') | self.ui.status(_('lfs: downloaded %d files (%s)\n') | ||||
% (blobs, util.bytecount(processed))) | % (blobs, util.bytecount(processed))) |