[PATCH] clone: allow clones into effectively empty directories
Tatham Oddie
tatham at oddie.com.au
Tue Apr 5 05:44:47 CDT 2011
Want to add thumbs.db and desktop.ini for Windows support while you're at it?
--
Tatham Oddie
au mob: +61 414 275 989, us cell: +1 213 280 3556, skype: tathamoddie
If you're printing this email, you're doing it wrong. This is a computer, not a typewriter.
-----Original Message-----
From: mercurial-devel-bounces at selenic.com [mailto:mercurial-devel-bounces at selenic.com] On Behalf Of Jason Harris
Sent: Tuesday, 5 April 2011 4:48 PM
To: mercurial-devel at selenic.com
Subject: [PATCH] clone: allow clones into effectively empty directories
# 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:
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list