Patchwork [05,of,14,"] pull: improved message issued in case of failed update

login
register
mail settings
Submitter Pierre-Yves David
Date April 13, 2019, 11:40 p.m.
Message ID <c69f95648b63e2ff430e.1555198835@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39597/
State Accepted
Headers show

Comments

Pierre-Yves David - April 13, 2019, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1554467733 -7200
#      Fri Apr 05 14:35:33 2019 +0200
# Node ID c69f95648b63e2ff430ed3650bface987908d5fb
# Parent  0adcfded9b03fff84190594ef29e37110967419f
# EXP-Topic hgweb-obsolete
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c69f95648b63
pull: improved message issued in case of failed update

When running `hg pull --update`, the update step may fail. Nothing in the error
message help to understand the abort is related to the secondary step (update)
instead of the primary step (pull).

We now add some information to the error message to clarify it comes from the
update part. It is useful in various situation (uncommitted changes blocking the
update, update to hidden destination, etc...)

The pull output is updated from:

  $ hg pull ../repo-Bob --rev 956063ac4557 --update
  pulling from ../repo-Bob
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 0 changes to 2 files (+1 heads)
  (2 other changesets obsolete on arrival)
  abort: filtered revision '6'!

to:

  $ hg pull ../repo-Bob --rev 956063ac4557 --update
  pulling from ../repo-Bob
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 0 changes to 2 files (+1 heads)
  (2 other changesets obsolete on arrival)
  abort: cannot update to target: filtered revision '6'!

(I am not sure why the actual error, "filtered revision '6'", is not using the
more modern format mentioning the obsolescence fate of '6')

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4503,7 +4503,10 @@  def pull(ui, repo, source="default", **o
             try:
                 ret = postincoming(ui, repo, modheads, opts.get('update'),
                                    checkout, brev)
-
+            except error.FilteredRepoLookupError as exc:
+                msg = _('cannot update to target: %s') % exc.args[0]
+                exc.args = (msg,) + exc.args[1:]
+                raise
             finally:
                 del repo._subtoppath
 
diff --git a/tests/test-obsolete-distributed.t b/tests/test-obsolete-distributed.t
--- a/tests/test-obsolete-distributed.t
+++ b/tests/test-obsolete-distributed.t
@@ -504,6 +504,21 @@  X` has to process a X that is filtered l
   (2 other changesets obsolete on arrival)
   (run 'hg heads' to see heads)
 
+With --update
+
+  $ hg rollback
+  repository tip rolled back to revision 4 (undo pull)
+  $ hg pull ../repo-Bob --rev 956063ac4557 --update
+  pulling from ../repo-Bob
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 0 changes to 2 files (+1 heads)
+  (2 other changesets obsolete on arrival)
+  abort: cannot update to target: filtered revision '6'!
+  [255]
+
   $ cd ..
 
 Test pull report consistency