Benjamin Pollack  committed c65f5b6

largefiles: rename functions and methods to match desired behavior

The original intent was that the largefiles would primarily be in the
repository, with the global cache being only that--a cache. The naming
conventions and actual intent have both strayed. In this first patch, the
naming conventions are switched to match the actual intent, as are the
configuration options.

  • Participants
  • Parent commits ca51a5d
  • Branches stable

Comments (0)

Files changed (5)

File hgext/largefiles/

             at += 1
             ui.note(_('getting %s:%s\n') % (filename, hash))
-            cachefilename = lfutil.cachepath(self.repo, hash)
-            cachedir = os.path.dirname(cachefilename)
+            storefilename = lfutil.storepath(self.repo, hash)
+            storedir = os.path.dirname(storefilename)
             # No need to pass mode='wb' to fdopen(), since mkstemp() already
             # opened the file in binary mode.
             (tmpfd, tmpfilename) = tempfile.mkstemp(
-                dir=cachedir, prefix=os.path.basename(filename))
+                dir=storedir, prefix=os.path.basename(filename))
             tmpfile = os.fdopen(tmpfd, 'w')
-            if os.path.exists(cachefilename): # Windows
-                os.remove(cachefilename)
-            os.rename(tmpfilename, cachefilename)
-            lfutil.linktosystemcache(self.repo, hash)
+            if os.path.exists(storefilename): # Windows
+                os.remove(storefilename)
+            os.rename(tmpfilename, storefilename)
+            lfutil.linktousercache(self.repo, hash)
             success.append((filename, hhash))
         ui.progress(_('getting largefiles'), None)

File hgext/largefiles/

         shutil.copyfile(src, dest)
         os.chmod(dest, os.stat(src).st_mode)
-def systemcachepath(ui, hash):
-    path = ui.config(longname, 'systemcache', None)
+def usercachepath(ui, hash):
+    path = ui.config(longname, 'usercache', None)
     if path:
         path = os.path.join(path, hash)
             raise util.Abort(_('unknown operating system: %s\n') %
     return path
-def insystemcache(ui, hash):
-    return os.path.exists(systemcachepath(ui, hash))
+def inusercache(ui, hash):
+    return os.path.exists(usercachepath(ui, hash))
 def findfile(repo, hash):
-    if incache(repo, hash):
-        repo.ui.note(_('Found %s in cache\n') % hash)
-        return cachepath(repo, hash)
-    if insystemcache(repo.ui, hash):
+    if instore(repo, hash):
+        repo.ui.note(_('Found %s in store\n') % hash)
+        return storepath(repo, hash)
+    if inusercache(repo.ui, hash):
         repo.ui.note(_('Found %s in system cache\n') % hash)
-        return systemcachepath(repo.ui, hash)
+        return usercachepath(repo.ui, hash)
     return None
 class largefiles_dirstate(dirstate.dirstate):
             for f in repo[rev].walk(matcher)
             if rev is not None or repo.dirstate[f] != '?']
-def incache(repo, hash):
-    return os.path.exists(cachepath(repo, hash))
+def instore(repo, hash):
+    return os.path.exists(storepath(repo, hash))
 def createdir(dir):
     if not os.path.exists(dir):
-def cachepath(repo, hash):
+def storepath(repo, hash):
     return repo.join(os.path.join(longname, hash))
 def copyfromcache(repo, hash, filename):
     shutil.copy(path, repo.wjoin(filename))
     return True
-def copytocache(repo, rev, file, uploaded=False):
+def copytostore(repo, rev, file, uploaded=False):
     hash = readstandin(repo, file)
-    if incache(repo, hash):
+    if instore(repo, hash):
-    copytocacheabsolute(repo, repo.wjoin(file), hash)
+    copytostoreabsolute(repo, repo.wjoin(file), hash)
-def copytocacheabsolute(repo, file, hash):
-    createdir(os.path.dirname(cachepath(repo, hash)))
-    if insystemcache(repo.ui, hash):
-        link(systemcachepath(repo.ui, hash), cachepath(repo, 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))
-        shutil.copyfile(file, cachepath(repo, hash))
-        os.chmod(cachepath(repo, hash), os.stat(file).st_mode)
-        linktosystemcache(repo, hash)
+        shutil.copyfile(file, storepath(repo, hash))
+        os.chmod(storepath(repo, hash), os.stat(file).st_mode)
+        linktousercache(repo, hash)
-def linktosystemcache(repo, hash):
-    createdir(os.path.dirname(systemcachepath(repo.ui, hash)))
-    link(cachepath(repo, hash), systemcachepath(repo.ui, 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={}):
     '''Return a match object that applies pats to the standin directory'''

File hgext/largefiles/

     def exists(self, hash):
-        return lfutil.insystemcache(self.repo.ui, hash)
+        return lfutil.inusercache(self.repo.ui, hash)
     def _getfile(self, tmpfile, filename, hash):
-        if lfutil.insystemcache(self.ui, hash):
-            return lfutil.systemcachepath(self.ui, hash)
+        if lfutil.inusercache(self.ui, hash):
+            return lfutil.usercachepath(self.ui, hash)
         raise basestore.StoreError(filename, hash, '',
             _("Can't get file locally"))
         expecthash =[0:40]
-        if not lfutil.insystemcache(self.ui, expecthash):
+        if not lfutil.inusercache(self.ui, expecthash):
                 _('changeset %s: %s missing\n'
                   '  (looked for hash %s)\n')
             return True                 # failed
         if contents:
-            storepath = lfutil.systemcachepath(self.ui, expecthash)
+            storepath = lfutil.usercachepath(self.ui, expecthash)
             actualhash = lfutil.hashfile(storepath)
             if actualhash != expecthash:

File hgext/largefiles/

             if sha != lfutil.hexsha1(f):
                 return wireproto.pushres(1)
-            lfutil.copytocacheabsolute(repo,, sha)
+            lfutil.copytostoreabsolute(repo,, sha)
         except IOError:
                 _('error: could not put received data into largefile store'))

File hgext/largefiles/

             for filename in ctx.files():
                 if lfutil.isstandin(filename) and filename in ctx.manifest():
                     realfile = lfutil.splitstandin(filename)
-                    lfutil.copytocache(self, ctx.node(), realfile)
+                    lfutil.copytostore(self, ctx.node(), realfile)
             return node