Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 24675:47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 10 Apr 2015 00:36:42 +0900 |
parents | 93b0e0db7929 |
children | 897a0715ee71 |
comparison
equal
deleted
inserted
replaced
24674:93b0e0db7929 | 24675:47e7d5fbbf04 |
---|---|
507 unit=_('files'), total=total) | 507 unit=_('files'), total=total) |
508 for i, name in enumerate(files): | 508 for i, name in enumerate(files): |
509 flags = self.fileflags(name) | 509 flags = self.fileflags(name) |
510 mode = 'x' in flags and 0755 or 0644 | 510 mode = 'x' in flags and 0755 or 0644 |
511 symlink = 'l' in flags | 511 symlink = 'l' in flags |
512 archiver.addfile(os.path.join(prefix, self._path, name), | 512 archiver.addfile(self.wvfs.reljoin(prefix, self._path, name), |
513 mode, symlink, self.filedata(name)) | 513 mode, symlink, self.filedata(name)) |
514 self.ui.progress(_('archiving (%s)') % relpath, i + 1, | 514 self.ui.progress(_('archiving (%s)') % relpath, i + 1, |
515 unit=_('files'), total=total) | 515 unit=_('files'), total=total) |
516 self.ui.progress(_('archiving (%s)') % relpath, None) | 516 self.ui.progress(_('archiving (%s)') % relpath, None) |
517 return total | 517 return total |
665 fp.close() | 665 fp.close() |
666 | 666 |
667 @annotatesubrepoerror | 667 @annotatesubrepoerror |
668 def add(self, ui, match, prefix, explicitonly, **opts): | 668 def add(self, ui, match, prefix, explicitonly, **opts): |
669 return cmdutil.add(ui, self._repo, match, | 669 return cmdutil.add(ui, self._repo, match, |
670 os.path.join(prefix, self._path), explicitonly, | 670 self.wvfs.reljoin(prefix, self._path), |
671 **opts) | 671 explicitonly, **opts) |
672 | 672 |
673 @annotatesubrepoerror | 673 @annotatesubrepoerror |
674 def addremove(self, m, prefix, opts, dry_run, similarity): | 674 def addremove(self, m, prefix, opts, dry_run, similarity): |
675 # In the same way as sub directories are processed, once in a subrepo, | 675 # In the same way as sub directories are processed, once in a subrepo, |
676 # always entry any of its subrepos. Don't corrupt the options that will | 676 # always entry any of its subrepos. Don't corrupt the options that will |
677 # be used to process sibling subrepos however. | 677 # be used to process sibling subrepos however. |
678 opts = copy.copy(opts) | 678 opts = copy.copy(opts) |
679 opts['subrepos'] = True | 679 opts['subrepos'] = True |
680 return scmutil.addremove(self._repo, m, | 680 return scmutil.addremove(self._repo, m, |
681 os.path.join(prefix, self._path), opts, | 681 self.wvfs.reljoin(prefix, self._path), opts, |
682 dry_run, similarity) | 682 dry_run, similarity) |
683 | 683 |
684 @annotatesubrepoerror | 684 @annotatesubrepoerror |
685 def cat(self, match, prefix, **opts): | 685 def cat(self, match, prefix, **opts): |
686 rev = self._state[1] | 686 rev = self._state[1] |
723 ctx = self._repo[rev] | 723 ctx = self._repo[rev] |
724 for subpath in ctx.substate: | 724 for subpath in ctx.substate: |
725 s = subrepo(ctx, subpath) | 725 s = subrepo(ctx, subpath) |
726 submatch = matchmod.narrowmatcher(subpath, match) | 726 submatch = matchmod.narrowmatcher(subpath, match) |
727 total += s.archive( | 727 total += s.archive( |
728 archiver, os.path.join(prefix, self._path), submatch) | 728 archiver, self.wvfs.reljoin(prefix, self._path), submatch) |
729 return total | 729 return total |
730 | 730 |
731 @annotatesubrepoerror | 731 @annotatesubrepoerror |
732 def dirty(self, ignoreupdate=False): | 732 def dirty(self, ignoreupdate=False): |
733 r = self._state[1] | 733 r = self._state[1] |
907 return ctx.walk(match) | 907 return ctx.walk(match) |
908 | 908 |
909 @annotatesubrepoerror | 909 @annotatesubrepoerror |
910 def forget(self, match, prefix): | 910 def forget(self, match, prefix): |
911 return cmdutil.forget(self.ui, self._repo, match, | 911 return cmdutil.forget(self.ui, self._repo, match, |
912 os.path.join(prefix, self._path), True) | 912 self.wvfs.reljoin(prefix, self._path), True) |
913 | 913 |
914 @annotatesubrepoerror | 914 @annotatesubrepoerror |
915 def removefiles(self, matcher, prefix, after, force, subrepos): | 915 def removefiles(self, matcher, prefix, after, force, subrepos): |
916 return cmdutil.remove(self.ui, self._repo, matcher, | 916 return cmdutil.remove(self.ui, self._repo, matcher, |
917 os.path.join(prefix, self._path), after, force, | 917 self.wvfs.reljoin(prefix, self._path), |
918 subrepos) | 918 after, force, subrepos) |
919 | 919 |
920 @annotatesubrepoerror | 920 @annotatesubrepoerror |
921 def revert(self, substate, *pats, **opts): | 921 def revert(self, substate, *pats, **opts): |
922 # reverting a subrepo is a 2 step process: | 922 # reverting a subrepo is a 2 step process: |
923 # 1. if the no_backup is not set, revert all modified | 923 # 1. if the no_backup is not set, revert all modified |
979 # --non-interactive. | 979 # --non-interactive. |
980 if commands[0] in ('update', 'checkout', 'commit'): | 980 if commands[0] in ('update', 'checkout', 'commit'): |
981 cmd.append('--non-interactive') | 981 cmd.append('--non-interactive') |
982 cmd.extend(commands) | 982 cmd.extend(commands) |
983 if filename is not None: | 983 if filename is not None: |
984 path = os.path.join(self._ctx.repo().origroot, self._path, filename) | 984 path = self.wvfs.reljoin(self._ctx.repo().origroot, |
985 self._path, filename) | |
985 cmd.append(path) | 986 cmd.append(path) |
986 env = dict(os.environ) | 987 env = dict(os.environ) |
987 # Avoid localized output, preserve current locale for everything else. | 988 # Avoid localized output, preserve current locale for everything else. |
988 lc_all = env.get('LC_ALL') | 989 lc_all = env.get('LC_ALL') |
989 if lc_all: | 990 if lc_all: |
1661 continue | 1662 continue |
1662 if info.issym(): | 1663 if info.issym(): |
1663 data = info.linkname | 1664 data = info.linkname |
1664 else: | 1665 else: |
1665 data = tar.extractfile(info).read() | 1666 data = tar.extractfile(info).read() |
1666 archiver.addfile(os.path.join(prefix, self._path, info.name), | 1667 archiver.addfile(self.wvfs.reljoin(prefix, self._path, info.name), |
1667 info.mode, info.issym(), data) | 1668 info.mode, info.issym(), data) |
1668 total += 1 | 1669 total += 1 |
1669 self.ui.progress(_('archiving (%s)') % relpath, i + 1, | 1670 self.ui.progress(_('archiving (%s)') % relpath, i + 1, |
1670 unit=_('files')) | 1671 unit=_('files')) |
1671 self.ui.progress(_('archiving (%s)') % relpath, None) | 1672 self.ui.progress(_('archiving (%s)') % relpath, None) |
1683 | 1684 |
1684 for f in match.files(): | 1685 for f in match.files(): |
1685 output = self._gitcommand(["show", "%s:%s" % (rev, f)]) | 1686 output = self._gitcommand(["show", "%s:%s" % (rev, f)]) |
1686 fp = cmdutil.makefileobj(self._subparent, opts.get('output'), | 1687 fp = cmdutil.makefileobj(self._subparent, opts.get('output'), |
1687 self._ctx.node(), | 1688 self._ctx.node(), |
1688 pathname=os.path.join(prefix, f)) | 1689 pathname=self.wvfs.reljoin(prefix, f)) |
1689 fp.write(output) | 1690 fp.write(output) |
1690 fp.close() | 1691 fp.close() |
1691 return 0 | 1692 return 0 |
1692 | 1693 |
1693 | 1694 |
1766 cmd.append('--stat') | 1767 cmd.append('--stat') |
1767 else: | 1768 else: |
1768 # for Git, this also implies '-p' | 1769 # for Git, this also implies '-p' |
1769 cmd.append('-U%d' % diffopts.context) | 1770 cmd.append('-U%d' % diffopts.context) |
1770 | 1771 |
1771 gitprefix = os.path.join(prefix, self._path) | 1772 gitprefix = self.wvfs.reljoin(prefix, self._path) |
1772 | 1773 |
1773 if diffopts.noprefix: | 1774 if diffopts.noprefix: |
1774 cmd.extend(['--src-prefix=%s/' % gitprefix, | 1775 cmd.extend(['--src-prefix=%s/' % gitprefix, |
1775 '--dst-prefix=%s/' % gitprefix]) | 1776 '--dst-prefix=%s/' % gitprefix]) |
1776 else: | 1777 else: |