Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG3d9d5e612e67: subrepo: adjust subrepo prefix before calling subrepo.archive() (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/largefiles/overrides.py (8 lines) | |||
| M | mercurial/archival.py (3 lines) | |||
| M | mercurial/subrepo.py (10 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Feb 7 2019, 1:20 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| getdata = lambda: util.readfile(path) | getdata = lambda: util.readfile(path) | ||||
| write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | ||||
| if subrepos: | if subrepos: | ||||
| for subpath in sorted(ctx.substate): | for subpath in sorted(ctx.substate): | ||||
| sub = ctx.workingsub(subpath) | sub = ctx.workingsub(subpath) | ||||
| submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
| subprefix = prefix + subpath + '/' | |||||
| sub._repo.lfstatus = True | sub._repo.lfstatus = True | ||||
| sub.archive(archiver, prefix, submatch) | sub.archive(archiver, subprefix, submatch) | ||||
| archiver.done() | archiver.done() | ||||
| @eh.wrapfunction(subrepo.hgsubrepo, 'archive') | @eh.wrapfunction(subrepo.hgsubrepo, 'archive') | ||||
| def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True): | def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True): | ||||
| lfenabled = util.safehasattr(repo._repo, '_largefilesenabled') | lfenabled = util.safehasattr(repo._repo, '_largefilesenabled') | ||||
| if not lfenabled or not repo._repo.lfstatus: | if not lfenabled or not repo._repo.lfstatus: | ||||
| return orig(repo, archiver, prefix, match, decode) | return orig(repo, archiver, prefix, match, decode) | ||||
| # At this point, the standin has been replaced with the largefile name, | # At this point, the standin has been replaced with the largefile name, | ||||
| # so the normal matcher works here without the lfutil variants. | # so the normal matcher works here without the lfutil variants. | ||||
| if match and not match(f): | if match and not match(f): | ||||
| return | return | ||||
| data = getdata() | data = getdata() | ||||
| if decode: | if decode: | ||||
| data = repo._repo.wwritedata(name, data) | data = repo._repo.wwritedata(name, data) | ||||
| archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data) | archiver.addfile(prefix + name, mode, islink, data) | ||||
| for f in ctx: | for f in ctx: | ||||
| ff = ctx.flags(f) | ff = ctx.flags(f) | ||||
| getdata = ctx[f].data | getdata = ctx[f].data | ||||
| lfile = lfutil.splitstandin(f) | lfile = lfutil.splitstandin(f) | ||||
| if lfile is not None: | if lfile is not None: | ||||
| if ctx.node() is not None: | if ctx.node() is not None: | ||||
| path = lfutil.findfile(repo._repo, getdata().strip()) | path = lfutil.findfile(repo._repo, getdata().strip()) | ||||
| getdata = lambda: util.readfile(os.path.join(prefix, path)) | getdata = lambda: util.readfile(os.path.join(prefix, path)) | ||||
| write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | ||||
| for subpath in sorted(ctx.substate): | for subpath in sorted(ctx.substate): | ||||
| sub = ctx.workingsub(subpath) | sub = ctx.workingsub(subpath) | ||||
| submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
| subprefix = prefix + subpath + '/' | |||||
| sub._repo.lfstatus = True | sub._repo.lfstatus = True | ||||
| sub.archive(archiver, prefix + repo._path + '/', submatch, decode) | sub.archive(archiver, subprefix, submatch, decode) | ||||
| # If a largefile is modified, the change is not reflected in its | # If a largefile is modified, the change is not reflected in its | ||||
| # standin until a commit. cmdutil.bailifchanged() raises an exception | # standin until a commit. cmdutil.bailifchanged() raises an exception | ||||
| # if the repo has uncommitted changes. Wrap it to also check if | # if the repo has uncommitted changes. Wrap it to also check if | ||||
| # largefiles were changed. This is used by bisect, backout and fetch. | # largefiles were changed. This is used by bisect, backout and fetch. | ||||
| @eh.wrapfunction(cmdutil, 'bailifchanged') | @eh.wrapfunction(cmdutil, 'bailifchanged') | ||||
| def overridebailifchanged(orig, repo, *args, **kwargs): | def overridebailifchanged(orig, repo, *args, **kwargs): | ||||
| orig(repo, *args, **kwargs) | orig(repo, *args, **kwargs) | ||||
| write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, ctx[f].data) | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, ctx[f].data) | ||||
| progress.increment(item=f) | progress.increment(item=f) | ||||
| progress.complete() | progress.complete() | ||||
| if subrepos: | if subrepos: | ||||
| for subpath in sorted(ctx.substate): | for subpath in sorted(ctx.substate): | ||||
| sub = ctx.workingsub(subpath) | sub = ctx.workingsub(subpath) | ||||
| submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
| total += sub.archive(archiver, prefix, submatch, decode) | subprefix = prefix + subpath + '/' | ||||
| total += sub.archive(archiver, subprefix, submatch, decode) | |||||
| if total == 0: | if total == 0: | ||||
| raise error.Abort(_('no files match the archive pattern')) | raise error.Abort(_('no files match the archive pattern')) | ||||
| archiver.done() | archiver.done() | ||||
| return total | return total | ||||
| relpath = subrelpath(self) | relpath = subrelpath(self) | ||||
| progress = self.ui.makeprogress(_('archiving (%s)') % relpath, | progress = self.ui.makeprogress(_('archiving (%s)') % relpath, | ||||
| unit=_('files'), total=total) | unit=_('files'), total=total) | ||||
| progress.update(0) | progress.update(0) | ||||
| for name in files: | for name in files: | ||||
| flags = self.fileflags(name) | flags = self.fileflags(name) | ||||
| mode = 'x' in flags and 0o755 or 0o644 | mode = 'x' in flags and 0o755 or 0o644 | ||||
| symlink = 'l' in flags | symlink = 'l' in flags | ||||
| archiver.addfile(prefix + self._path + '/' + name, | archiver.addfile(prefix + name, mode, symlink, | ||||
| mode, symlink, self.filedata(name, decode)) | self.filedata(name, decode)) | ||||
| progress.increment() | progress.increment() | ||||
| progress.complete() | progress.complete() | ||||
| return total | return total | ||||
| def walk(self, match): | def walk(self, match): | ||||
| ''' | ''' | ||||
| walk recursively through the directory tree, finding all files | walk recursively through the directory tree, finding all files | ||||
| matched by the match function | matched by the match function | ||||
| rev = self._state[1] | rev = self._state[1] | ||||
| ctx = self._repo[rev] | ctx = self._repo[rev] | ||||
| scmutil.prefetchfiles(self._repo, [ctx.rev()], | scmutil.prefetchfiles(self._repo, [ctx.rev()], | ||||
| scmutil.matchfiles(self._repo, files)) | scmutil.matchfiles(self._repo, files)) | ||||
| total = abstractsubrepo.archive(self, archiver, prefix, match) | total = abstractsubrepo.archive(self, archiver, prefix, match) | ||||
| for subpath in ctx.substate: | for subpath in ctx.substate: | ||||
| s = subrepo(ctx, subpath, True) | s = subrepo(ctx, subpath, True) | ||||
| submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
| total += s.archive(archiver, prefix + self._path + '/', submatch, | subprefix = prefix + subpath + '/' | ||||
| total += s.archive(archiver, subprefix, submatch, | |||||
| decode) | decode) | ||||
| return total | return total | ||||
| @annotatesubrepoerror | @annotatesubrepoerror | ||||
| def dirty(self, ignoreupdate=False, missing=False): | def dirty(self, ignoreupdate=False, missing=False): | ||||
| r = self._state[1] | r = self._state[1] | ||||
| if r == '' and not ignoreupdate: # no state recorded | if r == '' and not ignoreupdate: # no state recorded | ||||
| return True | return True | ||||
| continue | continue | ||||
| bname = pycompat.fsencode(info.name) | bname = pycompat.fsencode(info.name) | ||||
| if match and not match(bname): | if match and not match(bname): | ||||
| continue | continue | ||||
| if info.issym(): | if info.issym(): | ||||
| data = info.linkname | data = info.linkname | ||||
| else: | else: | ||||
| data = tar.extractfile(info).read() | data = tar.extractfile(info).read() | ||||
| archiver.addfile(prefix + self._path + '/' + bname, | archiver.addfile(prefix + bname, info.mode, info.issym(), data) | ||||
| info.mode, info.issym(), data) | |||||
| total += 1 | total += 1 | ||||
| progress.increment() | progress.increment() | ||||
| progress.complete() | progress.complete() | ||||
| return total | return total | ||||
| @annotatesubrepoerror | @annotatesubrepoerror | ||||
| def cat(self, match, fm, fntemplate, prefix, **opts): | def cat(self, match, fm, fntemplate, prefix, **opts): | ||||