Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG028bb170e74d: largefiles: use wrappedfunction() for util.copyfile() override
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/largefiles/overrides.py (27 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 5 2019, 5:29 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
oldmatch = installmatchfn(overridematch) | oldmatch = installmatchfn(overridematch) | ||||
listpats = [] | listpats = [] | ||||
for pat in pats: | for pat in pats: | ||||
if matchmod.patkind(pat) is not None: | if matchmod.patkind(pat) is not None: | ||||
listpats.append(pat) | listpats.append(pat) | ||||
else: | else: | ||||
listpats.append(makestandin(pat)) | listpats.append(makestandin(pat)) | ||||
try: | |||||
origcopyfile = util.copyfile | |||||
copiedfiles = [] | copiedfiles = [] | ||||
def overridecopyfile(src, dest, *args, **kwargs): | def overridecopyfile(orig, src, dest, *args, **kwargs): | ||||
if (lfutil.shortname in src and | if (lfutil.shortname in src and | ||||
dest.startswith(repo.wjoin(lfutil.shortname))): | dest.startswith(repo.wjoin(lfutil.shortname))): | ||||
destlfile = dest.replace(lfutil.shortname, '') | destlfile = dest.replace(lfutil.shortname, '') | ||||
if not opts['force'] and os.path.exists(destlfile): | if not opts['force'] and os.path.exists(destlfile): | ||||
raise IOError('', | raise IOError('', | ||||
_('destination largefile already exists')) | _('destination largefile already exists')) | ||||
copiedfiles.append((src, dest)) | copiedfiles.append((src, dest)) | ||||
origcopyfile(src, dest, *args, **kwargs) | orig(src, dest, *args, **kwargs) | ||||
with extensions.wrappedfunction(util, 'copyfile', overridecopyfile): | |||||
util.copyfile = overridecopyfile | |||||
result += orig(ui, repo, listpats, opts, rename) | result += orig(ui, repo, listpats, opts, rename) | ||||
finally: | |||||
util.copyfile = origcopyfile | |||||
lfdirstate = lfutil.openlfdirstate(ui, repo) | lfdirstate = lfutil.openlfdirstate(ui, repo) | ||||
for (src, dest) in copiedfiles: | for (src, dest) in copiedfiles: | ||||
if (lfutil.shortname in src and | if (lfutil.shortname in src and | ||||
dest.startswith(repo.wjoin(lfutil.shortname))): | dest.startswith(repo.wjoin(lfutil.shortname))): | ||||
srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') | srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') | ||||
destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') | destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') | ||||
destlfiledir = repo.wvfs.dirname(repo.wjoin(destlfile)) or '.' | destlfiledir = repo.wvfs.dirname(repo.wjoin(destlfile)) or '.' |