From c8995e48d6d61e3286db579d594b9b9df33619ce Mon Sep 17 00:00:00 2001
From: mhagger
Note: If you want to customize your conversion +using your own Python classes, these classes must be defined in a +separate Python file then imported into the options file. +See the FAQ for more details.
+It is possible to customize your conversion using arbitrary + Python code. Sometimes this requires you to define your own + Python class. For technical reasons, such classes should not be + defined within the options file but rather in a separate file that + is imported into the options file.
+ +[Technical explanation: The problem is that class instances used + in run_options are pickled in pass1 then unpickled in + later passes. (Pickling is a Python mechanism for storing objects + to a file.) But class instances can only be unpickled if the + class can be imported at the time of unpickling. This, in turns, + requires the class to be defined at the top level of a Python + module. The options file is not a valid Python module; + among other things, it is loaded using execfile(), not by being + imported.]
+ +So create a separate file with a *.py filename, + like myoptionsclasses.py. In that file, do any imports + needed by your code, then define your class:
+ ++from cvs2svn_lib.symbol_transform import SymbolTransform + +class MySymbolTransform(SymbolTransform): + def transform(self, cvs_file, symbol_name, revision): + [...] ++ +
Then, in your main options file, import the class and use it:
+ ++from myoptionsclasses import MySymbolTransform + +run_options.add_project( + [...] + symbol_transforms=[ + MySymbolTransform(), + ... + ]) ++ +
See the file cvs2svn_lib/property_setters.py for more - examples.
+Please note that the class must be + defined in a separate file.
+ +See the file cvs2svn_lib/property_setters.py for many + examples of property setters.
To use this feature, you will have to use an options file to start - the conversion. You then write a new SymbolTransform class that - inherits from RegexpSymbolTransform but checks the path before - deciding whether to transform the symbol. Add the following to - your options file:
+To use this feature, you will have to use + an options file to + start the conversion. You then write a new SymbolTransform class + that inherits from RegexpSymbolTransform but checks the path + before deciding whether to transform the symbol. You can do + something like the following:
from cvs2svn_lib.symbol_transform import RegexpSymbolTransform @@ -607,6 +658,9 @@ run_options.add_project( symbol_transforms=symbol_transforms))+
Please note that the class must be + defined in a separate file.
+This example causes any symbol under "project1" that looks like "release-3_12" to be transformed into a symbol named "project1-release-3.12", whereas if the same symbol appears under -- 2.11.4.GIT