Commits

Martin Scharrer committed 54ce890

Added Filter module.

  • Participants
  • Parent commits 7e196b2

Comments (0)

Files changed (1)

File py/SvnDumpLoad/Filter.py

+"""
+    Filter dumpfiles
+"""
+
+
+class Filter(object):
+    """ Base class for a SVN dumpfile filter. """
+
+    def filter_revision(self, revisionrecord):
+        pass
+
+    def filter_node(self, noderecord):
+        pass
+
+    def filter_version(self, versionrecord):
+        pass
+
+    def filter_uuid(self, uuidrecord):
+        pass
+
+    def filter_record(self, record):
+        pass
+
+
+
+class RenameAuthorFilter(Filter):
+
+    def __init__(self, oldname, newname):
+        self._oldname = oldname
+        self._newname = newname
+
+    def filter_revision(self, revisionrecord):
+        if (revisionrecord.get_author() == self._oldname):
+            revisionrecord.set_author(self._newname)
+
+
+class RemovePathFilter(Filter):
+
+    def __init__(self, filepath):
+        self._filepath = filepath
+
+    def check_path(self, filepath):
+        return self._filepath == filepath:
+
+    def filter_node(self, noderecord):
+        if (check_path(revisionrecord.get_path())):
+            return True
+
+
+class RemovePathByRegexFilter(RemovePathFilter):
+
+    def __init__(self, filepathregex):
+        import re
+        self._filepathregex = re.compile(filepathregex)
+
+    def check_path(self, filepath):
+        return self._filepathregex.search(filepath) is not None
+
+
+
+