[PATCH 1 of 2] largefiles: ensure destination directory exists before findfile links to there

Hao Lian hao at fogcreek.com
Thu Nov 3 10:02:57 CDT 2011


# HG changeset patch
# User Hao Lian <hao at fogcreek.com>
# Date 1320332372 14400
# Branch stable
# Node ID 9ff44ce93d70ec8fc47e2cf56c7453e0fe58e847
# Parent  a708b65baeb92ce4971cccaee5b799b88595ddb2
largefiles: ensure destination directory exists before findfile links to there

When (1) findfile links a largefile from the user cache to the store and (2) the
store directory doesn't exist yet, findfile errors out. A simple call to
util.makedirs fixes it.

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -110,7 +110,9 @@
         repo.ui.note(_('Found %s in store\n') % hash)
     elif inusercache(repo.ui, hash):
         repo.ui.note(_('Found %s in system cache\n') % hash)
-        link(usercachepath(repo.ui, hash), storepath(repo, hash))
+        path = storepath(repo, hash)
+        util.makedirs(os.path.dirname(path))
+        link(usercachepath(repo.ui, hash), path)
     else:
         return None
     return storepath(repo, hash)


More information about the Mercurial-devel mailing list