Commits

Martin Geisler committed 44b4a2a Merge

Merge with default

Comments (0)

Files changed (5)

 
     # apply color to output and display it
     for i in xrange(len(lines)):
-        status = abbreviations[lines_with_status[i][0]]
-        effects = effectdefs[status]
-        if effects:
-            lines[i] = render_effects(lines[i], effects)
+        try:
+            status = abbreviations[lines_with_status[i][0]]
+        except KeyError:
+            # Ignore lines with invalid codes, especially in the case of
+            # of unknown filenames containing newlines (issue2036).
+            pass
+        else:
+            effects = effectdefs[status]
+            if effects:
+                lines[i] = render_effects(lines[i], effects)
         ui.write(lines[i] + delimiter)
     return retval
 

tests/test-eolfilename

+#!/bin/sh
+# http://mercurial.selenic.com/bts/issue352
+
+"$TESTDIR/hghave" eol-in-paths || exit 80
+
+echo % test issue352
+hg init foo
+cd foo
+
+A=`printf 'he\rllo'`
+
+echo foo > "$A"
+hg add
+hg ci -A -m m
+rm "$A"
+
+echo foo > "hell
+o"
+hg add
+hg ci -A -m m
+
+echo foo > "$A"
+hg debugwalk
+
+# http://mercurial.selenic.com/bts/issue2036
+cd ..
+echo % test issue2039
+
+hg init bar
+cd bar
+
+echo "[extensions]" >> $HGRCPATH
+echo "color=" >> $HGRCPATH
+
+A=`printf 'foo\nbar'`
+B=`printf 'foo\nbar.baz'`
+
+touch "$A"
+touch "$B"
+
+hg status --color=always
+
+exit 0

tests/test-eolfilename.out

+% test issue352
+adding he
+abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
+adding he
+abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
+adding hell
+o
+abort: '\n' and '\r' disallowed in filenames: 'hell\no'
+adding hell
+o
+abort: '\n' and '\r' disallowed in filenames: 'hell\no'
+f  he
+f  hell
+o  hell
+o
+% test issue2039
+? foo
+bar
+? foo
+bar.baz

tests/test-issue352

-#!/bin/sh
-# http://mercurial.selenic.com/bts/issue352
-
-"$TESTDIR/hghave" eol-in-paths || exit 80
-
-hg init foo
-cd foo
-
-A=`printf 'he\rllo'`
-
-echo foo > "$A"
-hg add
-hg ci -A -m m
-rm "$A"
-
-echo foo > "hell
-o"
-hg add
-hg ci -A -m m
-
-echo foo > "$A"
-hg debugwalk
-
-exit 0

tests/test-issue352.out

-adding he
-abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
-adding he
-abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
-adding hell
-o
-abort: '\n' and '\r' disallowed in filenames: 'hell\no'
-adding hell
-o
-abort: '\n' and '\r' disallowed in filenames: 'hell\no'
-f  he
-f  hell
-o  hell
-o