RE: [PATCH] New SymbolTransforms

Jon Foster <[email protected]> Fri, 26 Mar 2010 17:58:29 -0000
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <[email protected]>
Hi,

I've been thinking about these some more.  I think that a couple of
the symbol transforms I proposed before were unduly complex, and I
can get the same effect with much simpler primitives.

I'd like to propose a "tags-only" symbol transform, which wraps any
other symbol transform and restricts it to only apply to CVS tag
symbols (i.e. where the revision number has an even number of
components).

Similarly, I propose a "branches-only" symbol transform.

I think these might be more generally useful - for example, if the
same name is used as a CVS tag and a CVS branch, and you want to
rename one of them so that you end up with a separate SVN tag and
SVN branch.

Patch is attached.


I notice you committed the SubtreeSymbolTransform, thanks for that.

The number of local mods I have is going steadily down.  Currently
I only have three:

1) A separate script that makes more "unusual" changes to RCS files.
I've implemented that using rcs_file_filter.py to avoid adding more
complexity to cvs2svn.  I haven't sent this yet.

2) The symbol transform changes (this mail).

3) Symbol strategy changes.  Did you have any comments about the
"Default-exclude symbol strategy" patch that I sent?

I know I need to spend some time next week writing test cases, and
the FAQ entry.

Kind regards,

Jon


**********************************************************************
This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Cabot Communications Ltd.

If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone.

Cabot Communications Limited
Verona House, Filwood Road, Bristol BS16 3RY, UK
+44 (0) 1179584232

Co. Registered in England number 02817269

Please contact the sender if you believe you have received this email in error.

**********************************************************************


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

------------------------------------------------------
http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2465599

To unsubscribe from this discussion, e-mail: [[email protected]].
cvs2svn_tag_only_symbol_transform_patch.txt (text/plain, 1.4 KB)
Index: cvs2svn_lib/symbol_transform.py
===================================================================
--- cvs2svn_lib/symbol_transform.py	(revision 5081)
+++ cvs2svn_lib/symbol_transform.py	(working copy)
@@ -265,3 +265,39 @@
       return symbol_name
 
 
+class TagOnlyTransform(SymbolTransform):
+  """A wrapper around another SymbolTransform, that limits it to
+  CVS tags (not CVS branches)."""
+
+  def __init__(self, inner_symbol_transform):
+    """Constructor.
+
+    INNER_SYMBOL_TRANSFORM is the SymbolTransform to wrap."""
+    self.__inner = inner_symbol_transform
+
+  def transform(self, cvs_file, symbol_name, revision):
+    if revision.count('.') % 2 == 0:
+      # It's a branch
+      return symbol_name
+    else:
+      # It's a tag
+      return self.__inner.transform(cvs_file, symbol_name, revision)
+
+
+class BranchOnlyTransform(SymbolTransform):
+  """A wrapper around another SymbolTransform, that limits it to
+  CVS branches (not CVS tags)."""
+
+  def __init__(self, inner_symbol_transform):
+    """Constructor.
+
+    INNER_SYMBOL_TRANSFORM is the SymbolTransform to wrap."""
+    self.__inner = inner_symbol_transform
+
+  def transform(self, cvs_file, symbol_name, revision):
+    if revision.count('.') % 2 == 0:
+      # It's a branch
+      return self.__inner.transform(cvs_file, symbol_name, revision)
+    else:
+      # It's a tag
+      return symbol_name