hgext/largefiles/lfcommands.py
changeset 39390 a65ad9b22a00
parent 38407 164306d3f4b4
child 39710 7375a9ab0149
equal deleted inserted replaced
39389:b26350d9d7b5 39390:a65ad9b22a00
   116                 matcher = matchmod.match(rsrc.root, '', list(pats))
   116                 matcher = matchmod.match(rsrc.root, '', list(pats))
   117             else:
   117             else:
   118                 matcher = None
   118                 matcher = None
   119 
   119 
   120             lfiletohash = {}
   120             lfiletohash = {}
   121             progress = ui.makeprogress(_('converting revisions'),
   121             with ui.makeprogress(_('converting revisions'),
   122                                        unit=_('revisions'),
   122                                  unit=_('revisions'),
   123                                        total=rsrc['tip'].rev())
   123                                  total=rsrc['tip'].rev()) as progress:
   124             for ctx in ctxs:
   124                 for ctx in ctxs:
   125                 progress.update(ctx.rev())
   125                     progress.update(ctx.rev())
   126                 _lfconvert_addchangeset(rsrc, rdst, ctx, revmap,
   126                     _lfconvert_addchangeset(rsrc, rdst, ctx, revmap,
   127                     lfiles, normalfiles, matcher, size, lfiletohash)
   127                         lfiles, normalfiles, matcher, size, lfiletohash)
   128             progress.complete()
       
   129 
   128 
   130             if rdst.wvfs.exists(lfutil.shortname):
   129             if rdst.wvfs.exists(lfutil.shortname):
   131                 rdst.wvfs.rmtree(lfutil.shortname)
   130                 rdst.wvfs.rmtree(lfutil.shortname)
   132 
   131 
   133             for f in lfiletohash.keys():
   132             for f in lfiletohash.keys():
   368     ui.debug("sending statlfile command for %d largefiles\n" % len(files))
   367     ui.debug("sending statlfile command for %d largefiles\n" % len(files))
   369     retval = store.exists(files)
   368     retval = store.exists(files)
   370     files = [h for h in files if not retval[h]]
   369     files = [h for h in files if not retval[h]]
   371     ui.debug("%d largefiles need to be uploaded\n" % len(files))
   370     ui.debug("%d largefiles need to be uploaded\n" % len(files))
   372 
   371 
   373     progress = ui.makeprogress(_('uploading largefiles'), unit=_('files'),
   372     with ui.makeprogress(_('uploading largefiles'), unit=_('files'),
   374                                total=len(files))
   373                          total=len(files)) as progress:
   375     for hash in files:
   374         for hash in files:
   376         progress.update(at)
   375             progress.update(at)
   377         source = lfutil.findfile(rsrc, hash)
   376             source = lfutil.findfile(rsrc, hash)
   378         if not source:
   377             if not source:
   379             raise error.Abort(_('largefile %s missing from store'
   378                 raise error.Abort(_('largefile %s missing from store'
   380                                ' (needs to be uploaded)') % hash)
   379                                    ' (needs to be uploaded)') % hash)
   381         # XXX check for errors here
   380             # XXX check for errors here
   382         store.put(source, hash)
   381             store.put(source, hash)
   383         at += 1
   382             at += 1
   384     progress.complete()
       
   385 
   383 
   386 def verifylfiles(ui, repo, all=False, contents=False):
   384 def verifylfiles(ui, repo, all=False, contents=False):
   387     '''Verify that every largefile revision in the current changeset
   385     '''Verify that every largefile revision in the current changeset
   388     exists in the central store.  With --contents, also verify that
   386     exists in the central store.  With --contents, also verify that
   389     the contents of each local largefile file revision are correct (SHA-1 hash
   387     the contents of each local largefile file revision are correct (SHA-1 hash