Browse Source

Add support for Subversion

Steven Myint 11 years ago
parent
commit
cbf54f3e06
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/cdiff.py

+ 9
- 1
src/cdiff.py View File

@@ -472,10 +472,18 @@ def markup_to_pager(stream):
472 472
     pager.wait()
473 473
 
474 474
 
475
+def check_command_status(arguments):
476
+    """Return True if command returns 0."""
477
+    return subprocess.call(
478
+        arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
479
+
480
+
475 481
 def revision_control_diff(path):
476 482
     """Return diff from revision control system."""
477
-    if subprocess.call(['git', 'rev-parse'], stderr=subprocess.PIPE) == 0:
483
+    if check_command_status(['git', 'rev-parse']):
478 484
         return subprocess.Popen(['git', 'diff'], stdout=subprocess.PIPE).stdout
485
+    elif check_command_status(['svn', 'info']):
486
+        return subprocess.Popen(['svn', 'diff'], stdout=subprocess.PIPE).stdout
479 487
 
480 488
 
481 489
 def decode(line):