[PATCH 3 of 3] mq: remove leading slash from url when qimporting
Brodie Rao
brodie at bitheap.org
Sat Apr 30 03:07:09 CDT 2011
On Apr 29, 2011, at 9:32 PM, Idan Kamara wrote:
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1304105557 -10800
> # Node ID 2e06c5551499416955dc1e77b6bfb76f144875d6
> # Parent 72f1f40451cb4ec16a268f233c0ceaee98f61de7
> mq: remove leading slash from url when qimporting
>
> When trying to qimport a url that ends with a slash
> os.path.basename would return an empty string. So
> when seeing a leading slash, remove it and infer the
> patch name from the remaining url.
>
> e.g. `hg qimport http://paste.pocoo.org/raw/xxx/`
> deduced '.' to be the patch name. Now we'll deduce 'xxx'.
>
> We could probably remove all leading slashes but this
> is the more common case.
Some questions:
- What if I run "hg qimport http://paste.pocoo.org/raw/xxx//"?
- Why aren't we using the url class to handle parsing here?
- What about a test?
> diff -r 72f1f40451cb -r 2e06c5551499 hgext/mq.py
> --- a/hgext/mq.py Fri Apr 29 22:21:13 2011 +0300
> +++ b/hgext/mq.py Fri Apr 29 22:32:37 2011 +0300
> @@ -1821,6 +1821,8 @@
> except (OSError, IOError):
> raise util.Abort(_("unable to read file %s") %
> filename)
> if not patchname:
> + if filename.endswith('/'):
> + filename = filename[:-1]
> patchname = normname(os.path.basename(filename))
> self.check_reserved_name(patchname)
> checkfile(patchname)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list