D4556: unionrepo: dynamically create repository type from base repository
This revision was automatically updated to reflect the committed changes. Closed by commit rHG23f2299e9e53: unionrepo: dynamically create repository type from base repository (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4556?vs=10988=10999 REVISION DETAIL https://phab.mercurial-scm.org/D4556 AFFECTED FILES mercurial/unionrepo.py CHANGE DETAILS diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -192,15 +192,18 @@ def canpush(self): return False -class unionrepository(localrepo.localrepository): -def __init__(self, ui, path, path2): -localrepo.localrepository.__init__(self, ui, path) +class unionrepository(object): +"""Represents the union of data in 2 repositories. + +Instances are not usable if constructed directly. Use ``instance()`` +or ``makeunionrepository()`` to create a usable instance. +""" +def __init__(self, repo2, url): +self.repo2 = repo2 +self._url = url + self.ui.setconfig('phases', 'publish', False, 'unionrepo') -self._url = 'union:%s+%s' % (util.expandpath(path), - util.expandpath(path2)) -self.repo2 = localrepo.localrepository(ui, path2) - @localrepo.unfilteredpropertycache def changelog(self): return unionchangelog(self.svfs, self.repo2.svfs) @@ -260,4 +263,22 @@ repopath, repopath2 = s else: repopath, repopath2 = parentpath, path -return unionrepository(ui, repopath, repopath2) + +return makeunionrepository(ui, repopath, repopath2) + +def makeunionrepository(ui, repopath1, repopath2): +"""Make a union repository object from 2 local repo paths.""" +repo1 = localrepo.instance(ui, repopath1, create=False) +repo2 = localrepo.instance(ui, repopath2, create=False) + +url = 'union:%s+%s' % (util.expandpath(repopath1), + util.expandpath(repopath2)) + +class derivedunionrepository(unionrepository, repo1.__class__): +pass + +repo = repo1 +repo.__class__ = derivedunionrepository +unionrepository.__init__(repo1, repo2, url) + +return repo To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4556: unionrepo: dynamically create repository type from base repository
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is basically the same thing we just did for bundlerepo except for union repositories. .. api:: ``unionrepo.unionrepository()`` is no longer usable on its own. To instantiate an instance, call ``unionrepo.instance()`` or ``unionrepo.makeunionrepository()``. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4556 AFFECTED FILES mercurial/unionrepo.py CHANGE DETAILS diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -192,15 +192,18 @@ def canpush(self): return False -class unionrepository(localrepo.localrepository): -def __init__(self, ui, path, path2): -localrepo.localrepository.__init__(self, ui, path) +class unionrepository(object): +"""Represents the union of data in 2 repositories. + +Instances are not usable if constructed directly. Use ``instance()`` +or ``makeunionrepository()`` to create a usable instance. +""" +def __init__(self, repo2, url): +self.repo2 = repo2 +self._url = url + self.ui.setconfig('phases', 'publish', False, 'unionrepo') -self._url = 'union:%s+%s' % (util.expandpath(path), - util.expandpath(path2)) -self.repo2 = localrepo.localrepository(ui, path2) - @localrepo.unfilteredpropertycache def changelog(self): return unionchangelog(self.svfs, self.repo2.svfs) @@ -260,4 +263,22 @@ repopath, repopath2 = s else: repopath, repopath2 = parentpath, path -return unionrepository(ui, repopath, repopath2) + +return makeunionrepository(ui, repopath, repopath2) + +def makeunionrepository(ui, repopath1, repopath2): +"""Make a union repository object from 2 local repo paths.""" +repo1 = localrepo.instance(ui, repopath1, create=False) +repo2 = localrepo.instance(ui, repopath2, create=False) + +url = 'union:%s+%s' % (util.expandpath(repopath1), + util.expandpath(repopath2)) + +class derivedunionrepository(unionrepository, repo1.__class__): +pass + +repo = repo1 +repo.__class__ = derivedunionrepository +unionrepository.__init__(repo1, repo2, url) + +return repo To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel