[PATCH 3 of 3] mq: remove leading slash from url when qimporting

Idan Kamara idankk86 at gmail.com
Fri Apr 29 14:32:45 CDT 2011


# 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.

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)


More information about the Mercurial-devel mailing list