[PATCH] largefiles: ensure destination's parent directory exists before linking there
Hao Lian
hao at fogcreek.com
Mon Oct 24 16:11:00 UTC 2011
# HG changeset patch
# User Hao Lian <hao at fogcreek.com>
# Date 1319471601 14400
# Branch stable
# Node ID be701d4a2bf507f3acac979252933ba8dc1f24f9
# Parent 8b8dd13295dbd733cc03ebb3c2af2f33d24d5428
largefiles: ensure destination's parent directory exists before linking there
When findfile links a largefile from the user cache to the store for the first
time, it errors out because the store path's parent directory doesn't exist yet.
This patch fixes it by imbuing the link helper function with the ability to
autovivify the destination's path.
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -73,6 +73,7 @@
return lfsize
def link(src, dest):
+ createdir(os.path.dirname(dest))
try:
util.oslink(src, dest)
except OSError:
@@ -223,16 +224,12 @@
copytostoreabsolute(repo, repo.wjoin(file), hash)
def copytostoreabsolute(repo, file, hash):
- createdir(os.path.dirname(storepath(repo, hash)))
- if inusercache(repo.ui, hash):
- link(usercachepath(repo.ui, hash), storepath(repo, hash))
- else:
- shutil.copyfile(file, storepath(repo, hash))
- os.chmod(storepath(repo, hash), os.stat(file).st_mode)
- linktousercache(repo, hash)
+ cachepath = usercachepath(repo.ui, hash)
+ if not inusercache(repo.ui, hash):
+ link(file, cachepath)
+ link(cachepath, storepath(repo, hash))
def linktousercache(repo, hash):
- createdir(os.path.dirname(usercachepath(repo.ui, hash)))
link(storepath(repo, hash), usercachepath(repo.ui, hash))
def getstandinmatcher(repo, pats=[], opts={}):
More information about the Mercurial-devel
mailing list