##// END OF EJS Templates
cat: support cat with explicit paths in subrepos...
Matt Harbison -
r21041:a2cc3c08 default
parent child Browse files
Show More
@@ -1812,11 +1812,12 b' def forget(ui, repo, match, prefix, expl'
1812 forgot.extend(forget)
1812 forgot.extend(forget)
1813 return bad, forgot
1813 return bad, forgot
1814
1814
1815 def cat(ui, repo, ctx, matcher, **opts):
1815 def cat(ui, repo, ctx, matcher, prefix, **opts):
1816 err = 1
1816 err = 1
1817
1817
1818 def write(path):
1818 def write(path):
1819 fp = makefileobj(repo, opts.get('output'), ctx.node(), pathname=path)
1819 fp = makefileobj(repo, opts.get('output'), ctx.node(),
1820 pathname=os.path.join(prefix, path))
1820 data = ctx[path].data()
1821 data = ctx[path].data()
1821 if opts.get('decode'):
1822 if opts.get('decode'):
1822 data = repo.wwritedata(path, data)
1823 data = repo.wwritedata(path, data)
@@ -1833,9 +1834,35 b' def cat(ui, repo, ctx, matcher, **opts):'
1833 write(file)
1834 write(file)
1834 return 0
1835 return 0
1835
1836
1837 # Don't warn about "missing" files that are really in subrepos
1838 bad = matcher.bad
1839
1840 def badfn(path, msg):
1841 for subpath in ctx.substate:
1842 if path.startswith(subpath):
1843 return
1844 bad(path, msg)
1845
1846 matcher.bad = badfn
1847
1836 for abs in ctx.walk(matcher):
1848 for abs in ctx.walk(matcher):
1837 write(abs)
1849 write(abs)
1838 err = 0
1850 err = 0
1851
1852 matcher.bad = bad
1853
1854 for subpath in sorted(ctx.substate):
1855 sub = ctx.sub(subpath)
1856 try:
1857 submatch = matchmod.narrowmatcher(subpath, matcher)
1858
1859 if not sub.cat(ui, submatch, os.path.join(prefix, sub._path),
1860 **opts):
1861 err = 0
1862 except error.RepoLookupError:
1863 ui.status(_("skipping missing subrepository: %s\n")
1864 % os.path.join(prefix, subpath))
1865
1839 return err
1866 return err
1840
1867
1841 def duplicatecopies(repo, rev, fromrev):
1868 def duplicatecopies(repo, rev, fromrev):
@@ -1174,7 +1174,7 b' def cat(ui, repo, file1, *pats, **opts):'
1174 ctx = scmutil.revsingle(repo, opts.get('rev'))
1174 ctx = scmutil.revsingle(repo, opts.get('rev'))
1175 m = scmutil.match(ctx, (file1,) + pats, opts)
1175 m = scmutil.match(ctx, (file1,) + pats, opts)
1176
1176
1177 return cmdutil.cat(ui, repo, ctx, m, **opts)
1177 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1178
1178
1179 @command('^clone',
1179 @command('^clone',
1180 [('U', 'noupdate', None,
1180 [('U', 'noupdate', None,
@@ -84,6 +84,9 b' Interaction with Mercurial Commands'
84 :archive: archive does not recurse in subrepositories unless
84 :archive: archive does not recurse in subrepositories unless
85 -S/--subrepos is specified.
85 -S/--subrepos is specified.
86
86
87 :cat: cat currently only handles exact file matches in subrepos.
88 Git and Subversion subrepositories are currently ignored.
89
87 :commit: commit creates a consistent snapshot of the state of the
90 :commit: commit creates a consistent snapshot of the state of the
88 entire project and its subrepositories. If any subrepositories
91 entire project and its subrepositories. If any subrepositories
89 have been modified, Mercurial will abort. Mercurial can be made
92 have been modified, Mercurial will abort. Mercurial can be made
@@ -439,6 +439,9 b' class abstractsubrepo(object):'
439 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly):
439 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly):
440 return []
440 return []
441
441
442 def cat(self, ui, match, prefix, **opts):
443 return 1
444
442 def status(self, rev2, **opts):
445 def status(self, rev2, **opts):
443 return [], [], [], [], [], [], []
446 return [], [], [], [], [], [], []
444
447
@@ -609,6 +612,12 b' class hgsubrepo(abstractsubrepo):'
609 os.path.join(prefix, self._path), explicitonly)
612 os.path.join(prefix, self._path), explicitonly)
610
613
611 @annotatesubrepoerror
614 @annotatesubrepoerror
615 def cat(self, ui, match, prefix, **opts):
616 rev = self._state[1]
617 ctx = self._repo[rev]
618 return cmdutil.cat(ui, self._repo, ctx, match, prefix, **opts)
619
620 @annotatesubrepoerror
612 def status(self, rev2, **opts):
621 def status(self, rev2, **opts):
613 try:
622 try:
614 rev1 = self._state[1]
623 rev1 = self._state[1]
@@ -792,6 +792,19 b' Prepare a repo with subrepo'
792 $ echo test >> sub/repo/foo
792 $ echo test >> sub/repo/foo
793 $ hg ci -mtest
793 $ hg ci -mtest
794 committing subrepository sub/repo (glob)
794 committing subrepository sub/repo (glob)
795 $ hg cat sub/repo/foo
796 test
797 test
798 $ mkdir -p tmp/sub/repo
799 $ hg cat -r 0 --output tmp/%p_p sub/repo/foo
800 $ cat tmp/sub/repo/foo_p
801 test
802 $ mv sub/repo sub_
803 $ hg cat sub/repo/baz
804 skipping missing subrepository: sub/repo
805 [1]
806 $ rm -rf sub/repo
807 $ mv sub_ sub/repo
795 $ cd ..
808 $ cd ..
796
809
797 Create repo without default path, pull top repo, and see what happens on update
810 Create repo without default path, pull top repo, and see what happens on update
General Comments 0
You need to be logged in to leave comments. Login now