Submitter | Stephen Lee |
---|---|
Date | Nov. 11, 2013, 10:53 a.m. |
Message ID | <fdb1232d9c82b0d6d9c1.1384167187@slee-desktop> |
Download | mbox | patch |
Permalink | /patch/2902/ |
State | Superseded |
Headers | show |
Comments
On Mon, 2013-11-11 at 21:53 +1100, Stephen Lee wrote: > # HG changeset patch > # User Stephen Lee <sphen.lee@gmail.com> > # Date 1384165016 -39600 > # Mon Nov 11 21:16:56 2013 +1100 > # Node ID fdb1232d9c82b0d6d9c10bb47c2e7bfb7b9be7c6 > # Parent 59a82b3476c080cf969711190e2afdc6f79432db > bookmarks: suggest 'push -B FOO' when a potentially new remote head has a local bookmark This one's a little worrisome. There's a non-trivial fraction of users who look like this: http://bit.ly/1kqMrE6 > + abort: push creates new remote head c922c0139ca0 with bookmark 'Y' > + (use push -B Y to push this bookmark) ..and will immediately type that command without trying to understand why what they just did might even be considered an error. We have lots of experience with people blindly using --force this way when we used to suggest it. This will be especially awesome in places where bookmarks and multiple heads on the server are not part of the corporate workflow but $USER found instructions that told them to use bookmarks on StackOverflow. Then we have their admins showing up on IRC asking how to fix the resulting mess and I will direct them to their nearest retailer of 2x4s. However, I -do- like the part where you report the bookmark on the new head. Please send that as a patch on its own, please.
On Sat, Dec 21, 2013 at 7:34 AM, Matt Mackall <mpm@selenic.com> wrote: > On Mon, 2013-11-11 at 21:53 +1100, Stephen Lee wrote: >> # HG changeset patch >> # User Stephen Lee <sphen.lee@gmail.com> >> # Date 1384165016 -39600 >> # Mon Nov 11 21:16:56 2013 +1100 >> # Node ID fdb1232d9c82b0d6d9c10bb47c2e7bfb7b9be7c6 >> # Parent 59a82b3476c080cf969711190e2afdc6f79432db >> bookmarks: suggest 'push -B FOO' when a potentially new remote head has a local bookmark > > This one's a little worrisome. There's a non-trivial fraction of users > who look like this: > > http://bit.ly/1kqMrE6 > >> + abort: push creates new remote head c922c0139ca0 with bookmark 'Y' >> + (use push -B Y to push this bookmark) > > ..and will immediately type that command without trying to understand > why what they just did might even be considered an error. We have lots > of experience with people blindly using --force this way when we used to > suggest it. I actually dropped this patch when Sean asked me to resend after the last sprint for exactly that reason. This was just after the hint that suggested --force was removed. > > However, I -do- like the part where you report the bookmark on the new > head. Please send that as a patch on its own, please. > So the hint should match the other push cases (see hg help push)? I will prepare a patch tonight from home. Steve
Patch
diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -327,20 +327,26 @@ dhs = sorted(newhs - bookmarkedheads - oldhs) if dhs: if error is None: - if branch not in ('default', None): + if repo[dhs[0]].bookmarks(): + bm = repo[dhs[0]].bookmarks()[0] error = _("push creates new remote head %s " - "on branch '%s'!") % (short(dhs[0]), branch) + "with bookmark '%s'") % (short(dhs[0]), bm) + hint = _("use push -B %s to push this bookmark") % bm else: - error = _("push creates new remote head %s!" - ) % short(dhs[0]) - if heads[2]: # unsynced - hint = _("pull and merge or" - " see \"hg help push\" for details about" - " pushing new heads") - else: - hint = _("merge or" - " see \"hg help push\" for details about" - " pushing new heads") + if branch not in ('default', None): + error = _("push creates new remote head %s " + "on branch '%s'!") % (short(dhs[0]), branch) + else: + error = _("push creates new remote head %s!" + ) % short(dhs[0]) + if heads[2]: # unsynced + hint = _("pull and merge or" + " see \"hg help push\" for details about" + " pushing new heads") + else: + hint = _("merge or" + " see \"hg help push\" for details about" + " pushing new heads") if branch is not None: repo.ui.note(_("new remote heads on branch '%s'\n") % branch) for h in dhs: 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,8 +274,8 @@ $ hg push http://localhost:$HGPORT2/ pushing to http://localhost:$HGPORT2/ searching for changes - abort: push creates new remote head c922c0139ca0! - (merge or see "hg help push" for details about pushing new heads) + abort: push creates new remote head c922c0139ca0 with bookmark 'Y' + (use push -B Y to push this bookmark) [255] $ hg -R ../a book @ 1:0d2164f0ce0d @@ -290,8 +290,8 @@ $ hg push http://localhost:$HGPORT2/ pushing to http://localhost:$HGPORT2/ searching for changes - abort: push creates new remote head c922c0139ca0! - (merge or see "hg help push" for details about pushing new heads) + abort: push creates new remote head c922c0139ca0 with bookmark 'Y' + (use push -B Y to push this bookmark) [255] $ hg -R ../a book @ 1:0d2164f0ce0d @@ -431,6 +431,12 @@ $ echo c5 > f2 $ hg ci -Am5 created new head + $ hg push + pushing to http://localhost:$HGPORT/ + searching for changes + abort: push creates new remote head cc978a373a53 with bookmark 'W' + (use push -B W to push this bookmark) + [255] $ hg push -B W pushing to http://localhost:$HGPORT/ searching for changes