19 import weakref, errno, os, time, inspect |
19 import weakref, errno, os, time, inspect |
20 propertycache = util.propertycache |
20 propertycache = util.propertycache |
21 |
21 |
22 class localrepository(repo.repository): |
22 class localrepository(repo.repository): |
23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey')) |
23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey')) |
24 supported = set('revlogv1 store fncache shared parentdelta'.split()) |
24 supportedformats = set(('revlogv1', 'parentdelta')) |
|
25 supported = supportedformats | set(('store', 'fncache', 'shared')) |
25 |
26 |
26 def __init__(self, baseui, path=None, create=0): |
27 def __init__(self, baseui, path=None, create=0): |
27 repo.repository.__init__(self) |
28 repo.repository.__init__(self) |
28 self.root = os.path.realpath(util.expandpath(path)) |
29 self.root = os.path.realpath(util.expandpath(path)) |
29 self.path = os.path.join(self.root, ".hg") |
30 self.path = os.path.join(self.root, ".hg") |
56 '\0\0\0\2' # represents revlogv2 |
57 '\0\0\0\2' # represents revlogv2 |
57 ' dummy changelog to prevent using the old repo layout' |
58 ' dummy changelog to prevent using the old repo layout' |
58 ) |
59 ) |
59 if self.ui.configbool('format', 'parentdelta', False): |
60 if self.ui.configbool('format', 'parentdelta', False): |
60 requirements.append("parentdelta") |
61 requirements.append("parentdelta") |
61 reqfile = self.opener("requires", "w") |
|
62 for r in requirements: |
|
63 reqfile.write("%s\n" % r) |
|
64 reqfile.close() |
|
65 else: |
62 else: |
66 raise error.RepoError(_("repository %s not found") % path) |
63 raise error.RepoError(_("repository %s not found") % path) |
67 elif create: |
64 elif create: |
68 raise error.RepoError(_("repository %s already exists") % path) |
65 raise error.RepoError(_("repository %s already exists") % path) |
69 else: |
66 else: |
91 self.store = store.store(requirements, self.sharedpath, util.opener) |
88 self.store = store.store(requirements, self.sharedpath, util.opener) |
92 self.spath = self.store.path |
89 self.spath = self.store.path |
93 self.sopener = self.store.opener |
90 self.sopener = self.store.opener |
94 self.sjoin = self.store.join |
91 self.sjoin = self.store.join |
95 self.opener.createmode = self.store.createmode |
92 self.opener.createmode = self.store.createmode |
96 self.sopener.options = {} |
93 self._applyrequirements(requirements) |
97 if 'parentdelta' in requirements: |
94 if create: |
98 self.sopener.options['parentdelta'] = 1 |
95 self._writerequirements() |
99 |
96 |
100 # These two define the set of tags for this repository. _tags |
97 # These two define the set of tags for this repository. _tags |
101 # maps tag name to node; _tagtypes maps tag name to 'global' or |
98 # maps tag name to node; _tagtypes maps tag name to 'global' or |
102 # 'local'. (Global tags are defined by .hgtags across all |
99 # 'local'. (Global tags are defined by .hgtags across all |
103 # heads, and local tags are defined in .hg/localtags.) They |
100 # heads, and local tags are defined in .hg/localtags.) They |
109 self._branchcachetip = None |
106 self._branchcachetip = None |
110 self.nodetagscache = None |
107 self.nodetagscache = None |
111 self.filterpats = {} |
108 self.filterpats = {} |
112 self._datafilters = {} |
109 self._datafilters = {} |
113 self._transref = self._lockref = self._wlockref = None |
110 self._transref = self._lockref = self._wlockref = None |
|
111 |
|
112 def _applyrequirements(self, requirements): |
|
113 self.requirements = requirements |
|
114 self.sopener.options = {} |
|
115 if 'parentdelta' in requirements: |
|
116 self.sopener.options['parentdelta'] = 1 |
|
117 |
|
118 def _writerequirements(self): |
|
119 reqfile = self.opener("requires", "w") |
|
120 for r in self.requirements: |
|
121 reqfile.write("%s\n" % r) |
|
122 reqfile.close() |
114 |
123 |
115 def _checknested(self, path): |
124 def _checknested(self, path): |
116 """Determine if path is a legal nested repository.""" |
125 """Determine if path is a legal nested repository.""" |
117 if not path.startswith(self.root): |
126 if not path.startswith(self.root): |
118 return False |
127 return False |