Patchwork [2,of,3,RFC] import: if --exact fails, suggest importing without --exact

login
register
mail settings
Submitter Augie Fackler
Date March 11, 2016, 6:25 p.m.
Message ID <602504c64084d85820c8.1457720749@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/13807/
State Accepted
Headers show

Comments

Augie Fackler - March 11, 2016, 6:25 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1457538538 18000
#      Wed Mar 09 10:48:58 2016 -0500
# Node ID 602504c64084d85820c883a43b02951a61e992f5
# Parent  288dbf95fd9eb74148d0d94f0b7a05a4d3d7b50d
# EXP-Topic import
import: if --exact fails, suggest importing without --exact

I've heard enough reports that users get confused by this that adding
a hint here seems prudent. I'm not in love with the specific hint, but
it seems like a slight improvement over the status quo.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1041,7 +1041,9 @@  def tryimportone(ui, repo, hunk, parents
             # and branch bits
             ui.warn(_("warning: can't check exact import with --no-commit\n"))
         elif opts.get('exact') and hex(n) != nodeid:
-            raise error.Abort(_('patch is damaged or loses information'))
+            raise error.Abort(_('patch is damaged or loses information'),
+                              hint=_('try again without --exact, as the data'
+                                     ' loss may be minor'))
         msg = _('applied to working directory')
         if n:
             # i18n: refers to a short changeset id
diff --git a/tests/test-import-merge.t b/tests/test-import-merge.t
--- a/tests/test-import-merge.t
+++ b/tests/test-import-merge.t
@@ -156,6 +156,7 @@  Test that --exact on a bad header doesn'
   transaction abort!
   rollback completed
   abort: patch is damaged or loses information
+  (try again without --exact, as the data loss may be minor)
   [255]
   $ hg verify
   checking changesets