meld r1335 - in trunk: . vc



Author: vincele
Date: Sat Apr 11 22:30:33 2009
New Revision: 1335
URL: http://svn.gnome.org/viewvc/meld?rev=1335&view=rev

Log:
Remove the hardcoded default VC file filter, construct one
from the actually supported plugins metadata.

The misc.py shell_escape() function should be
implemented by python stdlib fnmatch module,
the current, incomplete, local version will do
until this goes upstream.


Modified:
   trunk/meldapp.py
   trunk/misc.py
   trunk/vc/__init__.py
   trunk/vc/_vc.py
   trunk/vc/monotone.py
   trunk/vc/tla.py

Modified: trunk/meldapp.py
==============================================================================
--- trunk/meldapp.py	(original)
+++ trunk/meldapp.py	Sat Apr 11 22:30:33 2009
@@ -36,6 +36,7 @@
 import vcview
 import dirdiff
 import task
+import vc
 
 from sourceviewer import srcviewer
 
@@ -404,7 +405,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

Modified: trunk/misc.py
==============================================================================
--- trunk/misc.py	(original)
+++ trunk/misc.py	Sat Apr 11 22:30:33 2009
@@ -285,6 +285,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.
 

Modified: trunk/vc/__init__.py
==============================================================================
--- trunk/vc/__init__.py	(original)
+++ trunk/vc/__init__.py	Sat Apr 11 22:30:33 2009
@@ -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 instantiated
+        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
     

Modified: trunk/vc/_vc.py
==============================================================================
--- trunk/vc/_vc.py	(original)
+++ trunk/vc/_vc.py	Sat Apr 11 22:30:33 2009
@@ -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)

Modified: trunk/vc/monotone.py
==============================================================================
--- trunk/vc/monotone.py	(original)
+++ trunk/vc/monotone.py	Sat Apr 11 22:30:33 2009
@@ -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}$"
 

Modified: trunk/vc/tla.py
==============================================================================
--- trunk/vc/tla.py	(original)
+++ trunk/vc/tla.py	Sat Apr 11 22:30:33 2009
@@ -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/(.*)"
 



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