[PATCH RFC] repo: differentiate between repos and proxies for potentially remotes

Adrian Buehlmann adrian at cadifra.com
Sat Jun 4 11:23:36 CDT 2011


On 2011-06-03 20:37, Peter Arrenbrecht wrote:
> # HG changeset patch
> # User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
> # Date 1307126195 -7200
> # Node ID 063cd4fae0ee0606678ed22dbaf1c77948301662
> # Parent  1ffeeb91c55d0b00445ceabde14a0d0faf906a33
> repo: differentiate between repos and proxies for potentially remotes

..

> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -21,6 +21,7 @@
>      return (os.path.isfile(path) and bundlerepo or localrepo)
>  
>  def addbranchrevs(lrepo, repo, branches, revs):
> +    repo = repo.proxy()

Why do we need to go from repo to proxy?

Why do you use the local name 'repo'? A proxy is not a repo.

Why is the second parameter of addbranchrevs a repo and not a proxy?

>      hashbranch, branches = branches
>      if not hashbranch and not branches:
>          return revs or None, revs and revs[0] or None
> @@ -34,7 +35,7 @@
>  
>      def primary(branch):
>          if branch == '.':
> -            if not lrepo or not lrepo.local():
> +            if not lrepo:
>                  raise util.Abort(_("dirstate branch not accessible"))
>              branch = lrepo.dirstate.branch()
>          if branch in branchmap:
> @@ -88,7 +89,7 @@
>              return False
>      return repo.local()
>  
> -def repository(ui, path='', create=False):
> +def repoproxy(ui, path='', create=False):
>      """return a repository object for the specified path"""

This doc string isn't correct any more. Near as I can tell, function
repoproxy returns an object which is a subclass of repositoryproxy.

Class repositoryproxy is not derived from mercurial.repo.repository, so
a repositoryproxy is not a repository(object.

>      repo = _lookup(path).instance(ui, path, create)
>      ui = getattr(repo, "ui", ui)
> @@ -96,7 +97,14 @@
>          hook = getattr(module, 'reposetup', None)
>          if hook:
>              hook(ui, repo)
> -    return repo
> +    return repo.proxy()
> +
> +def repository(ui, path='', create=False):
> +    """return a repository object for the specified path"""
> +    proxy = repoproxy(ui, path, create)
> +    if not proxy.local():
> +        raise util.Abort(_("repository '%s' is not local") % (path or proxy.url()))
> +    return proxy.repo


More information about the Mercurial-devel mailing list