changeset 8799:87d1fd40f57e

repo: add internal support for sharing store directories set .hg/sharedpath to point to the .hg to share with
author Matt Mackall <mpm@selenic.com>
date Sat, 13 Jun 2009 18:01:46 -0500
parents 92fc57c9f9d1
children 971e38a9344b
files mercurial/localrepo.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Jun 12 02:19:51 2009 -0500
+++ b/mercurial/localrepo.py	Sat Jun 13 18:01:46 2009 -0500
@@ -19,7 +19,7 @@
 
 class localrepository(repo.repository):
     capabilities = set(('lookup', 'changegroupsubset', 'branchmap'))
-    supported = set('revlogv1 store fncache'.split())
+    supported = set('revlogv1 store fncache shared'.split())
 
     def __init__(self, baseui, path=None, create=0):
         repo.repository.__init__(self)
@@ -72,7 +72,18 @@
             for r in requirements - self.supported:
                 raise error.RepoError(_("requirement '%s' not supported") % r)
 
-        self.store = store.store(requirements, self.path, util.opener)
+        self.sharedpath = self.path
+        try:
+            s = os.path.realpath(self.opener("sharedpath").read())
+            if not os.path.exists(s):
+                raise error.RepoError(
+                    _('.hg/sharedpath points to nonexistent directory %s' % s))
+            self.sharedpath = s
+        except IOError, inst:
+            if inst.errno != errno.ENOENT:
+                raise
+
+        self.store = store.store(requirements, self.sharedpath, util.opener)
         self.spath = self.store.path
         self.sopener = self.store.opener
         self.sjoin = self.store.join