Mercurial > hg
comparison hgext/largefiles/overrides.py @ 41579:028bb170e74d
largefiles: use wrappedfunction() for util.copyfile() override
Differential Revision: https://phab.mercurial-scm.org/D5866
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 05 Feb 2019 14:29:37 -0800 |
parents | 8d1dc380b026 |
children | 9f11759fc5f5 |
comparison
equal
deleted
inserted
replaced
41578:8d1dc380b026 | 41579:028bb170e74d |
---|---|
684 if matchmod.patkind(pat) is not None: | 684 if matchmod.patkind(pat) is not None: |
685 listpats.append(pat) | 685 listpats.append(pat) |
686 else: | 686 else: |
687 listpats.append(makestandin(pat)) | 687 listpats.append(makestandin(pat)) |
688 | 688 |
689 try: | 689 copiedfiles = [] |
690 origcopyfile = util.copyfile | 690 def overridecopyfile(orig, src, dest, *args, **kwargs): |
691 copiedfiles = [] | 691 if (lfutil.shortname in src and |
692 def overridecopyfile(src, dest, *args, **kwargs): | 692 dest.startswith(repo.wjoin(lfutil.shortname))): |
693 if (lfutil.shortname in src and | 693 destlfile = dest.replace(lfutil.shortname, '') |
694 dest.startswith(repo.wjoin(lfutil.shortname))): | 694 if not opts['force'] and os.path.exists(destlfile): |
695 destlfile = dest.replace(lfutil.shortname, '') | 695 raise IOError('', |
696 if not opts['force'] and os.path.exists(destlfile): | 696 _('destination largefile already exists')) |
697 raise IOError('', | 697 copiedfiles.append((src, dest)) |
698 _('destination largefile already exists')) | 698 orig(src, dest, *args, **kwargs) |
699 copiedfiles.append((src, dest)) | 699 with extensions.wrappedfunction(util, 'copyfile', overridecopyfile): |
700 origcopyfile(src, dest, *args, **kwargs) | |
701 | |
702 util.copyfile = overridecopyfile | |
703 result += orig(ui, repo, listpats, opts, rename) | 700 result += orig(ui, repo, listpats, opts, rename) |
704 finally: | |
705 util.copyfile = origcopyfile | |
706 | 701 |
707 lfdirstate = lfutil.openlfdirstate(ui, repo) | 702 lfdirstate = lfutil.openlfdirstate(ui, repo) |
708 for (src, dest) in copiedfiles: | 703 for (src, dest) in copiedfiles: |
709 if (lfutil.shortname in src and | 704 if (lfutil.shortname in src and |
710 dest.startswith(repo.wjoin(lfutil.shortname))): | 705 dest.startswith(repo.wjoin(lfutil.shortname))): |