[PATCH] archive: make sure prefix is a string
Mads Kiilerich
mads at kiilerich.com
Sun Jul 31 15:46:55 CDT 2011
Andreas Freimuth wrote, On 07/31/2011 09:07 PM:
> # HG changeset patch
> # User Andreas Freimuth<andreas.freimuth at united-bits.de>
> # Date 1312139091 -7200
> # Branch stable
> # Node ID a933df66be1ff3b5a012bb0cef03d0324ca00dc7
> # Parent 192e02680d094dc22cf856e70f07348bd6de18d1
> archive: make sure prefix is a string
>
> prefix defaults to None, but it is used to create
> a file name like this:
> prefix + name
> so make sure it is an empty string.
Yes, we have prefix=None in the function definition, but is the function
ever called without prefix set to a string?
What you have found might not be a bug but just an indication that
prefix is a mandatory parameter unless kind='files'.
However, if the default value for prefix should be '', then why not just
set it as default instead of None?
/Mads
> diff --git a/mercurial/archival.py b/mercurial/archival.py
> --- a/mercurial/archival.py
> +++ b/mercurial/archival.py
> @@ -230,6 +230,7 @@ def archive(repo, dest, node, kind, deco
> if kind == 'files':
> if prefix:
> raise util.Abort(_('cannot give prefix when archiving to files'))
> + prefix = ''
> else:
> prefix = tidyprefix(dest, kind, prefix)
>
More information about the Mercurial-devel
mailing list