[PATCH 1 of 3] Add a new function, filesystem_case
Adrian Buehlmann
adrian at cadifra.com
Wed Apr 23 03:42:31 CDT 2008
On 23.04.2008 00:10, Paul Moore wrote:
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1063,6 +1063,42 @@
> def localpath(path):
> return path.replace('/', '\\')
>
> + def filesystem_case(name, root=''):
> + '''Get name in the case stored in the filesystem
> +
> + The filename 'name' is relative to the path 'root' (if given).
> + If the file does not exist, return it unchanged. Otherwise, return the
> + version of name with case as stored in the filesystem.
> + '''
> + if not os.path.exists(os.path.join(root, name)):
> + return name
> + parts = []
> + while name:
> + dir, leaf = os.path.split(name)
> +
> + # Scan os.listdir for a name that matches leaf except for case
> + leaf_l = leaf.lower()
Not that I would urge to do so, but what is the reasoning here for not
using os.path.normcase(leaf) instead of leaf.lower()?
http://docs.python.org/lib/module-os.path.html
More information about the Mercurial-devel
mailing list