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

login
register
mail settings
Submitter Stanislau Hlebik
Date Jan. 30, 2017, 3:56 p.m.
Message ID <227796849698292c76c7.1485791764@devvm1840.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18282/
State Accepted
Headers show

Comments

Stanislau Hlebik - Jan. 30, 2017, 3:56 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@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).
Sean Farley - Feb. 3, 2017, 10:44 p.m.
Stanislau Hlebik <stash@fb.com> writes:

> # HG changeset patch
> # User Stanislau Hlebik <stash@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).

Queued these, thanks!
Gregory Szorc - Feb. 11, 2017, 6:54 p.m.
> On Jan 30, 2017, at 07:56, Stanislau Hlebik <stash@fb.com> wrote:
> 
> # HG changeset patch
> # User Stanislau Hlebik <stash@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://www.mercurial-scm.org/repo/hg/file/a95fc01aaffe/mercurial/help/config.txt#l1348).

So if we wanted to implement selective pull in core, the mechanism to support defining the config 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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Stanislau Hlebik - Feb. 13, 2017, 9:41 a.m.
Excerpts from Gregory Szorc's message of 2017-02-11 10:54:43 -0800:
> 
> > On Jan 30, 2017, at 07:56, Stanislau Hlebik <stash@fb.com> wrote:
> > 
> > # HG changeset patch
> > # User Stanislau Hlebik <stash@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@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=
Gregory Szorc - Feb. 22, 2017, 5:28 a.m.
On Mon, Feb 13, 2017 at 1:41 AM, Stanislau Hlebik <stash@fb.com> wrote:

> Excerpts from Gregory Szorc's message of 2017-02-11 10:54:43 -0800:
> >
> > > On Jan 30, 2017, at 07:56, Stanislau Hlebik <stash@fb.com> wrote:
> > >
> > > # HG changeset patch
> > > # User Stanislau Hlebik <stash@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?
>

No. But I saw smf making noise about this a few days ago.


>
> >
> > >
> > > 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@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=
>

Patch

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