Show More
@@ -578,14 +578,13 b' def overridecopy(orig, ui, repo, pats, o' | |||
|
578 | 578 | nolfiles = False |
|
579 | 579 | installnormalfilesmatchfn(repo[None].manifest()) |
|
580 | 580 | try: |
|
581 | try: | |
|
582 | result = orig(ui, repo, pats, opts, rename) | |
|
583 | except util.Abort, e: | |
|
584 | if str(e) != _('no files to copy'): | |
|
585 | raise e | |
|
586 |
|
|
|
587 | nonormalfiles = True | |
|
588 | result = 0 | |
|
581 | result = orig(ui, repo, pats, opts, rename) | |
|
582 | except util.Abort, e: | |
|
583 | if str(e) != _('no files to copy'): | |
|
584 | raise e | |
|
585 | else: | |
|
586 | nonormalfiles = True | |
|
587 | result = 0 | |
|
589 | 588 | finally: |
|
590 | 589 | restorematchfn() |
|
591 | 590 | |
@@ -608,86 +607,85 b' def overridecopy(orig, ui, repo, pats, o' | |||
|
608 | 607 | os.makedirs(makestandin(dest)) |
|
609 | 608 | |
|
610 | 609 | try: |
|
611 | try: | |
|
612 | # When we call orig below it creates the standins but we don't add | |
|
613 | # them to the dir state until later so lock during that time. | |
|
614 | wlock = repo.wlock() | |
|
610 | # When we call orig below it creates the standins but we don't add | |
|
611 | # them to the dir state until later so lock during that time. | |
|
612 | wlock = repo.wlock() | |
|
615 | 613 | |
|
616 |
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
|
621 |
|
|
|
622 | for pat in pats: | |
|
623 | if match_.patkind(pat) is None and lfutil.shortname in pat: | |
|
624 | newpats.append(pat.replace(lfutil.shortname, '')) | |
|
625 | else: | |
|
626 | newpats.append(pat) | |
|
627 | match = oldmatch(ctx, newpats, opts, globbed, default) | |
|
628 | m = copy.copy(match) | |
|
629 | lfile = lambda f: lfutil.standin(f) in manifest | |
|
630 | m._files = [lfutil.standin(f) for f in m._files if lfile(f)] | |
|
631 | m._fmap = set(m._files) | |
|
632 | origmatchfn = m.matchfn | |
|
633 | m.matchfn = lambda f: (lfutil.isstandin(f) and | |
|
634 | (f in manifest) and | |
|
635 | origmatchfn(lfutil.splitstandin(f)) or | |
|
636 | None) | |
|
637 | return m | |
|
638 | oldmatch = installmatchfn(overridematch) | |
|
639 | listpats = [] | |
|
614 | manifest = repo[None].manifest() | |
|
615 | def overridematch(ctx, pats=[], opts={}, globbed=False, | |
|
616 | default='relpath'): | |
|
617 | newpats = [] | |
|
618 | # The patterns were previously mangled to add the standin | |
|
619 | # directory; we need to remove that now | |
|
640 | 620 | for pat in pats: |
|
641 |
if match_.patkind(pat) is |
|
|
642 |
|
|
|
621 | if match_.patkind(pat) is None and lfutil.shortname in pat: | |
|
622 | newpats.append(pat.replace(lfutil.shortname, '')) | |
|
643 | 623 | else: |
|
644 |
|
|
|
624 | newpats.append(pat) | |
|
625 | match = oldmatch(ctx, newpats, opts, globbed, default) | |
|
626 | m = copy.copy(match) | |
|
627 | lfile = lambda f: lfutil.standin(f) in manifest | |
|
628 | m._files = [lfutil.standin(f) for f in m._files if lfile(f)] | |
|
629 | m._fmap = set(m._files) | |
|
630 | origmatchfn = m.matchfn | |
|
631 | m.matchfn = lambda f: (lfutil.isstandin(f) and | |
|
632 | (f in manifest) and | |
|
633 | origmatchfn(lfutil.splitstandin(f)) or | |
|
634 | None) | |
|
635 | return m | |
|
636 | oldmatch = installmatchfn(overridematch) | |
|
637 | listpats = [] | |
|
638 | for pat in pats: | |
|
639 | if match_.patkind(pat) is not None: | |
|
640 | listpats.append(pat) | |
|
641 | else: | |
|
642 | listpats.append(makestandin(pat)) | |
|
645 | 643 | |
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
|
650 | if (lfutil.shortname in src and | |
|
651 | dest.startswith(repo.wjoin(lfutil.shortname))): | |
|
652 | destlfile = dest.replace(lfutil.shortname, '') | |
|
653 | if not opts['force'] and os.path.exists(destlfile): | |
|
654 | raise IOError('', | |
|
655 | _('destination largefile already exists')) | |
|
656 | copiedfiles.append((src, dest)) | |
|
657 | origcopyfile(src, dest) | |
|
658 | ||
|
659 | util.copyfile = overridecopyfile | |
|
660 | result += orig(ui, repo, listpats, opts, rename) | |
|
661 | finally: | |
|
662 | util.copyfile = origcopyfile | |
|
663 | ||
|
664 | lfdirstate = lfutil.openlfdirstate(ui, repo) | |
|
665 | for (src, dest) in copiedfiles: | |
|
644 | try: | |
|
645 | origcopyfile = util.copyfile | |
|
646 | copiedfiles = [] | |
|
647 | def overridecopyfile(src, dest): | |
|
666 | 648 | if (lfutil.shortname in src and |
|
667 | 649 | dest.startswith(repo.wjoin(lfutil.shortname))): |
|
668 |
|
|
|
669 | destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') | |
|
670 | destlfiledir = os.path.dirname(repo.wjoin(destlfile)) or '.' | |
|
671 | if not os.path.isdir(destlfiledir): | |
|
672 | os.makedirs(destlfiledir) | |
|
673 | if rename: | |
|
674 | os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile)) | |
|
650 | destlfile = dest.replace(lfutil.shortname, '') | |
|
651 | if not opts['force'] and os.path.exists(destlfile): | |
|
652 | raise IOError('', | |
|
653 | _('destination largefile already exists')) | |
|
654 | copiedfiles.append((src, dest)) | |
|
655 | origcopyfile(src, dest) | |
|
656 | ||
|
657 | util.copyfile = overridecopyfile | |
|
658 | result += orig(ui, repo, listpats, opts, rename) | |
|
659 | finally: | |
|
660 | util.copyfile = origcopyfile | |
|
675 | 661 | |
|
676 | # The file is gone, but this deletes any empty parent | |
|
677 | # directories as a side-effect. | |
|
678 | util.unlinkpath(repo.wjoin(srclfile), True) | |
|
679 | lfdirstate.remove(srclfile) | |
|
680 | else: | |
|
681 | util.copyfile(repo.wjoin(srclfile), | |
|
682 | repo.wjoin(destlfile)) | |
|
662 | lfdirstate = lfutil.openlfdirstate(ui, repo) | |
|
663 | for (src, dest) in copiedfiles: | |
|
664 | if (lfutil.shortname in src and | |
|
665 | dest.startswith(repo.wjoin(lfutil.shortname))): | |
|
666 | srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') | |
|
667 | destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') | |
|
668 | destlfiledir = os.path.dirname(repo.wjoin(destlfile)) or '.' | |
|
669 | if not os.path.isdir(destlfiledir): | |
|
670 | os.makedirs(destlfiledir) | |
|
671 | if rename: | |
|
672 | os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile)) | |
|
683 | 673 | |
|
684 | lfdirstate.add(destlfile) | |
|
685 | lfdirstate.write() | |
|
686 | except util.Abort, e: | |
|
687 | if str(e) != _('no files to copy'): | |
|
688 |
|
|
|
689 | else: | |
|
690 | nolfiles = True | |
|
674 | # The file is gone, but this deletes any empty parent | |
|
675 | # directories as a side-effect. | |
|
676 | util.unlinkpath(repo.wjoin(srclfile), True) | |
|
677 | lfdirstate.remove(srclfile) | |
|
678 | else: | |
|
679 | util.copyfile(repo.wjoin(srclfile), | |
|
680 | repo.wjoin(destlfile)) | |
|
681 | ||
|
682 | lfdirstate.add(destlfile) | |
|
683 | lfdirstate.write() | |
|
684 | except util.Abort, e: | |
|
685 | if str(e) != _('no files to copy'): | |
|
686 | raise e | |
|
687 | else: | |
|
688 | nolfiles = True | |
|
691 | 689 | finally: |
|
692 | 690 | restorematchfn() |
|
693 | 691 | wlock.release() |
@@ -31,17 +31,16 b' def putlfile(repo, proto, sha):' | |||
|
31 | 31 | tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) |
|
32 | 32 | |
|
33 | 33 | try: |
|
34 | try: | |
|
35 | proto.getfile(tmpfp) | |
|
36 | tmpfp._fp.seek(0) | |
|
37 | if sha != lfutil.hexsha1(tmpfp._fp): | |
|
38 | raise IOError(0, _('largefile contents do not match hash')) | |
|
39 | tmpfp.close() | |
|
40 | lfutil.linktousercache(repo, sha) | |
|
41 | except IOError, e: | |
|
42 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % | |
|
43 | (sha, e.strerror)) | |
|
44 | return wireproto.pushres(1) | |
|
34 | proto.getfile(tmpfp) | |
|
35 | tmpfp._fp.seek(0) | |
|
36 | if sha != lfutil.hexsha1(tmpfp._fp): | |
|
37 | raise IOError(0, _('largefile contents do not match hash')) | |
|
38 | tmpfp.close() | |
|
39 | lfutil.linktousercache(repo, sha) | |
|
40 | except IOError, e: | |
|
41 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % | |
|
42 | (sha, e.strerror)) | |
|
43 | return wireproto.pushres(1) | |
|
45 | 44 | finally: |
|
46 | 45 | tmpfp.discard() |
|
47 | 46 |
@@ -36,13 +36,12 b' class remotestore(basestore.basestore):' | |||
|
36 | 36 | self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) |
|
37 | 37 | fd = None |
|
38 | 38 | try: |
|
39 | try: | |
|
40 | fd = lfutil.httpsendfile(self.ui, filename) | |
|
41 | except IOError, e: | |
|
42 | raise util.Abort( | |
|
43 | _('remotestore: could not open file %s: %s') | |
|
44 | % (filename, str(e))) | |
|
39 | fd = lfutil.httpsendfile(self.ui, filename) | |
|
45 | 40 | return self._put(hash, fd) |
|
41 | except IOError, e: | |
|
42 | raise util.Abort( | |
|
43 | _('remotestore: could not open file %s: %s') | |
|
44 | % (filename, str(e))) | |
|
46 | 45 | finally: |
|
47 | 46 | if fd: |
|
48 | 47 | fd.close() |
General Comments 0
You need to be logged in to leave comments.
Login now