[PATCH v2] mq: strip all leading slashes from url when importing

Matt Mackall mpm at selenic.com
Fri May 20 17:04:38 CDT 2011


On Fri, 2011-05-20 at 21:26 +0300, Idan Kamara wrote:
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1305915624 -10800
> # Node ID 7a1d9092a16ea4fbcde7deafccc3252f370083fd
> # Parent  de78eed71adc97701457a6d45b273460b60d450c
> 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.

Doesn't apply to default?

> e.g. `hg qimport http://paste.pocoo.org/raw/xxx/`
> deduced '.' to be the patch name. Now we'll deduce 'xxx'.
> 
> diff -r de78eed71adc -r 7a1d9092a16e 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 de78eed71adc -r 7a1d9092a16e 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list