Patchwork [stable] discovery: don't report all "unsynced" remote heads (issue4230)

login
register
mail settings
Submitter Mads Kiilerich
Date April 24, 2014, 2:48 p.m.
Message ID <6cf15ecc6c4f473a5b0e.1398350908@mk-desktop>
Download mbox | patch
Permalink /patch/4436/
State Accepted
Commit 56a04085c23c1184d65d9d2d10927379c6211939
Headers show

Comments

Mads Kiilerich - April 24, 2014, 2:48 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1398350842 -7200
#      Thu Apr 24 16:47:22 2014 +0200
# Branch stable
# Node ID 6cf15ecc6c4f473a5b0e10741745dea2db2d11a4
# Parent  d36440d843284ba546858b241da9cc4817811fe5
discovery: don't report all "unsynced" remote heads (issue4230)

8a9e0b523d2d made discovery more helpful - too helpful for some extreme use
cases.

Instead, we arbitrarily limit the list it at 4 and add 'or more'.
Pierre-Yves David - April 24, 2014, 8:26 p.m.
On 04/24/2014 07:48 AM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1398350842 -7200
> #      Thu Apr 24 16:47:22 2014 +0200
> # Branch stable
> # Node ID 6cf15ecc6c4f473a5b0e10741745dea2db2d11a4
> # Parent  d36440d843284ba546858b241da9cc4817811fe5
> discovery: don't report all "unsynced" remote heads (issue4230)
>
> 8a9e0b523d2d made discovery more helpful - too helpful for some extreme use
> cases.
>
> Instead, we arbitrarily limit the list it at 4 and add 'or more'.

Thanks for the patches, definitly and improvement on the previous state


>
> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
> --- a/mercurial/discovery.py
> +++ b/mercurial/discovery.py
> @@ -313,7 +313,11 @@ def checkheads(repo, remote, outgoing, r
>               newhs = candidate_newhs
>           unsynced = sorted(h for h in unsyncedheads if h not in discardedheads)
>           if unsynced:
> -            heads = ' '.join(short(h) for h in unsynced)
> +            if len(unsynced) <= 4 or repo.ui.verbose:
> +                heads = ' '.join(short(h) for h in unsynced)
> +            else:
> +                heads = (' '.join(short(h) for h in unsynced[:4]) +
> +                         ' ' + _("and %s others") % (len(unsynced) - 4))

Sound translation unfriendly but is probably okay

>               if branch is None:
>                   repo.ui.status(_("remote has heads that are "
>                                    "not known locally: %s\n") % heads)
> diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
> --- a/tests/test-push-warn.t
> +++ b/tests/test-push-warn.t
> @@ -378,7 +378,7 @@ Pushing multi headed new branch:
>     added 3 changesets with 3 changes to 1 files (+1 heads)
>
>   Checking prepush logic does not allow silently pushing
> -multiple new heads:
> +multiple new heads but also doesn't report too many heads:
>
>     $ cd ..
>     $ hg init h
> @@ -404,10 +404,29 @@ multiple new heads:
>     adding c
>     created new head
>
> +  $ for i in `seq 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
> +
>     $ hg -R i push h
>     pushing to h
>     searching for changes
> -  remote has heads on branch 'default' that are not known locally: ce4212fc8847
> +  remote has heads on branch 'default' that are not known locally: 534543e22c29 764f8ec07b96 afe7cc7679f5 ce4212fc8847

This line is still a bit long (116 char) maybe we can rephrase of 
reformat it so it is not that long?


> +  abort: push creates new remote head 97bd0c84d346!
> +  (pull and merge or see "hg help push" for details about pushing new heads)
> +  [255]
> +  $ hg -R h up -q 0; echo x > h/b; hg -R h ci -qAmx
> +  $ hg -R i push h
> +  pushing to h
> +  searching for changes
> +  remote has heads on branch 'default' that are not known locally: 18ddb72c4590 534543e22c29 764f8ec07b96 afe7cc7679f5 and 1 others


getting worth here. 130 char.
Matt Mackall - April 29, 2014, 7:26 p.m.
On Thu, 2014-04-24 at 16:48 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1398350842 -7200
> #      Thu Apr 24 16:47:22 2014 +0200
> # Branch stable
> # Node ID 6cf15ecc6c4f473a5b0e10741745dea2db2d11a4
> # Parent  d36440d843284ba546858b241da9cc4817811fe5
> discovery: don't report all "unsynced" remote heads (issue4230)

Queued for stable, thanks.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -313,7 +313,11 @@  def checkheads(repo, remote, outgoing, r
             newhs = candidate_newhs
         unsynced = sorted(h for h in unsyncedheads if h not in discardedheads)
         if unsynced:
-            heads = ' '.join(short(h) for h in unsynced)
+            if len(unsynced) <= 4 or repo.ui.verbose:
+                heads = ' '.join(short(h) for h in unsynced)
+            else:
+                heads = (' '.join(short(h) for h in unsynced[:4]) +
+                         ' ' + _("and %s others") % (len(unsynced) - 4))
             if branch is None:
                 repo.ui.status(_("remote has heads that are "
                                  "not known locally: %s\n") % heads)
diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -378,7 +378,7 @@  Pushing multi headed new branch:
   added 3 changesets with 3 changes to 1 files (+1 heads)
 
 Checking prepush logic does not allow silently pushing
-multiple new heads:
+multiple new heads but also doesn't report too many heads:
 
   $ cd ..
   $ hg init h
@@ -404,10 +404,29 @@  multiple new heads:
   adding c
   created new head
 
+  $ for i in `seq 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
+
   $ hg -R i push h
   pushing to h
   searching for changes
-  remote has heads on branch 'default' that are not known locally: ce4212fc8847
+  remote has heads on branch 'default' that are not known locally: 534543e22c29 764f8ec07b96 afe7cc7679f5 ce4212fc8847
+  abort: push creates new remote head 97bd0c84d346!
+  (pull and merge or see "hg help push" for details about pushing new heads)
+  [255]
+  $ hg -R h up -q 0; echo x > h/b; hg -R h ci -qAmx
+  $ hg -R i push h
+  pushing to h
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: 18ddb72c4590 534543e22c29 764f8ec07b96 afe7cc7679f5 and 1 others
+  abort: push creates new remote head 97bd0c84d346!
+  (pull and merge or see "hg help push" for details about pushing new heads)
+  [255]
+  $ hg -R i push h -v
+  pushing to h
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: 18ddb72c4590 534543e22c29 764f8ec07b96 afe7cc7679f5 ce4212fc8847
+  new remote heads on branch 'default':
+   97bd0c84d346
   abort: push creates new remote head 97bd0c84d346!
   (pull and merge or see "hg help push" for details about pushing new heads)
   [255]