Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
21040:bdf5ed5246d2 | 21041:a2cc3c08c3ac |
---|---|
437 raise NotImplementedError | 437 raise NotImplementedError |
438 | 438 |
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 |
445 def diff(self, ui, diffopts, node2, match, prefix, **opts): | 448 def diff(self, ui, diffopts, node2, match, prefix, **opts): |
446 pass | 449 pass |
605 | 608 |
606 @annotatesubrepoerror | 609 @annotatesubrepoerror |
607 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly): | 610 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly): |
608 return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos, | 611 return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos, |
609 os.path.join(prefix, self._path), explicitonly) | 612 os.path.join(prefix, self._path), explicitonly) |
613 | |
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) | |
610 | 619 |
611 @annotatesubrepoerror | 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] |