[PATCH 2 of 3] Fix income/pull with bundle and -R. Adds an additional "mainrepo" parameter to

Matt Mackall mpm at selenic.com
Fri Nov 30 16:12:14 CST 2007


On Fri, Nov 30, 2007 at 01:16:15PM +0100, Peter Arrenbrecht wrote:
> # HG changeset patch
> # User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
> # Date 1194075690 -3600
> # Node ID c5d7088145d04baf2235a004d729a7fa7ac0e6ad
> # Parent  e2b6327fd09c361b38d603614ed473dc7d9fff83
> Fix income/pull with bundle and -R. Adds an additional "mainrepo" parameter to
> hg.repository() and *repo.instance(), which is the repository hg is running in. This
> is used to properly initialize the parent repository of a bundle repository
> (particularly when -R is in effect).
> Fixes http://www.selenic.com/mercurial/bts/issue820.
> 
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -253,17 +253,30 @@ class bundlerepository(localrepo.localre
>          if tempfile is not None:
>              os.unlink(tempfile)
>  
> -def instance(ui, path, create):
> +def instance(ui, path, create, mainrepo=None):

Could we simply always pass a mainrepo? I like to avoid default
arguments where possible.

> -            ui.write(_(" Internal patcher failure, please report this error" 
> +            ui.write(_(" Internal patcher failure, please report this error"
>                         " to http://www.selenic.com/mercurial/bts\n"))

Unrelated change

>      if source:
>          source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
> -        srepo = hg.repository(ui, source)
> +        srepo = hg.repository(ui, source, mainrepo=repo)
>          if not rev and revs:
>              rev = revs[0]
>          if not rev:
> @@ -1651,7 +1651,7 @@ def incoming(ui, repo, source="default",
>      source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev'])
>      cmdutil.setremoteconfig(ui, opts)
>  
> -    other = hg.repository(ui, source)
> +    other = hg.repository(ui, source, mainrepo=repo)
>      ui.status(_('comparing with %s\n') % util.hidepassword(source))
>      if revs:
>          revs = [other.lookup(rev) for rev in revs]

Not using the default

> -    With -v flag, print file permissions, symlink and executable bits. With 
> +    With -v flag, print file permissions, symlink and executable bits. With

Unrelated change

> -    other = hg.repository(ui, dest)
> +    other = hg.repository(ui, dest, mainrepo=repo) # mainrepo is untested; cannot outgoing from bundle
...
> -    other = hg.repository(ui, source)
> +    other = hg.repository(ui, source, mainrepo=repo)
...
> -    other = hg.repository(ui, dest)
> +    other = hg.repository(ui, dest, mainrepo=repo) # mainrepo is untested; cannot push to bundle
...
> -def repository(ui, path='', create=False):
> +def repository(ui, path='', create=False, mainrepo=None):
>      """return a repository object for the specified path"""
> -    repo = _lookup(path).instance(ui, path, create)
> +    repo = _lookup(path).instance(ui, path, create, mainrepo)
...

Again, not using the default.

On the other hand, it seems messy fiddling with this mainrepo thing.
It might be better for the -R switch to inform hg.py of where things
are happening and have hg.py manage this bit internally?

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list