Skip to content
Snippets Groups Projects
Commit 91cb08a9 authored by Adrian Buehlmann's avatar Adrian Buehlmann
Browse files

discovery: list new remote heads in prepush() on --debug

With this patch applied, Mercurial will list the hashes of new remote heads
if push --debug aborts because of new remote heads (option -f/--force not set).

Example:

  $ hg push --debug repo1
  using http://example.org/repo1
  http auth: user johndoe, password not set
  sending between command
  pushing to http://example.org/repo1
  sending capabilities command
  capabilities: changegroupsubset stream=1 lookup pushkey unbundle=HG10GZ,HG10BZ,HG10UN branchmap
  sending heads command
  searching for changes
  common changesets up to 609edbc7853f
  sending branchmap command
  new remote heads on branch 'default'        <- new output line
  new remote head 5862c07f53a2                <- new output line
  abort: push creates new remote heads on branch 'default'!
  (did you forget to merge? use push -f to force)

Compare to without --debug (not changed by this patch, including it here
for reference purposes only):

  $ hg push repo1
  pushing to http://example.org/repo1
  searching for changes
  abort: push creates new remote heads on branch 'default'!
  (did you forget to merge? use push -f to force)

Motivation for this change:

'hg outgoing' may list a whole lot of benign changesets plus an odd changeset
that will trigger the "new remote heads" abort. It can be hard to spot that
single unwanted changeset (it may be an old forgotten experiment, lingering
in the local repo).

"hg log -r 'heads(outgoing())'" might be useful, but that also lists a head
that may be benign on push.

Inside prepush(), we already know which heads are causing troubles on 'hg push'.
Why not make that info available (at least on --debug)?

This would also be helpful for doing remote support, as the supporter can ask
the user to paste the output of 'hg push --debug' on error and then ask further
questions about the heads listed.
parent a5060632
No related branches found
No related tags found
No related merge requests found
......@@ -278,5 +278,6 @@
# 5. Check for new heads.
# If there are more heads after the push than before, a suitable
# warning, depending on unsynced status, is displayed.
# error message, depending on unsynced status, is displayed.
error = None
for branch in branches:
......@@ -282,3 +283,17 @@
for branch in branches:
if len(newmap[branch]) > len(oldmap[branch]):
newhs = set(newmap[branch])
oldhs = set(oldmap[branch])
if len(newhs) > len(oldhs):
if error is None:
if branch:
error = _("push creates new remote heads "
"on branch '%s'!") % branch
else:
error = _("push creates new remote heads!")
if branch in unsynced:
hint = _("you should pull and merge or "
"use push -f to force")
else:
hint = _("did you forget to merge? "
"use push -f to force")
if branch:
......@@ -284,14 +299,9 @@
if branch:
msg = _("push creates new remote heads "
"on branch '%s'!") % branch
else:
msg = _("push creates new remote heads!")
if branch in unsynced:
hint = _("you should pull and merge or use push -f to force")
else:
hint = _("did you forget to merge? use push -f to force")
raise util.Abort(msg, hint=hint)
repo.ui.debug("new remote heads on branch '%s'\n" % branch)
for h in (newhs - oldhs):
repo.ui.debug("new remote head %s\n" % short(h))
if error:
raise util.Abort(error, hint=hint)
# 6. Check for unsynced changes on involved branches.
if unsynced:
......
......@@ -30,6 +30,23 @@
(you should pull and merge or use push -f to force)
[255]
$ hg push --debug ../a
pushing to ../a
searching for changes
examining 1c9246a22a0a:d8d565842d04
found incomplete branch 1c9246a22a0a:d8d565842d04
searching: 1 queries
narrowing 1:1 d8d565842d04
found new branch changeset 1c9246a22a0a
found new changesets starting at 1c9246a22a0a
1 total queries
common changesets up to d8d565842d04
new remote heads on branch 'default'
new remote head 1e108cc5548c
abort: push creates new remote heads on branch 'default'!
(you should pull and merge or use push -f to force)
[255]
$ hg pull ../a
pulling from ../a
searching for changes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment