[PATCH 6 of 6 remotenames-ext] selectivepull: support list of default bookmarks

Stanislau Hlebik stash at fb.com
Mon Feb 13 04:41:47 EST 2017


Excerpts from Gregory Szorc's message of 2017-02-11 10:54:43 -0800:
> 
> > On Jan 30, 2017, at 07:56, Stanislau Hlebik <stash at fb.com> wrote:
> > 
> > # HG changeset patch
> > # User Stanislau Hlebik <stash at fb.com>
> > # Date 1485791649 28800
> > #      Mon Jan 30 07:54:09 2017 -0800
> > # Node ID 227796849698292c76c70e874179de52b7b688d6
> > # Parent  a96117003c763be640a975d8128068d2bd3527c0
> > selectivepull: support list of default bookmarks
> > 
> > The addition is that we now support list of default bookmarks, instead of a
> > single default bookmark (the previous behavior).
> 
> Cool series!
> 
> [paths] entries have sub-options to control push behavior, including which rev is pushed by default (https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_repo_hg_file_a95fc01aaffe_mercurial_help_config.txt-23l1348&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=1EQ58Dmb5uX1qHujcsT1Mg&m=m80cJkPdWL1VwONVzbgynAt-AQewDC6TBiaCt4FE9EE&s=HPqaL5aBO4IeOlcb_2VjalCA7VhXXAmjqYHNWbaFsBY&e= ).
> 
> So if we wanted to implement selective pull in core, the mechanism to support defining the config is there...

There is one problem with that. We want to update pullrev whenever we
pull one more bookmark. For example by default `hg pull` will pull only `@`
bookmark, but after user does `hg pull -B release-bookmark` next `hg pull`
will pull `@` and `release-bookmark`. I think there isn't a way to update
config from inside hg, is there?

> 
> > 
> > diff --git a/remotenames.py b/remotenames.py
> > --- a/remotenames.py
> > +++ b/remotenames.py
> > @@ -81,14 +81,19 @@
> >     return ui.configbool('remotenames', 'selectivepull', False)
> > 
> > def _getselectivepulldefaultbookmarks(ui, remotebookmarks):
> > -    default_book = ui.config('remotenames', 'selectivepulldefault')
> > -    if not default_book:
> > -        raise error.Abort(_('no default bookmark specified for selectivepull'))
> > -    if default_book in remotebookmarks:
> > -        return {default_book: remotebookmarks[default_book]}
> > -    else:
> > +    default_books = ui.configlist('remotenames', 'selectivepulldefault')
> > +    if not default_books:
> > +        raise error.Abort(_('no default bookmarks specified for selectivepull'))
> > +
> > +    result = {}
> > +    for default_book in default_books:
> > +        if default_book in remotebookmarks:
> > +            result[default_book] = remotebookmarks[default_book]
> > +
> > +    if not default_books:
> >         raise error.Abort(
> > -            _('default bookmark %s is not found on remote') % default_book)
> > +            _('default bookmarks %s are not found on remote') % default_books)
> > +    return result
> > 
> > def _trypullremotebookmark(mayberemotebookmark, repo, ui):
> >     ui.warn(_('`%s` not found: assuming it is a remote bookmark '
> > diff --git a/tests/test-selective-pull.t b/tests/test-selective-pull.t
> > --- a/tests/test-selective-pull.t
> > +++ b/tests/test-selective-pull.t
> > @@ -227,3 +227,14 @@
> >   $ hg pull -q
> >   $ hg book --remote
> >      default/master            2:0238718db2b1
> > +
> > +Set two bookmarks in selectivepulldefault, make sure both of them were pulled
> > +  $ cat >> .hg/hgrc << EOF
> > +  > [remotenames]
> > +  > selectivepulldefault=master,thirdbook
> > +  > EOF
> > +  $ rm .hg/selectivepullenabled
> > +  $ hg pull -q
> > +  $ hg book --remote
> > +     default/master            2:0238718db2b1
> > +     default/thirdbook         0:1449e7934ec1
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel at mercurial-scm.org
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=1EQ58Dmb5uX1qHujcsT1Mg&m=m80cJkPdWL1VwONVzbgynAt-AQewDC6TBiaCt4FE9EE&s=SwBFnDsS8d4zYF2z3lzuaDpSruRPoom8wzTyogP_JVQ&e= 


More information about the Mercurial-devel mailing list