[PATCH 5 of 6] hg: use vfs functions in clone

Chinmay Joshi c at chinmayjoshi.com
Mon Jun 16 11:39:45 CDT 2014


# HG changeset patch
# User Chinmay Joshi <c at chinmayjoshi.com>
# Date 1402933362 -19800
#      Mon Jun 16 21:12:42 2014 +0530
# Node ID 9dc6f43b60b2ce035846ca2fbe2f579418d2128d
# Parent  b5da6438d602ea375b4cce2d677ec8cb5ad4c2a2
hg: use vfs functions in clone

This change applies vfs functions in clone. os.path.exists will invoke
os.path.lexists via lexists of vfs to check for broken symbolic links.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -308,11 +308,12 @@
 
     dest = util.urllocalpath(dest)
     source = util.urllocalpath(source)
+    dstvfs = scmutil.vfs(dest, expandpath=True)
 
     if not dest:
         raise util.Abort(_("empty destination path is not valid"))
-    if os.path.exists(dest):
-        if not os.path.isdir(dest):
+    if dstvfs.lexists():
+        if not dstvfs.isdir():
             raise util.Abort(_("destination '%s' already exists") % dest)
         elif os.listdir(dest):
             raise util.Abort(_("destination '%s' is not empty") % dest)


More information about the Mercurial-devel mailing list