Specifying repository root with cat

Martin Geisler mg at aragost.com
Mon Jan 31 07:26:58 CST 2011


Johan Holmberg <johan556 at gmail.com> writes:

> On Thu, Jan 27, 2011 at 12:10 PM, Martin Geisler <mg at aragost.com> wrote:
>
>> You have to use
>>
>>  hg -R rootdir cat -r -1 rootdir/file
>>
>
> Doesn't the following work just as well?
>
>     hg cat -r -1 rootdir/file
>
> And the case with the "log" command could be written without the -R
> option too:
>
>     hg log rootdir
>
> I don't know if this works in all situations, but my feeling is that
> most hg commands works this way. As long as the correct file/directory
> is pointed out relative to the current working directory (or given as
> an absolute path).

This only works when you are not already inside another repository. In
that case we infer the right repository from the filenames. This is done
by literally calling the dispatch function again with a --repository
flag:

  http://selenic.com/hg/file/tip/mercurial/dispatch.py#l573

One condition that you can read out of the code is that all files must
be inside the same repository, so

  hg log repo-a/x repo-b/y

is forbidden, of course.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/en/services/mercurial/blog/


More information about the Mercurial mailing list