366 store.put(source, hash) |
366 store.put(source, hash) |
367 at += 1 |
367 at += 1 |
368 ui.progress(_('uploading largefiles'), None) |
368 ui.progress(_('uploading largefiles'), None) |
369 |
369 |
370 def verifylfiles(ui, repo, all=False, contents=False): |
370 def verifylfiles(ui, repo, all=False, contents=False): |
371 '''Verify that every big file revision in the current changeset |
371 '''Verify that every largefile revision in the current changeset |
372 exists in the central store. With --contents, also verify that |
372 exists in the central store. With --contents, also verify that |
373 the contents of each big file revision are correct (SHA-1 hash |
373 the contents of each local largefile file revision are correct (SHA-1 hash |
374 matches the revision ID). With --all, check every changeset in |
374 matches the revision ID). With --all, check every changeset in |
375 this repository.''' |
375 this repository.''' |
376 if all: |
376 if all: |
377 # Pass a list to the function rather than an iterator because we know a |
377 # Pass a list to the function rather than an iterator because we know a |
378 # list will work. |
378 # list will work. |
528 lfdirstate.add(lfile) |
528 lfdirstate.add(lfile) |
529 elif state == '?': |
529 elif state == '?': |
530 lfdirstate.drop(lfile) |
530 lfdirstate.drop(lfile) |
531 return ret |
531 return ret |
532 |
532 |
533 def catlfile(repo, lfile, rev, filename): |
533 def lfpull(ui, repo, source="default", **opts): |
534 hash = lfutil.readstandin(repo, lfile, rev) |
534 """pull largefiles for the specified revisions from the specified source |
535 if not lfutil.inusercache(repo.ui, hash): |
535 |
536 store = basestore._openstore(repo) |
536 Pull largefiles that are referenced from local changesets but missing |
537 success, missing = store.get([(lfile, hash)]) |
537 locally, pulling from a remote repository to the local cache. |
538 if len(success) != 1: |
538 |
539 raise util.Abort( |
539 If SOURCE is omitted, the 'default' path will be used. |
540 _('largefile %s is not in cache and could not be downloaded') |
540 See :hg:`help urls` for more information. |
541 % lfile) |
541 |
542 path = lfutil.usercachepath(repo.ui, hash) |
542 .. container:: verbose |
543 fpout = cmdutil.makefileobj(repo, filename) |
543 |
544 fpin = open(path, "rb") |
544 Some examples: |
545 fpout.write(fpin.read()) |
545 |
546 fpout.close() |
546 - pull largefiles for all branch heads:: |
547 fpin.close() |
547 |
548 return 0 |
548 hg lfpull -r "head() and not closed()" |
|
549 |
|
550 - pull largefiles on the default branch:: |
|
551 |
|
552 hg lfpull -r "branch(default)" |
|
553 """ |
|
554 repo.lfpullsource = source |
|
555 |
|
556 revs = opts.get('rev', []) |
|
557 if not revs: |
|
558 raise util.Abort(_('no revisions specified')) |
|
559 revs = scmutil.revrange(repo, revs) |
|
560 |
|
561 numcached = 0 |
|
562 for rev in revs: |
|
563 ui.note(_('pulling largefiles for revision %s\n') % rev) |
|
564 (cached, missing) = cachelfiles(ui, repo, rev) |
|
565 numcached += len(cached) |
|
566 ui.status(_("%d largefiles cached\n") % numcached) |
549 |
567 |
550 # -- hg commands declarations ------------------------------------------------ |
568 # -- hg commands declarations ------------------------------------------------ |
551 |
569 |
552 cmdtable = { |
570 cmdtable = { |
553 'lfconvert': (lfconvert, |
571 'lfconvert': (lfconvert, |
557 'SIZE'), |
575 'SIZE'), |
558 ('', 'to-normal', False, |
576 ('', 'to-normal', False, |
559 _('convert from a largefiles repo to a normal repo')), |
577 _('convert from a largefiles repo to a normal repo')), |
560 ], |
578 ], |
561 _('hg lfconvert SOURCE DEST [FILE ...]')), |
579 _('hg lfconvert SOURCE DEST [FILE ...]')), |
|
580 'lfpull': (lfpull, |
|
581 [('r', 'rev', [], _('pull largefiles for these revisions')) |
|
582 ] + commands.remoteopts, |
|
583 _('-r REV... [-e CMD] [--remotecmd CMD] [SOURCE]') |
|
584 ), |
562 } |
585 } |
563 |
586 |
564 commands.inferrepo += " lfconvert" |
587 commands.inferrepo += " lfconvert" |