[PATCH 7 of 9 paths v2] ui: parse revisions out of URLs
Augie Fackler
raf at durin42.com
Tue Mar 3 13:45:01 CST 2015
On Sun, Mar 01, 2015 at 01:50:46PM -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1423518263 28800
> # Mon Feb 09 13:44:23 2015 -0800
> # Node ID a18ef66b7b91f6ab396683330e849bc8009c7ad8
> # Parent b8d39c692feb69e2560a49abb1b9dcc984b3e1c8
> ui: parse revisions out of URLs
>
> URLs can be of the form "url#revision." Currently, this additional
> parsing is done at call sites in addition to ui.expandpath(). We
> build this functionality into the "path" class to make consumer code
> simpler.
>
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -979,9 +979,13 @@ class paths(object):
> if name:
> if util.hasscheme(name):
> return path(None, url=name)
>
> - if os.path.isdir(os.path.join(name, '.hg')):
> + # Strip #revision fragment before testing against filesystem
> + # paths.
> + url = util.url(name)
> + url.fragment = None
> + if os.path.isdir(os.path.join(str(url), '.hg')):
> return path(name, local=name)
>
> try:
> return self[name]
> @@ -1017,8 +1021,16 @@ class path(object):
>
> The primary URL for the path is defined as either a URL via ``url``
> (preferred) or from a local, relative filesystem path (``local``).
> """
> + import hg # avoid cycle
> +
> + url = url or local
> self.name = name
> - # We will eventually do intelligent things depending on the
> - # source type. Until then, store a single variable for simplicity.
> - self.loc = url or local
> +
> + # loc can disappear once all consumers are gone.
> + self.loc = url
> +
> + url, revs = hg.parseurl(url)
>
Ideally, parseurl() should be able to move someplace else to avoid the cycle...
> +
> + self.url = url
> + self.rev = revs[0]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list