Patchwork [01,of,13] largefiles: refactoring - create destination dir in lfutil.link

login
register
mail settings
Submitter Mads Kiilerich
Date April 16, 2013, 2:43 a.m.
Message ID <ee8921bf4a35fe2fd8a2.1366080198@mk-desktop>
Download mbox | patch
Permalink /patch/1330/
State Accepted
Commit d035c390211187b7536736a1ff1054423b8f580b
Headers show

Comments

Mads Kiilerich - April 16, 2013, 2:43 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1366061553 -7200
#      Mon Apr 15 23:32:33 2013 +0200
# Node ID ee8921bf4a35fe2fd8a2dcc04a0048db344ca58f
# Parent  18b828bbae09abbeac1d8ad79fbef22691f34ec2
largefiles: refactoring - create destination dir in lfutil.link

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -39,6 +39,7 @@ 
     return lfsize
 
 def link(src, dest):
+    util.makedirs(os.path.dirname(dest))
     try:
         util.oslink(src, dest)
     except OSError:
@@ -86,7 +87,6 @@ 
     elif inusercache(repo.ui, hash):
         repo.ui.note(_('found %s in system cache\n') % hash)
         path = storepath(repo, hash)
-        util.makedirs(os.path.dirname(path))
         link(usercachepath(repo.ui, hash), path)
         return path
     return None
@@ -203,10 +203,10 @@ 
 
 
 def copytostoreabsolute(repo, file, hash):
-    util.makedirs(os.path.dirname(storepath(repo, hash)))
     if inusercache(repo.ui, hash):
         link(usercachepath(repo.ui, hash), storepath(repo, hash))
     elif not getattr(repo, "_isconverting", False):
+        util.makedirs(os.path.dirname(storepath(repo, hash)))
         dst = util.atomictempfile(storepath(repo, hash),
                                   createmode=repo.store.createmode)
         for chunk in util.filechunkiter(open(file, 'rb')):
@@ -217,7 +217,6 @@ 
 def linktousercache(repo, hash):
     path = usercachepath(repo.ui, hash)
     if path:
-        util.makedirs(os.path.dirname(path))
         link(storepath(repo, hash), path)
 
 def getstandinmatcher(repo, pats=[], opts={}):
diff --git a/hgext/largefiles/localstore.py b/hgext/largefiles/localstore.py
--- a/hgext/largefiles/localstore.py
+++ b/hgext/largefiles/localstore.py
@@ -8,9 +8,6 @@ 
 
 '''store class for local filesystem'''
 
-import os
-
-from mercurial import util
 from mercurial.i18n import _
 
 import lfutil
@@ -26,7 +23,6 @@ 
         super(localstore, self).__init__(ui, repo, self.remote.url())
 
     def put(self, source, hash):
-        util.makedirs(os.path.dirname(lfutil.storepath(self.remote, hash)))
         if lfutil.instore(self.remote, hash):
             return
         lfutil.link(lfutil.storepath(self.repo, hash),