Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 21041:a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
The cat command with an explicit path into a subrepo is now handled by invoking
cat on the file, from that subrepo. The previous behavior was to complain that
the file didn't exist in the revision (of the top most repo). Now when the file
is actually missing, the revision of the subrepo is named instead (though it is
probably desirable to continue naming the top level repo).
The documented output formatters %d and %p reflect the path from the top level
repo, since the purpose of this is to give the illusion of a unified repository.
Support for the undocumented (for cat) formatters %H, %R, %h, %m and %r was
added long ago (I tested back as far as 0.5), but unfortunately these will
reflect the subrepo node instead of the parent context.
The previous implementation was a bit loose with the return value, i.e. it would
return 0 if _any_ file requested was cat'd successfully. This maintains that
behavior.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 14 Mar 2014 21:32:05 -0400 |
parents | 70312c95f2f7 |
children | 78a60daacea8 2e91d4964ecd |
line wrap: on
line diff
--- a/mercurial/subrepo.py Thu Mar 13 23:45:18 2014 -0400 +++ b/mercurial/subrepo.py Fri Mar 14 21:32:05 2014 -0400 @@ -439,6 +439,9 @@ def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly): return [] + def cat(self, ui, match, prefix, **opts): + return 1 + def status(self, rev2, **opts): return [], [], [], [], [], [], [] @@ -609,6 +612,12 @@ os.path.join(prefix, self._path), explicitonly) @annotatesubrepoerror + def cat(self, ui, match, prefix, **opts): + rev = self._state[1] + ctx = self._repo[rev] + return cmdutil.cat(ui, self._repo, ctx, match, prefix, **opts) + + @annotatesubrepoerror def status(self, rev2, **opts): try: rev1 = self._state[1]