simplemerge: use ui.warn() for warnings
authorSteve Borho <steve@borho.org>
Thu, 30 Apr 2009 23:57:36 -0500
changeset 8269 bb9f13974d8e
parent 8265 52c5be55af82
child 8270 3477ad0b1f2c
simplemerge: use ui.warn() for warnings
contrib/simplemerge
mercurial/filemerge.py
mercurial/simplemerge.py
--- a/contrib/simplemerge	Thu Apr 30 19:22:06 2009 -0500
+++ b/contrib/simplemerge	Thu Apr 30 23:57:36 2009 -0500
@@ -5,7 +5,7 @@
 
 import os, sys
 from mercurial.i18n import _
-from mercurial import simplemerge, fancyopts, util
+from mercurial import simplemerge, fancyopts, util, ui
 
 options = [('L', 'label', [], _('labels to use on conflict markers')),
            ('a', 'text', None, _('treat all files as text')),
@@ -55,7 +55,7 @@
         sys.exit(0)
     if len(args) != 3:
             raise ParseError(_('wrong number of arguments'))
-    sys.exit(simplemerge.simplemerge(*args, **opts))
+    sys.exit(simplemerge.simplemerge(ui.ui(), *args, **opts))
 except ParseError, e:
     sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
     showhelp()
--- a/mercurial/filemerge.py	Thu Apr 30 19:22:06 2009 -0500
+++ b/mercurial/filemerge.py	Thu Apr 30 23:57:36 2009 -0500
@@ -170,7 +170,7 @@
 
     # do we attempt to simplemerge first?
     if _toolbool(ui, tool, "premerge", not (binary or symlink)):
-        r = simplemerge.simplemerge(a, b, c, quiet=True)
+        r = simplemerge.simplemerge(ui, a, b, c, quiet=True)
         if not r:
             ui.debug(_(" premerge successful\n"))
             os.unlink(back)
@@ -187,7 +187,7 @@
                HG_BASE_ISLINK='l' in fca.flags())
 
     if tool == "internal:merge":
-        r = simplemerge.simplemerge(a, b, c, label=['local', 'other'])
+        r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other'])
     else:
         args = _toolstr(ui, tool, "args", '$local $base $other')
         if "$output" in args:
--- a/mercurial/simplemerge.py	Thu Apr 30 19:22:06 2009 -0500
+++ b/mercurial/simplemerge.py	Thu Apr 30 23:57:36 2009 -0500
@@ -24,11 +24,6 @@
 class CantReprocessAndShowBase(Exception):
     pass
 
-def warn(message):
-    sys.stdout.flush()
-    sys.stderr.write(message)
-    sys.stderr.flush()
-
 def intersect(ra, rb):
     """Given two ranges return the range where they intersect or None.
 
@@ -405,7 +400,7 @@
 
         return unc
 
-def simplemerge(local, base, other, **opts):
+def simplemerge(ui, local, base, other, **opts):
     def readfile(filename):
         f = open(filename, "rb")
         text = f.read()
@@ -415,7 +410,7 @@
             if not opts.get('text'):
                 raise util.Abort(msg)
             elif not opts.get('quiet'):
-                warn(_('warning: %s\n') % msg)
+                ui.warn(_('warning: %s\n') % msg)
         return text
 
     name_a = local
@@ -451,5 +446,5 @@
 
     if m3.conflicts:
         if not opts.get('quiet'):
-            warn(_("warning: conflicts during merge.\n"))
+            ui.warn(_("warning: conflicts during merge.\n"))
         return 1