[PATCH 2 of 2 V2] remotenames: selectivepull, update to the unknown bookmark tries to pull it

Durham Goode durham at fb.com
Thu Aug 18 14:21:42 EDT 2016


I'd use 'hg email --flag remotenames-ext ...' when sending remotenames 
patches, so it's clear this series isn't for normal Mercurial.

A few inline comments, but overall looks good.

On 8/18/16 3:53 AM, Stanislau Hlebik wrote:
> # HG changeset patch
> # User Stanislau Hlebik <stash at fb.com>
> # Date 1471517316 25200
> #      Thu Aug 18 03:48:36 2016 -0700
> # Node ID 956e82482a2cd431ab73f2492fe4ae1e7efff15b
> # Parent  866049ffa049dc598af834a035f27a06684d264d
> remotenames: selectivepull, update to the unknown bookmark tries to pull it
>
> Part of Selective Pull project (see https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_wiki_SelectivePullPlan&d=DQIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=Xi_7BpNL8bqVfsBjWGxHg2y4o8voQE5e2-jrnjrwm5s&s=Jbe2NmRU2jc4Sg3bEYC4YLhZhh9lP-CuZ0R3BB2zaDc&e=  for details).
> If Selective Pull is enabled, then we want to be able to check out
> revision even if it's not present locally, but present on remote server.
> If rev or node is not present locally, new request is issued to find
> it remotely. If it is present remotely then it's pulled.
>
> Test Plan:
> Run remotenames tests
>
> diff --git a/remotenames.py b/remotenames.py
> --- a/remotenames.py
> +++ b/remotenames.py
> @@ -76,6 +76,22 @@
>   def _isselectivepull(ui):
>       return ui.configbool('remotenames', 'selectivepull', False)
>   
> +def _trypullremotebookmark(mayberemotebookmark, repo, ui):
> +    ui.status(_('`%s` not found: assuming it is a remote bookmark '
> +                'and trying to pull it\n') % mayberemotebookmark)
> +    sourcerenames = dict((v, k) for k, v in _getrenames(ui).iteritems())
> +    remote, bookmarkname = splitremotename(mayberemotebookmark)
> +    paths = dict((path, url) for path, url in ui.configitems('paths'))
> +    if remote in sourcerenames:
> +        source = sourcerenames[remote]
What if the result of the rename isn't a valid path?
> +    elif remote in paths:
> +        source = remote
> +    else:
> +        source = 'default'
> +        bookmarkname = mayberemotebookmark
> +    commands.pull(ui, repo, source=source, bookmark=[bookmarkname])
What happens if the pull fails?  Do we throw a pull exception? Seems 
like we'd probably want to eat it (maybe with a message) and let the 
update continue and fail like normal.  That also fits in better with the 
function name 'tryxxx'
> +    ui.status(_('`%s` found remotely\n') % mayberemotebookmark)
I'd probably put this message (and the one above) on stderr (ui.warn).  
That way we don't interfere with any automation that's expecting certain 
stdout.


More information about the Mercurial-devel mailing list