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

login
register
mail settings
Submitter Chinmay Joshi
Date June 16, 2014, 4:39 p.m.
Message ID <9dc6f43b60b2ce035846.1402936785@genesis>
Download mbox | patch
Permalink /patch/5009/
State Superseded
Commit 62cc4055c6c81ca6ecd4ea6d288e6eca2626699e
Headers show

Comments

Chinmay Joshi - June 16, 2014, 4:39 p.m.
# HG changeset patch
# User Chinmay Joshi <c@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.
Katsunori FUJIWARA - June 19, 2014, 5:27 p.m.
At Mon, 16 Jun 2014 22:09:45 +0530,
Chinmay Joshi wrote:
> 
> # HG changeset patch
> # User Chinmay Joshi <c@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)

Is additional "expandpath=True" passing needed ?

>      if not dest:
>          raise util.Abort(_("empty destination path is not valid"))

"dstvfs" should be created after "not dest" confirmation, because
creation of "dstvfs" itself becomes meaningless if "dest" is empty,

> -    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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

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)