[PATCH] clone: allow clones into effectively empty directories
Jason Harris
jason.f.harris at gmail.com
Tue Apr 5 01:48:25 CDT 2011
# HG changeset patch
# User jfh <jason at jasonfharris.com>
# Date 1301985969 -7200
# Node ID b583c5667fad5d84899f94183117757f42de41e8
# Parent 0995eee8ffe4a24478379fb16fd6c38812bc3dd5
clone: allow clones into effectively empty directories
In OSX many empty directories actually have a '.DS_Store' file
in them, which is effectively ignored by lots of things. The
presence of this .DS_Store file shouldn't mean that the directory
is treated as though it really has stuff in it.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -227,7 +227,7 @@
if os.path.exists(dest):
if not os.path.isdir(dest):
raise util.Abort(_("destination '%s' already exists") % dest)
- elif os.listdir(dest):
+ elif not util.effectivelyempty(dest):
raise util.Abort(_("destination '%s' is not empty") % dest)
class DirCleanup(object):
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -493,6 +493,13 @@
return hardlink, num
+def effectivelyempty(d):
+ for file in os.listdir(d):
+ if file != '.DS_Store':
+ return False
+ return True
+
+
class path_auditor(object):
'''ensure that a filesystem path contains no banned components.
the following properties of a path are checked:
More information about the Mercurial-devel
mailing list