Patchwork [2,of,8] localrepo: use vfs instead of "os.path.*" in sharedpath checking

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 14, 2013, 5:23 p.m.
Message ID <82678ef500c55c41e317.1365960191@feefifofum>
Download mbox | patch
Permalink /patch/1302/
State Accepted, archived
Headers show

Comments

Katsunori FUJIWARA - April 14, 2013, 5:23 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1365956535 -32400
# Node ID 82678ef500c55c41e3173f46b41cd77446b6293b
# Parent  da2aae2ce567c5f8c65dcca1e2c1cf9319ee0fa0
localrepo: use vfs instead of "os.path.*" in sharedpath checking

In the point of view of efficiency, "vfs" instance created in this
patch should be passed to and reuse in "store.store()" invocation just
after patched code block, because "store" object is initialized by vfs
created with "self.sharedpath".

eBut to focus just on migration from direct file I/O API accessing to
vfs, this patch uses created vfs as temporary one. Refactoring around
"store.store()" invocation will be done in the future.

Patch

diff -r da2aae2ce567 -r 82678ef500c5 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Apr 15 01:22:15 2013 +0900
+++ b/mercurial/localrepo.py	Mon Apr 15 01:22:15 2013 +0900
@@ -209,8 +209,10 @@ 
 
         self.sharedpath = self.path
         try:
-            s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n'))
-            if not os.path.exists(s):
+            vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
+                              realpath=True)
+            s = vfs.base
+            if not vfs.exists():
                 raise error.RepoError(
                     _('.hg/sharedpath points to nonexistent directory %s') % s)
             self.sharedpath = s