##// END OF EJS Templates
unionrepo: dynamically create repository type from base repository...
Gregory Szorc -
r39641:23f2299e default
parent child Browse files
Show More
@@ -192,15 +192,18 b' class unionpeer(localrepo.localpeer):'
192 def canpush(self):
192 def canpush(self):
193 return False
193 return False
194
194
195 class unionrepository(localrepo.localrepository):
195 class unionrepository(object):
196 def __init__(self, ui, path, path2):
196 """Represents the union of data in 2 repositories.
197 localrepo.localrepository.__init__(self, ui, path)
197
198 Instances are not usable if constructed directly. Use ``instance()``
199 or ``makeunionrepository()`` to create a usable instance.
200 """
201 def __init__(self, repo2, url):
202 self.repo2 = repo2
203 self._url = url
204
198 self.ui.setconfig('phases', 'publish', False, 'unionrepo')
205 self.ui.setconfig('phases', 'publish', False, 'unionrepo')
199
206
200 self._url = 'union:%s+%s' % (util.expandpath(path),
201 util.expandpath(path2))
202 self.repo2 = localrepo.localrepository(ui, path2)
203
204 @localrepo.unfilteredpropertycache
207 @localrepo.unfilteredpropertycache
205 def changelog(self):
208 def changelog(self):
206 return unionchangelog(self.svfs, self.repo2.svfs)
209 return unionchangelog(self.svfs, self.repo2.svfs)
@@ -260,4 +263,22 b' def instance(ui, path, create, intents=N'
260 repopath, repopath2 = s
263 repopath, repopath2 = s
261 else:
264 else:
262 repopath, repopath2 = parentpath, path
265 repopath, repopath2 = parentpath, path
263 return unionrepository(ui, repopath, repopath2)
266
267 return makeunionrepository(ui, repopath, repopath2)
268
269 def makeunionrepository(ui, repopath1, repopath2):
270 """Make a union repository object from 2 local repo paths."""
271 repo1 = localrepo.instance(ui, repopath1, create=False)
272 repo2 = localrepo.instance(ui, repopath2, create=False)
273
274 url = 'union:%s+%s' % (util.expandpath(repopath1),
275 util.expandpath(repopath2))
276
277 class derivedunionrepository(unionrepository, repo1.__class__):
278 pass
279
280 repo = repo1
281 repo.__class__ = derivedunionrepository
282 unionrepository.__init__(repo1, repo2, url)
283
284 return repo
General Comments 0
You need to be logged in to leave comments. Login now