Patchwork [1,of,2] discovery: if a push would create a new head, mention the bookmark name if any

login
register
mail settings
Submitter Stephen Lee
Date March 11, 2014, 9:10 a.m.
Message ID <0573ffab1d3878b637a9.1394529006@slee-desktop>
Download mbox | patch
Permalink /patch/3908/
State Superseded
Commit 32601b0b74c0bb0ad294c100f0675745c048453d
Headers show

Comments

Stephen Lee - March 11, 2014, 9:10 a.m.
# HG changeset patch
# User Stephen Lee <sphen.lee@gmail.com>
# Date 1394265759 -39600
#      Sat Mar 08 19:02:39 2014 +1100
# Node ID 0573ffab1d3878b637a95bf6ff7bf172facedc1c
# Parent  19e9478c1a2245b6b5b4b2882efee5261d7df963
discovery: if a push would create a new head, mention the bookmark name if any
Augie Fackler - April 12, 2014, 4:22 p.m.
On Tue, Mar 11, 2014 at 08:10:06PM +1100, Stephen Lee wrote:
> # HG changeset patch
> # User Stephen Lee <sphen.lee@gmail.com>
> # Date 1394265759 -39600
> #      Sat Mar 08 19:02:39 2014 +1100
> # Node ID 0573ffab1d3878b637a95bf6ff7bf172facedc1c
> # Parent  19e9478c1a2245b6b5b4b2882efee5261d7df963
> discovery: if a push would create a new head, mention the bookmark name if any

This appears to be the case even if the user wasn't pushing the
bookmark? I'm not sure this wouldn't end up being at least moderately
confusing. Does anyone else have an opinion?

>
> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
> --- a/mercurial/discovery.py
> +++ b/mercurial/discovery.py
> @@ -337,6 +337,10 @@
>                  if branch not in ('default', None):
>                      error = _("push creates new remote head %s "
>                                "on branch '%s'!") % (short(dhs[0]), branch)
> +                elif repo[dhs[0]].bookmarks():
> +                    error = _("push creates new remote head %s "
> +                              "with bookmark '%s'!") % (
> +                              short(dhs[0]), repo[dhs[0]].bookmarks()[0])
>                  else:
>                      error = _("push creates new remote head %s!"
>                                ) % short(dhs[0])
> diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
> --- a/tests/test-bookmarks-pushpull.t
> +++ b/tests/test-bookmarks-pushpull.t
> @@ -274,7 +274,7 @@
>    $ hg push http://localhost:$HGPORT2/
>    pushing to http://localhost:$HGPORT2/
>    searching for changes
> -  abort: push creates new remote head c922c0139ca0!
> +  abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
>    (merge or see "hg help push" for details about pushing new heads)
>    [255]
>    $ hg -R ../a book
> @@ -290,7 +290,7 @@
>    $ hg push http://localhost:$HGPORT2/
>    pushing to http://localhost:$HGPORT2/
>    searching for changes
> -  abort: push creates new remote head c922c0139ca0!
> +  abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
>    (merge or see "hg help push" for details about pushing new heads)
>    [255]
>    $ hg -R ../a book
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Stephen Lee - April 13, 2014, 5:02 a.m.
On Sun, Apr 13, 2014 at 2:22 AM, Augie Fackler <raf@durin42.com> wrote:
> On Tue, Mar 11, 2014 at 08:10:06PM +1100, Stephen Lee wrote:
>> # HG changeset patch
>> # User Stephen Lee <sphen.lee@gmail.com>
>> # Date 1394265759 -39600
>> #      Sat Mar 08 19:02:39 2014 +1100
>> # Node ID 0573ffab1d3878b637a95bf6ff7bf172facedc1c
>> # Parent  19e9478c1a2245b6b5b4b2882efee5261d7df963
>> discovery: if a push would create a new head, mention the bookmark name if any
>
> This appears to be the case even if the user wasn't pushing the
> bookmark? I'm not sure this wouldn't end up being at least moderately
> confusing. Does anyone else have an opinion?
>

I see your point - this could be confusing.

The idea was to make it clear to the user what the new head is - we
remind them that it has a bookmark on it, and if they wanted to push
it they will think to use -B.

The original patch put "push -B" in the hint which made more sense.
We now redirect to "hg help push" to prevent people blindly following
the suggestion when it may not be what they want to do.

Steve

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -337,6 +337,10 @@ 
                 if branch not in ('default', None):
                     error = _("push creates new remote head %s "
                               "on branch '%s'!") % (short(dhs[0]), branch)
+                elif repo[dhs[0]].bookmarks():
+                    error = _("push creates new remote head %s "
+                              "with bookmark '%s'!") % (
+                              short(dhs[0]), repo[dhs[0]].bookmarks()[0])
                 else:
                     error = _("push creates new remote head %s!"
                               ) % short(dhs[0])
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -274,7 +274,7 @@ 
   $ hg push http://localhost:$HGPORT2/
   pushing to http://localhost:$HGPORT2/
   searching for changes
-  abort: push creates new remote head c922c0139ca0!
+  abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
   (merge or see "hg help push" for details about pushing new heads)
   [255]
   $ hg -R ../a book
@@ -290,7 +290,7 @@ 
   $ hg push http://localhost:$HGPORT2/
   pushing to http://localhost:$HGPORT2/
   searching for changes
-  abort: push creates new remote head c922c0139ca0!
+  abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
   (merge or see "hg help push" for details about pushing new heads)
   [255]
   $ hg -R ../a book