Merge with stable
authorChristian Ebert <blacktrash@gmx.net>
Thu, 11 Oct 2012 19:46:25 +0200
changeset 1140 689f8b6b711c
parent 1137 2d9daef1e473 (current diff)
parent 1139 cdabdd17f980 (diff)
child 1141 4e2090ed2e72
Merge with stable
--- a/tests/run-tests.py	Wed Oct 10 11:31:01 2012 +0200
+++ b/tests/run-tests.py	Thu Oct 11 19:46:25 2012 +0200
@@ -283,21 +283,6 @@
     shutil.copy(src, dst)
     os.remove(src)
 
-def splitnewlines(text):
-    '''like str.splitlines, but only split on newlines.
-    keep line endings.'''
-    i = 0
-    lines = []
-    while True:
-        n = text.find('\n', i)
-        if n == -1:
-            last = text[i:]
-            if last:
-                lines.append(last)
-            return lines
-        lines.append(text[i:n + 1])
-        i = n + 1
-
 def parsehghaveoutput(lines):
     '''Parse hghave log lines.
     Return tuple of lists (missing, failed):
@@ -690,8 +675,7 @@
             lout, lcmd = l.split(salt, 1)
 
         if lout:
-            if lcmd:
-                # output block had no trailing newline, clean up
+            if not lout.endswith('\n'):
                 lout += ' (no-eol)\n'
 
             # find the expected output at the current position
@@ -762,7 +746,7 @@
 
     for s, r in replacements:
         output = re.sub(s, r, output)
-    return ret, splitnewlines(output)
+    return ret, output.splitlines(True)
 
 def runone(options, test):
     '''tristate output:
@@ -925,7 +909,7 @@
         refout = None                   # to match "out is None"
     elif os.path.exists(ref):
         f = open(ref, "r")
-        refout = list(splitnewlines(f.read()))
+        refout = f.read().splitlines(True)
         f.close()
     else:
         refout = []