[meld/VersionControlRework: 49/123] vc._vc: Make lookup_files require its directory argument



commit 6c0cdf07806c71c05d5238bea8f03a335f262050
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Mar 29 10:36:51 2015 +1000

    vc._vc: Make lookup_files require its directory argument
    
    The directory argument is trivial to identify in all cases anyway, and
    this allows other simplifications.

 meld/vc/_vc.py |   15 ++++++---------
 meld/vcview.py |    3 ++-
 2 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 3c96c39..65cf7ae 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -207,7 +207,7 @@ class Vc(object):
         dirs, files = self.lookup_files(cdirs, cfiles, path)
         return dirs + files
 
-    def lookup_files(self, dirs, files, directory=None):
+    def lookup_files(self, dirs, files, directory):
         # Assumes that all files are in the same directory. files is an array
         # of (name, path) tuples.
         if len(dirs):
@@ -248,15 +248,12 @@ class Vc(object):
         If the given path does not correspond to any entry in the VC, this
         method returns return None.
         """
-        vc_files = [
-            x for x in
-            self.lookup_files(
-                [], [(os.path.basename(path), path)])[1]
-            if x.path == path
-        ]
-        if not vc_files:
+        vc_files = self.lookup_files(
+            [], [(os.path.basename(path), path)], os.path.dirname(path))
+        vc_file = [x for x in vc_files[1] if x.path == path]
+        if not vc_file:
             return None
-        return vc_files[0]
+        return vc_file[0]
 
     @classmethod
     def is_installed(cls):
diff --git a/meld/vcview.py b/meld/vcview.py
index c3a28ae..6b7bd7d 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -820,7 +820,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         if it:
             path = self.model.value_path(it, 0)
             self.vc.update_file_state(path)
-            files = self.vc.lookup_files([], [(os.path.basename(path), path)])[1]
+            files = self.vc.lookup_files(
+                [], [(os.path.basename(path), path)], os.path.dirname(path))[1]
             for e in files:
                 if e.path == path:
                     prefixlen = 1 + len( self.model.value_path( self.model.get_iter_first(), 0 ) )


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