Author: danielsh
Date: Thu Sep 6 10:38:32 2012
New Revision: 1381551
URL: http://svn.apache.org/viewvc?rev=1381551&view=rev
Log:
[in tools/server-side/svnpubsub]
Teach svnwcsub to tolerate existing empty directories.
* svnwcsub.py
(): Declare UTF-8 encoding for Python.
(is_emptydir): New function (with alternative definitions for 2.5+ and
2.4-and-older --- what version of Python does svnwcsub support?).
(WorkingCopy._get_match):
Autopopulate existing empty directories.
Modified:
subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
Modified: subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py?rev=1381551&r1=1381550&r2=1381551&view=diff
==============================================================================
--- subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py (original)
+++ subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py Thu Sep 6
10:38:32 2012
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# encoding: UTF-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -72,6 +73,22 @@ def svn_info(svnbin, env, path):
info[line[:idx]] = line[idx+1:].strip()
return info
+try:
+ import glob
+ glob.iglob
+ def is_emptydir(path):
+ # ### If the directory contains only dotfile children, this will
readdir()
+ # ### the entire directory. But os.readdir() is not exposed to us...
+ for x in glob.iglob('%s/*' % path):
+ return False
+ for x in glob.iglob('%s/.*' % path):
+ return False
+ return True
+except (ImportError, AttributeError):
+ # Python â¤2.4
+ def is_emptydir(path):
+ # This will read the entire directory list to memory.
+ return not os.listdir(path)
class WorkingCopy(object):
def __init__(self, bdec, path, url):
@@ -107,7 +124,7 @@ class WorkingCopy(object):
def _get_match(self, svnbin, env):
### quick little hack to auto-checkout missing working copies
- if not os.path.isdir(self.path):
+ if not os.path.isdir(self.path) or is_emptydir(self.path):
logging.info("autopopulate %s from %s" % (self.path, self.url))
subprocess.check_call([svnbin, 'co', '-q',
'--non-interactive',