[PATCH STABLE] subrepo: handle 'C:' style paths on the command line (issue5770)

Yuya Nishihara yuya at tcha.org
Mon Jan 22 07:38:39 EST 2018


On Sun, 21 Jan 2018 15:50:33 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1516560845 18000
> #      Sun Jan 21 13:54:05 2018 -0500
> # Node ID a79c2c7aeffeee2f4681f5410864ef688e688b36
> # Parent  1dd5724664ab53e0cf2a69809bb3f4158d4e30d7
> subrepo: handle 'C:' style paths on the command line (issue5770)

Queued, many thanks.

> Rather than fixing every command call site, just convert it in the common
> subrepo location.  I don't see any sanitizing on the path config options, so I
> fixed those too.  Note that while the behavior is fixed here, there are still
> places where 'comparing with C:' gets printed out, and that's not great for
> debugging purposes.  (Specifically I saw it in `hg incoming -B C:`, without
> subrepos.)  While clone will write out an absolute default path, I wonder what
> would happen if a user edited that path to be 'C:'.  (I don't think supporting
> relative paths in .hgrc is a sane thing to do, but while we're poking holes in
> things...)
> 
> Since this is such an oddball case, it still leaks through in places, and there
> seems to be a lot of duplicate url parsing, maybe the url parsing should be
> moved to dispatch, and provide the command with a url object?  Then we could
> convert this to an absolute path once, and not have to worry about it in the
> rest of the code.

It wouldn't be easy to determine which argument is a URL at dispatcher level.
Perhaps we can instead add a utility function. FYI, there's another weird bug
you might be interested. :)

  $ mkdir '$foo'
  $ cd '$foo'
  $ hg init
  $ foo=bar hg root
  abort: repository $TESTTMP/$foo not found!

https://bz.mercurial-scm.org/show_bug.cgi?id=5739

> +        path = None
>          if util.safehasattr(repo, '_subtoppath'):
> -            return repo._subtoppath
> -        if push and repo.ui.config('paths', 'default-push'):
> -            return repo.ui.config('paths', 'default-push')
> -        if repo.ui.config('paths', 'default'):
> -            return repo.ui.config('paths', 'default')

I don't fully understand the _subtopath magic, but maybe we could resolve
the peer subrepo URLs recursively from the peerrepo.url(), not from the
localrepo attribute.


More information about the Mercurial-devel mailing list