Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 32610:746e12a767b3
cat: add formatter support
This is an example showing how formatter can handle the --output option.
git subrepo isn't supported for now.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 25 May 2017 21:53:44 +0900 |
parents | f4cd4c49e302 |
children | bf2daeddd42b |
comparison
equal
deleted
inserted
replaced
32609:7bfa1b199972 | 32610:746e12a767b3 |
---|---|
536 | 536 |
537 def addremove(self, matcher, prefix, opts, dry_run, similarity): | 537 def addremove(self, matcher, prefix, opts, dry_run, similarity): |
538 self.ui.warn("%s: %s" % (prefix, _("addremove is not supported"))) | 538 self.ui.warn("%s: %s" % (prefix, _("addremove is not supported"))) |
539 return 1 | 539 return 1 |
540 | 540 |
541 def cat(self, match, fntemplate, prefix, **opts): | 541 def cat(self, match, fm, fntemplate, prefix, **opts): |
542 return 1 | 542 return 1 |
543 | 543 |
544 def status(self, rev2, **opts): | 544 def status(self, rev2, **opts): |
545 return scmutil.status([], [], [], [], [], [], []) | 545 return scmutil.status([], [], [], [], [], [], []) |
546 | 546 |
765 return scmutil.addremove(self._repo, m, | 765 return scmutil.addremove(self._repo, m, |
766 self.wvfs.reljoin(prefix, self._path), opts, | 766 self.wvfs.reljoin(prefix, self._path), opts, |
767 dry_run, similarity) | 767 dry_run, similarity) |
768 | 768 |
769 @annotatesubrepoerror | 769 @annotatesubrepoerror |
770 def cat(self, match, fntemplate, prefix, **opts): | 770 def cat(self, match, fm, fntemplate, prefix, **opts): |
771 rev = self._state[1] | 771 rev = self._state[1] |
772 ctx = self._repo[rev] | 772 ctx = self._repo[rev] |
773 return cmdutil.cat(self.ui, self._repo, ctx, match, fntemplate, prefix, | 773 return cmdutil.cat(self.ui, self._repo, ctx, match, fm, fntemplate, |
774 **opts) | 774 prefix, **opts) |
775 | 775 |
776 @annotatesubrepoerror | 776 @annotatesubrepoerror |
777 def status(self, rev2, **opts): | 777 def status(self, rev2, **opts): |
778 try: | 778 try: |
779 rev1 = self._state[1] | 779 rev1 = self._state[1] |
1831 self.ui.progress(_('archiving (%s)') % relpath, None) | 1831 self.ui.progress(_('archiving (%s)') % relpath, None) |
1832 return total | 1832 return total |
1833 | 1833 |
1834 | 1834 |
1835 @annotatesubrepoerror | 1835 @annotatesubrepoerror |
1836 def cat(self, match, fntemplate, prefix, **opts): | 1836 def cat(self, match, fm, fntemplate, prefix, **opts): |
1837 rev = self._state[1] | 1837 rev = self._state[1] |
1838 if match.anypats(): | 1838 if match.anypats(): |
1839 return 1 #No support for include/exclude yet | 1839 return 1 #No support for include/exclude yet |
1840 | 1840 |
1841 if not match.files(): | 1841 if not match.files(): |
1842 return 1 | 1842 return 1 |
1843 | 1843 |
1844 # TODO: add support for non-plain formatter (see cmdutil.cat()) | |
1844 for f in match.files(): | 1845 for f in match.files(): |
1845 output = self._gitcommand(["show", "%s:%s" % (rev, f)]) | 1846 output = self._gitcommand(["show", "%s:%s" % (rev, f)]) |
1846 fp = cmdutil.makefileobj(self._subparent, fntemplate, | 1847 fp = cmdutil.makefileobj(self._subparent, fntemplate, |
1847 self._ctx.node(), | 1848 self._ctx.node(), |
1848 pathname=self.wvfs.reljoin(prefix, f)) | 1849 pathname=self.wvfs.reljoin(prefix, f)) |