Re: [PATCH] Construct VC directory filter for supported plugins



> Here we are, added assertion about unhandled cases.
> I still think this belongs to (in order) fnmatch > misc > meldapp

And with the patch...

-- 
Vincent Legoll
Index: misc.py
===================================================================
--- misc.py	(revision 1322)
+++ misc.py	(working copy)
@@ -300,6 +300,11 @@
         else:
             copy2(srcname, dstname)
 
+def shell_escape(glob_pat):
+    # TODO: handle all cases
+    assert not re.compile(r"[][*?]").findall(glob_pat)
+    return glob_pat.replace('{', '[{]').replace('}', '[}]')
+
 def shell_to_regex(pat):
     """Translate a shell PATTERN to a regular expression.
 
Index: vc/monotone.py
===================================================================
--- vc/monotone.py	(revision 1322)
+++ vc/monotone.py	(working copy)
@@ -29,6 +29,7 @@
 class Vc(_vc.Vc):
     CMD = "mtn"
     NAME = "Monotone"
+    VC_METADATA = ['MT', '_MTN']
     PATCH_STRIP_NUM = 0
     PATCH_INDEX_RE = "^[+]{3,3} ([^  ]*)\t[0-9a-f]{40,40}$"
 
Index: vc/__init__.py
===================================================================
--- vc/__init__.py	(revision 1322)
+++ vc/__init__.py	(working copy)
@@ -34,6 +34,17 @@
     return ret
 _plugins = load_plugins()
 
+def get_plugins_metadata():
+    ret = []
+    for p in _plugins:
+        # Some plugins have VC_DIR=None until instanciated
+        if p.Vc.VC_DIR:
+            ret.append(p.Vc.VC_DIR)
+        # Most plugins have VC_METADATA=None
+        if p.Vc.VC_METADATA:
+            ret.extend(p.Vc.VC_METADATA)
+    return ret
+
 def get_vcs(location):
     """Pick only the Vcs with the longest repo root
     
Index: vc/_vc.py
===================================================================
--- vc/_vc.py	(revision 1322)
+++ vc/_vc.py	(working copy)
@@ -71,6 +71,7 @@
     PATCH_STRIP_NUM = 0
     PATCH_INDEX_RE = ''
     VC_DIR = None
+    VC_METADATA = None
 
     def __init__(self, location):
         self.root = self.find_repo_root(location)
Index: vc/tla.py
===================================================================
--- vc/tla.py	(revision 1322)
+++ vc/tla.py	(working copy)
@@ -62,6 +62,7 @@
     CMD = "tla"
     NAME = "Arch"
     VC_DIR = "{arch}"
+    VC_METADATA = ['.arch-ids', '.arch-inventory']
     PATCH_STRIP_NUM = 1
     PATCH_INDEX_RE = "--- orig/(.*)"
 
Index: meldapp.py
===================================================================
--- meldapp.py	(revision 1322)
+++ meldapp.py	(working copy)
@@ -36,6 +36,7 @@
 import vcview
 import dirdiff
 import task
+import vc
 
 # optional
 sourceview_available = 0
@@ -413,7 +414,7 @@
             #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact
             _("Backups\t1\t#*# .#* ~* *~ *.{orig,bak,swp}\n") + \
             #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact
-            _("Version Control\t1\tCVS .svn MT [{]arch[}] .arch-ids .arch-inventory RCS\n") + \
+            _("Version Control\t1\t%s\n") % misc.shell_escape(' '.join(vc.get_plugins_metadata())) + \
             #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact
             _("Binaries\t1\t*.{pyc,a,obj,o,so,la,lib,dll}\n") + \
             #TRANSLATORS: translate this string ONLY to the first "\t", leave it and the following parts intact


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