[meld] Fix scanning of entire VC repository for single-file diff



commit 4db76df0fb995b3b446386d3f7961a4030dd2764
Author: Peter Tyser <ptyser gmail com>
Date:   Sun Apr 25 12:50:03 2010 -0500

    Fix scanning of entire VC repository for single-file diff
    
    Previously, running meld on one file in a version-controlled directory
    would result in meld scanning the entire repository for modifications.
    The scanning of the entire repository was unnecessary and could hog
    system resources, especially on larger repositories.
    
    Signed-off-by: Peter Tyser <ptyser gmail com>

 meld/meldapp.py |    2 +-
 meld/vc/_vc.py  |   13 +++++++++----
 meld/vcview.py  |    6 +++++-
 3 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/meld/meldapp.py b/meld/meldapp.py
index b55afe4..148461e 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -915,7 +915,7 @@ class MeldApp(gnomeglade.Component):
             self.scheduler.remove_scheduler(doc.scheduler)
         self.scheduler.add_task(cleanup)
         self.scheduler.add_scheduler(doc.scheduler)
-        doc.set_location(os.path.dirname(path))
+        doc.set_location(path)
         doc.connect("create-diff", lambda obj,arg: self.append_diff(arg))
         doc.run_diff([path])
 
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index ba5d49e..413e072 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -76,15 +76,20 @@ class Vc(object):
     VC_METADATA = None
 
     def __init__(self, location):
-        # Save the requested diff directory.  It may be a sub-directory
+        # Save the requested diff directory/file.  It may be a sub-directory
         # of the repository we are diffing and can be useful in limiting meld's
-        # output to the requested location.
+        # output to the requested location.  It can also be used to determine
+        # if the user is requesting a single-file diff or a diretcory diff.
         self.location = location
 
+        if not os.path.isdir(location):
+            path = os.path.dirname(self.location)
+        else:
+            path = location
         if self.VC_ROOT_WALK:
-            self.root = self.find_repo_root(location)
+            self.root = self.find_repo_root(path)
         else:
-            self.root = self.check_repo_root(location)
+            self.root = self.check_repo_root(path)
 
     def commit_command(self, message):
         raise NotImplementedError()
diff --git a/meld/vcview.py b/meld/vcview.py
index 23002c2..9f93a91 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -262,7 +262,11 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self.model.set_state(it, 0, tree.STATE_NORMAL, isdir=1)
         self.recompute_label()
         self.scheduler.remove_all_tasks()
-        self.scheduler.add_task( self._search_recursively_iter(self.model.get_iter_root()).next )
+
+        # If the user is just diffing a file (ie not a directory), there's no
+        # need to scan the rest of the repository
+        if os.path.isdir(self.vc.location):
+            self.scheduler.add_task(self._search_recursively_iter(self.model.get_iter_root()).next)
 
     def recompute_label(self):
         self.label_text = os.path.basename(self.location)



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