Submitter | Gregory Szorc |
---|---|
Date | March 1, 2015, 9:50 p.m. |
Message ID | <a18ef66b7b91f6ab3966.1425246646@vm-ubuntu-main.gateway.sonic.net> |
Download | mbox | patch |
Permalink | /patch/7868/ |
State | Changes Requested |
Headers | show |
Comments
On Sun, Mar 01, 2015 at 01:50:46PM -0800, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@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@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
On Tue, 2015-03-03 at 14:45 -0500, Augie Fackler wrote: > On Sun, Mar 01, 2015 at 01:50:46PM -0800, Gregory Szorc wrote: > > # HG changeset patch > > # User Gregory Szorc <gregory.szorc@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... Without the branches arg, it's trivial enough to just inline, no?
Patch
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) + + self.url = url + self.rev = revs[0]