D371: simplemerge: extract verifytext as a helper function

2017-08-15 Thread phillco (Phil Cohen)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGde573184686e: simplemerge: extract verifytext as a helper 
function (authored by phillco).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D371?vs=852&id=953

REVISION DETAIL
  https://phab.mercurial-scm.org/D371

AFFECTED FILES
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -397,18 +397,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':



To: phillco, #hg-reviewers, smf
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D371: simplemerge: extract verifytext as a helper function

2017-08-13 Thread phillco (Phil Cohen)
phillco added a comment.


  This stack isn't particular complicated; it's just that changing simplemerge 
to go from files to contexts, with small commits and working intermediate 
commits, requires some jumping around.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D371

To: phillco, #hg-reviewers, smf
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D371: simplemerge: extract verifytext as a helper function

2017-08-13 Thread phillco (Phil Cohen)
phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will be used in a subsequent commit.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D371

AFFECTED FILES
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -397,18 +397,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':



To: phillco, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel