[PATCH 08 of 10] scmutil: use the new faster path split

Greg Ward greg at gerg.ca
Thu Sep 13 20:27:41 CDT 2012


On 13 September 2012, Bryan O'Sullivan said:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1347562631 25200
> # Node ID 168fa28b4620b30505e8284bcee5a0cf0d0b6338
> # Parent  9d1ceb24dc23a965d6df2b14ebca30da59139710
> scmutil: use the new faster path split
> 
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -267,7 +267,7 @@
>              mode += "b" # for that other OS
>  
>          nlink = -1
> -        dirname, basename = os.path.split(f)
> +        dirname, basename = util.split(f)
>          # If basename is empty, then the path is malformed because it points
>          # to a directory. Let the posixfile() call below raise IOError.
>          if basename and mode not in ('r', 'rb'):
> @@ -383,7 +383,7 @@
>                  name = os.path.join(*rel)
>                  auditor(name)
>                  return util.pconvert(name)
> -            dirname, basename = os.path.split(name)
> +            dirname, basename = util.split(name)
>              rel.append(basename)
>              if dirname == name:
>                  break

$ hg locate '**.py' | xargs grep 'os\.path\.split'

finds lots of other call sites. There Should Be Only One Way To Do It.

       Greg


More information about the Mercurial-devel mailing list