[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH v2] Make display_lines output a diff

From: Ramkumar Ramachandra <artagnon_at_gmail.com>
Date: Sat, 24 Jul 2010 21:12:52 +0530

Hi,

Instead of spawning diff, I used difflib in Python. Here's the
result. I need a +1 to commit this since it's outside my area.

Thanks.

-- Ram

[[[
* subversion/tests/cmdline/svntest/verify.py (display_lines): Use
  Python difflib to output a context diff instead of printing actual
  and expected in full.
]]]

Index: subversion/tests/cmdline/svntest/verify.py
===================================================================
--- subversion/tests/cmdline/svntest/verify.py (revision 978817)
+++ subversion/tests/cmdline/svntest/verify.py (working copy)
@@ -25,6 +25,7 @@
 ######################################################################
 
 import re, sys
+from difflib import context_diff
 
 import svntest
 
@@ -276,21 +277,16 @@ def display_lines(message, label, expected, actual
   if message is not None:
     print(message)
   if expected is not None:
- output = 'EXPECTED %s' % label
+ output = 'DIFF %s' % label
     if expected_is_regexp:
       output += ' (regexp)'
     if expected_is_unordered:
       output += ' (unordered)'
     output += ':'
     print(output)
- for x in expected:
- sys.stdout.write(x)
- if expected_is_regexp:
- sys.stdout.write('\n')
- if actual is not None:
- print('ACTUAL %s:' % label)
- for x in actual:
- sys.stdout.write(x)
+ for x in context_diff(actual, expected, \
+ fromfile="ACTUAL", tofile="EXPECTED"):
+ sys.stdout.write(x)
 
 def compare_and_display_lines(message, label, expected, actual,
                               raisable=None):
Received on 2010-07-24 17:45:10 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.