Patchwork [1,of,5] simplemerge: extract verifytext as a helper function

login
register
mail settings
Submitter Phillip Cohen
Date Jan. 1, 1970, 12:03 a.m.
Message ID <c33a1225fcbc5cc2c133.191@phillco-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/21948/
State Superseded
Headers show

Comments

Phillip Cohen - Jan. 1, 1970, 12:03 a.m.
# HG changeset patch
# User Phil Cohen <phillco@fb.com>
# Date 200 28800
#      Wed Dec 31 16:03:20 1969 -0800
# Node ID c33a1225fcbc5cc2c13391fe4f72d329abbe6129
# Parent  016ce3d8fee0968dd30894bf78c3812a19a240d9
simplemerge: extract verifytext as a helper function

This will be used in a subsequent commit.
Yuya Nishihara - July 4, 2017, 2:31 p.m.
On Wed, 31 Dec 1969 16:03:11 -0800, Phil Cohen wrote:
> # HG changeset patch
> # User Phil Cohen <phillco@fb.com>
> # Date 200 28800
> #      Wed Dec 31 16:03:20 1969 -0800

An email from history. :)
Can you resend updated version so people won't miss this series? (or was
this a bug of scripting?)
Phillip Cohen - July 4, 2017, 7:46 p.m.
My fault :) I'll resend it.

On Tue, Jul 4, 2017 at 7:31 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Wed, 31 Dec 1969 16:03:11 -0800, Phil Cohen wrote:
>> # HG changeset patch
>> # User Phil Cohen <phillco@fb.com>
>> # Date 200 28800
>> #      Wed Dec 31 16:03:20 1969 -0800
>
> An email from history. :)
> Can you resend updated version so people won't miss this series? (or was
> this a bug of scripting?)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -396,18 +396,23 @@ 
 
         return unc
 
+def _verifytext(text, path, ui, opts):
+    """verifies that text is non-binary (unless opts[text] is passed,
+    then we just warn)"""
+    if util.binary(text):
+        msg = _("%s looks like a binary file.") % path
+        if not opts.get('quiet'):
+            ui.warn(_('warning: %s\n') % msg)
+        if not opts.get('text'):
+            raise error.Abort(msg)
+    return text
+
 def simplemerge(ui, local, base, other, **opts):
     def readfile(filename):
         f = open(filename, "rb")
         text = f.read()
         f.close()
-        if util.binary(text):
-            msg = _("%s looks like a binary file.") % filename
-            if not opts.get('quiet'):
-                ui.warn(_('warning: %s\n') % msg)
-            if not opts.get('text'):
-                raise error.Abort(msg)
-        return text
+        return _verifytext(text, filename, ui, opts)
 
     mode = opts.get('mode','merge')
     if mode == 'union':