Re: meld shows modified files with cvsnt, but won't compare



On Fri, Apr 3, 2009 at 9:44 AM, Stephen Kennedy <stevek gnome org> wrote:
> On Fri, Apr 3, 2009 at 7:35 AM, Steve Franks <bahamasfranks gmail com> wrote:
>>>> It tries to execute "cvs -v" and the "cvsnt -v" and then use the
>>>> first one that can be executed.
>
> This should work if we just swap the search order.

Like the attached, which fixes other bugs:
- "w+b" for devnull open
- devnull for stdin
- wait() instead of communicate()
- return instead of break in the loop

-- 
Vincent Legoll
Index: vc/cvs.py
===================================================================
--- vc/cvs.py	(revision 1322)
+++ vc/cvs.py	(working copy)
@@ -26,11 +26,11 @@
 import re
 import time
 import misc
+import subprocess
 import _vc
 
-
 class Vc(_vc.Vc):
-    CMD = "cvs"
+    CMDS = ["cvsnt", "cvs"]
     NAME = "CVS"
     VC_DIR = "CVS"
     PATCH_INDEX_RE = "^Index:(.*)$"
@@ -38,8 +38,22 @@
     def __init__(self, location):
         if not os.path.isdir(os.path.join(location, self.VC_DIR)):
             raise ValueError
+        self._set_cmd()
         self.root = location
 
+    def _set_cmd(self):
+        devnull = open(os.devnull, 'w+b')
+        for cmd in self.CMDS:
+            try:
+                subprocess.Popen([cmd, '-v'], stdin = devnull, stdout = devnull,
+                                 stderr = devnull).wait()
+                self.CMD = cmd
+                return
+            except OSError:
+                pass
+        print "Cannot execute any of the following commands: " + " ".join(self.CMDS)
+        raise ValueError
+
     def commit_command(self, message):
         return [self.CMD,"commit","-m",message]
     def diff_command(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]