# HG changeset patch # User Idan Kamara # Date 1305915624 -10800 # Node ID 170747a3e13958da9ee63ec88354ae052c35672d # Parent dc961471efde85c527d96392aab39f9c0005e16f mq: strip all leading slashes from url when importing When trying to import 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'. diff -r dc961471efde -r 170747a3e139 hgext/mq.py --- a/hgext/mq.py Fri May 20 21:19:33 2011 +0300 +++ b/hgext/mq.py Fri May 20 21:20:24 2011 +0300 @@ -1832,7 +1832,7 @@ if filename == '-' and not patchname: raise util.Abort(_('need --name to import a patch from -')) elif not patchname: - patchname = normname(os.path.basename(filename)) + patchname = normname(os.path.basename(filename.rstrip('/'))) self.check_reserved_name(patchname) checkfile(patchname) try: diff -r dc961471efde -r 170747a3e139 tests/test-mq-qimport.t --- a/tests/test-mq-qimport.t Fri May 20 21:19:33 2011 +0300 +++ b/tests/test-mq-qimport.t Fri May 20 21:20:24 2011 +0300 @@ -208,3 +208,20 @@ $ hg qimport non-existant-file --name .hg abort: patch name cannot begin with ".hg" [255] + +qimport http:// patch with leading slashes in url + +set up hgweb + + $ cd .. + $ hg init served + $ cd served + $ echo a > a + $ hg ci -Am patch + adding a + $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + + $ cd ../repo + $ hg qimport http://localhost:$HGPORT/raw-rev/0/// + adding 0 to series file