Patchwork [V2] filemerge: store error messages in module variables

login
register
mail settings
Submitter Stanislau Hlebik
Date May 19, 2017, 10:52 a.m.
Message ID <48651bcde6516d2bc075.1495191177@devvm1840.lla2.facebook.com>
Download mbox | patch
Permalink /patch/20708/
State Accepted
Headers show

Comments

Stanislau Hlebik - May 19, 2017, 10:52 a.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1495190863 25200
#      Fri May 19 03:47:43 2017 -0700
# Node ID 48651bcde6516d2bc075ce694a3d8b2fc0084e7b
# Parent  8a87bfc5bebbbe0ac996ac8e047a029eb931af45
filemerge: store error messages in module variables

Copytracing may be disabled because it's too slow (see
experimental.disablecopytrace config option). In that case user may get errors
like 'local changed FILE which other deleted'. It would be nice to give user a
hint to rerun command with `--config experimental.disablecopytrace=False`. To
make it possible let's extract error message to variables so that extension may
overwrite them.
Yuya Nishihara - May 19, 2017, 1:16 p.m.
On Fri, 19 May 2017 03:52:57 -0700, Stanislau Hlebik wrote:
> # HG changeset patch
> # User Stanislau Hlebik <stash@fb.com>
> # Date 1495190863 25200
> #      Fri May 19 03:47:43 2017 -0700
> # Node ID 48651bcde6516d2bc075ce694a3d8b2fc0084e7b
> # Parent  8a87bfc5bebbbe0ac996ac8e047a029eb931af45
> filemerge: store error messages in module variables

Seems fine. Queued, thanks.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -49,6 +49,17 @@ 
 mergeonly = 'mergeonly'  # just the full merge, no premerge
 fullmerge = 'fullmerge'  # both premerge and merge
 
+_localchangedotherdeletedmsg = _(
+    "local%(l)s changed %(fd)s which other%(o)s deleted\n"
+    "use (c)hanged version, (d)elete, or leave (u)nresolved?"
+    "$$ &Changed $$ &Delete $$ &Unresolved")
+
+_otherchangedlocaldeletedmsg = _(
+    "other%(o)s changed %(fd)s which local%(l)s deleted\n"
+    "use (c)hanged version, leave (d)eleted, or "
+    "leave (u)nresolved?"
+    "$$ &Changed $$ &Deleted $$ &Unresolved")
+
 class absentfilectx(object):
     """Represents a file that's ostensibly in a context but is actually not
     present in it.
@@ -250,16 +261,11 @@ 
     try:
         if fco.isabsent():
             index = ui.promptchoice(
-                _("local%(l)s changed %(fd)s which other%(o)s deleted\n"
-                  "use (c)hanged version, (d)elete, or leave (u)nresolved?"
-                  "$$ &Changed $$ &Delete $$ &Unresolved") % prompts, 2)
+                _localchangedotherdeletedmsg % prompts, 2)
             choice = ['local', 'other', 'unresolved'][index]
         elif fcd.isabsent():
             index = ui.promptchoice(
-                _("other%(o)s changed %(fd)s which local%(l)s deleted\n"
-                  "use (c)hanged version, leave (d)eleted, or "
-                  "leave (u)nresolved?"
-                  "$$ &Changed $$ &Deleted $$ &Unresolved") % prompts, 2)
+                _otherchangedlocaldeletedmsg % prompts, 2)
             choice = ['other', 'local', 'unresolved'][index]
         else:
             index = ui.promptchoice(