hgext/largefiles/lfcommands.py
changeset 26587 56b2bcea2529
parent 25660 328739ea70c3
child 26944 ef5bab63af85
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    60     else:
    60     else:
    61         tolfile = True
    61         tolfile = True
    62         size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
    62         size = lfutil.getminsize(ui, True, opts.get('size'), default=None)
    63 
    63 
    64     if not hg.islocal(src):
    64     if not hg.islocal(src):
    65         raise util.Abort(_('%s is not a local Mercurial repo') % src)
    65         raise error.Abort(_('%s is not a local Mercurial repo') % src)
    66     if not hg.islocal(dest):
    66     if not hg.islocal(dest):
    67         raise util.Abort(_('%s is not a local Mercurial repo') % dest)
    67         raise error.Abort(_('%s is not a local Mercurial repo') % dest)
    68 
    68 
    69     rsrc = hg.repository(ui, src)
    69     rsrc = hg.repository(ui, src)
    70     ui.status(_('initializing destination %s\n') % dest)
    70     ui.status(_('initializing destination %s\n') % dest)
    71     rdst = hg.repository(ui, dest, create=True)
    71     rdst = hg.repository(ui, dest, create=True)
    72 
    72 
   137                     # Substitute in the largefile data for the hash
   137                     # Substitute in the largefile data for the hash
   138                     hash = f[0].strip()
   138                     hash = f[0].strip()
   139                     path = lfutil.findfile(rsrc, hash)
   139                     path = lfutil.findfile(rsrc, hash)
   140 
   140 
   141                     if path is None:
   141                     if path is None:
   142                         raise util.Abort(_("missing largefile for \'%s\' in %s")
   142                         raise error.Abort(_("missing largefile for '%s' in %s")
   143                                           % (realname, realrev))
   143                                           % (realname, realrev))
   144                     fp = open(path, 'rb')
   144                     fp = open(path, 'rb')
   145 
   145 
   146                     try:
   146                     try:
   147                         return (fp.read(), f[1])
   147                         return (fp.read(), f[1])
   155                     super(converter, self).__init__(ui, src, dest, revmapfile,
   155                     super(converter, self).__init__(ui, src, dest, revmapfile,
   156                                                     opts)
   156                                                     opts)
   157 
   157 
   158             found, missing = downloadlfiles(ui, rsrc)
   158             found, missing = downloadlfiles(ui, rsrc)
   159             if missing != 0:
   159             if missing != 0:
   160                 raise util.Abort(_("all largefiles must be present locally"))
   160                 raise error.Abort(_("all largefiles must be present locally"))
   161 
   161 
   162             orig = convcmd.converter
   162             orig = convcmd.converter
   163             convcmd.converter = converter
   163             convcmd.converter = converter
   164 
   164 
   165             try:
   165             try:
   194                 renamed = fctx.renamed()
   194                 renamed = fctx.renamed()
   195                 renamedlfile = renamed and renamed[0] in lfiles
   195                 renamedlfile = renamed and renamed[0] in lfiles
   196                 islfile |= renamedlfile
   196                 islfile |= renamedlfile
   197                 if 'l' in fctx.flags():
   197                 if 'l' in fctx.flags():
   198                     if renamedlfile:
   198                     if renamedlfile:
   199                         raise util.Abort(
   199                         raise error.Abort(
   200                             _('renamed/copied largefile %s becomes symlink')
   200                             _('renamed/copied largefile %s becomes symlink')
   201                             % f)
   201                             % f)
   202                     islfile = False
   202                     islfile = False
   203             if islfile:
   203             if islfile:
   204                 lfiles.add(f)
   204                 lfiles.add(f)
   211             if f in ctx.manifest():
   211             if f in ctx.manifest():
   212                 fctx = ctx.filectx(f)
   212                 fctx = ctx.filectx(f)
   213                 if 'l' in fctx.flags():
   213                 if 'l' in fctx.flags():
   214                     renamed = fctx.renamed()
   214                     renamed = fctx.renamed()
   215                     if renamed and renamed[0] in lfiles:
   215                     if renamed and renamed[0] in lfiles:
   216                         raise util.Abort(_('largefile %s becomes symlink') % f)
   216                         raise error.Abort(_('largefile %s becomes symlink') % f)
   217 
   217 
   218                 # largefile was modified, update standins
   218                 # largefile was modified, update standins
   219                 m = util.sha1('')
   219                 m = util.sha1('')
   220                 m.update(ctx[f].data())
   220                 m.update(ctx[f].data())
   221                 hash = m.hexdigest()
   221                 hash = m.hexdigest()
   353     for hash in files:
   353     for hash in files:
   354         ui.progress(_('uploading largefiles'), at, unit='largefile',
   354         ui.progress(_('uploading largefiles'), at, unit='largefile',
   355                     total=len(files))
   355                     total=len(files))
   356         source = lfutil.findfile(rsrc, hash)
   356         source = lfutil.findfile(rsrc, hash)
   357         if not source:
   357         if not source:
   358             raise util.Abort(_('largefile %s missing from store'
   358             raise error.Abort(_('largefile %s missing from store'
   359                                ' (needs to be uploaded)') % hash)
   359                                ' (needs to be uploaded)') % hash)
   360         # XXX check for errors here
   360         # XXX check for errors here
   361         store.put(source, hash)
   361         store.put(source, hash)
   362         at += 1
   362         at += 1
   363     ui.progress(_('uploading largefiles'), None)
   363     ui.progress(_('uploading largefiles'), None)
   537     """
   537     """
   538     repo.lfpullsource = source
   538     repo.lfpullsource = source
   539 
   539 
   540     revs = opts.get('rev', [])
   540     revs = opts.get('rev', [])
   541     if not revs:
   541     if not revs:
   542         raise util.Abort(_('no revisions specified'))
   542         raise error.Abort(_('no revisions specified'))
   543     revs = scmutil.revrange(repo, revs)
   543     revs = scmutil.revrange(repo, revs)
   544 
   544 
   545     numcached = 0
   545     numcached = 0
   546     for rev in revs:
   546     for rev in revs:
   547         ui.note(_('pulling largefiles for revision %s\n') % rev)
   547         ui.note(_('pulling largefiles for revision %s\n') % rev)