On Fri, 24 Feb 2006, blair@tigris.org wrote:
...
> --- trunk/contrib/client-side/svnmerge.py (original)
> +++ trunk/contrib/client-side/svnmerge.py Fri Feb 24 17:49:01 2006
> @@ -435,7 +435,13 @@
>
> def is_wc(dir):
> """Check if a directory is a working copy."""
> - return os.path.isdir(dir) and os.path.isdir(os.path.join(dir, ".svn"))
> + if not os.path.isdir(dir):
> + return False
Blair, this initial check is unecessary, and results in an extra stat
when the parent directory is present:
$ strace python -c 'import os; os.path.isdir("/etc") and os.path.isdir("/etc/hosts")' 2>&1 | grep etc | grep stat
stat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
stat64("/etc/hosts", {st_mode=S_IFREG|0644, st_size=191, ...}) = 0
$ strace python -c 'import os; os.path.isdir("/etc/hosts")' 2>&1 | grep etc | grep stat
stat64("/etc/hosts", {st_mode=S_IFREG|0644, st_size=191, ...}) = 0
> + if os.path.isdir(os.path.join(dir, ".svn")):
> + return True
> + if os.path.isdir(os.path.join(dir, "_svn")):
> + return True
> + return False
>
> _cache_svninfo = {}
> def get_svninfo(path):
An os.path.join() call is generally cheaper than that initial stat.
How about:
Index: svnmerge.py
===================================================================
--- svnmerge.py (revision 18629)
+++ svnmerge.py (working copy)
@@ -435,13 +435,8 @@
def is_wc(dir):
"""Check if a directory is a working copy."""
- if not os.path.isdir(dir):
- return False
- if os.path.isdir(os.path.join(dir, ".svn")):
- return True
- if os.path.isdir(os.path.join(dir, "_svn")):
- return True
- return False
+ return os.path.isdir(os.path.join(dir, ".svn")) or \
+ os.path.isdir(os.path.join(dir, "_svn"))
_cache_svninfo = {}
def get_svninfo(path):
--
Daniel Rall
- application/pgp-signature attachment: stored
Received on Mon Feb 27 19:55:50 2006