meld r1159 - trunk/vc



Author: vincele
Date: Mon Feb 23 21:49:14 2009
New Revision: 1159
URL: http://svn.gnome.org/viewvc/meld?rev=1159&view=rev

Log:
Noop: preparation for multiple VC in a single directory handling

This patch only move the code that picks a VC plugin when there
are multiple ones that can handle a directory. This is a preparatory
step for a GUI chooser that let the user decide which one he wants
to use.


Modified:
   trunk/vc/__init__.py

Modified: trunk/vc/__init__.py
==============================================================================
--- trunk/vc/__init__.py	(original)
+++ trunk/vc/__init__.py	Mon Feb 23 21:49:14 2009
@@ -34,7 +34,11 @@
     return ret
 _plugins = load_plugins()
 
-def Vc(location):
+def default_plugin_order(vcs):
+    # Pick the Vc with the longest repo root
+    return max(vcs, key=lambda repo: len(repo.root))
+
+def Vc(location, ordering_func = default_plugin_order):
     vcs = []
     for plugin in _plugins:
         try:
@@ -43,7 +47,13 @@
             pass
 
     if not vcs:
-        return _null.Vc(location)
+        # No plugin recognized that location, fallback to _null
+        vc = _null.Vc(location)
+    elif len(vcs) == 1:
+        # No need to launch a potentially GUI/interactive chooser
+        vc = vcs[0]
+    else:
+        # User gets to pick one, eventually
+        vc = ordering_func(vcs)
 
-    #Pick the Vc with the longest repo root
-    return max(vcs, key=lambda repo: len(repo.root))
+    return vc



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