You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "Eric S. Raymond" <es...@thyrsus.com> on 2004/08/09 21:04:11 UTC

Feature enhancement for cvs2svn

Thanks for the copy of the Subversion book.  As you might have anticipated,
it has renewed my interest in this software, and I am experimentally 
converting some of my projects from RCS.

The following patch implements a feature for cvs2svn that supports massaging 
illegal symbolic names into something useful rather than throwing them away.

The use case for this feature is the way many solo developers use
plain old RCS with per-project local repositories for version control.
Emacs VC mode, which I originally wrote, encourages this; furthermore,
I designed its Ctl-x v s command to allow developers to use the RCS
tagging feature as a klugey form of release labeling.  Ctl-x v s
accepts a tag name and applies it to the latest revision of all
RCS-controlled files beneath the current directory.

Because dot is illegal in RCS symbol names, the natural way to label
such snapshots is with symbol names like 1-0, 1-1, 2-1, etc.
Unfortunately these are illegal to cvs2svn, so the user's most
important version-control data is summarily discarded.

This patch allows cvs2svn users to give any number of --transform-tag options.
Each option should be a string in two parts sepatated by a ":".  The first part
is a pattern, the second should be a substitution (both in Python regexp
syntax).  Whenever cvs2svn is about to store a symbolic name, each tag 
transform is applied in the order it was specified.  Each transform 
application generates a warning.  The result of all transforms is what is 
registered (or discarded if it's still illegal).

Here is a representative application:

	cvs2svn --tag-transform='([0-9])-(.*):release-\1.\2' -q -s SVN RCS

This transforms a local CVS repository into a local SVN repository, performing
the following mappings of RCS symbolic names to SVN tags:

1-0 => release-1.0
1-1 => release-1.1
2-0 => release-2.0

etc.  Ideally there should be another option arranging for all the
commits associated with each release to be merged and their log
message accumulated, but that's a more difficult problem.  Perhaps for
my next patch...

--- cvs2svn	2004/08/08 18:43:00	1.1
+++ cvs2svn	2004/08/08 20:04:00
@@ -291,6 +291,9 @@
 CRLF = "\x0d\x0a"
 LF = "\x0a"
 
+# This should probably be local to some class
+tag_transforms = []
+
 def temp(basename):
   """Return a path to BASENAME in Ctx().tmpdir.
   This is a convenience function to save horizontal space in source."""
@@ -1110,6 +1113,12 @@
     header, for example: '1.7', '1.7.0.2', or '1.1.1' or '1.1.1.1'.
     This function will determine what kind of symbolic name it is by
     inspection, and record it in the right places."""
+    for (pattern, replacement) in tag_transforms:
+      newname = re.sub(pattern, replacement, name)
+      sys.stderr.write("%s: in '%s':\n"
+                       "   tag '%s' transformed to '%s'\n"
+                       % (warning_prefix, self.fname, name, newname))
+      name = newname
     if not symbolic_name_re.match(name):
       sys.stderr.write("%s: in '%s':\n"
                        "   '%s' is not a valid tag or branch name, ignoring\n"
@@ -4202,6 +4211,7 @@
 
 def main():
   # Convenience var, so we don't have to keep instantiating this Borg.
+  global tag_transforms
   ctx = Ctx()
 
   profiling = None
@@ -4219,7 +4229,8 @@
                                  "trunk-only", "no-prune", "dry-run",
                                  "dump-only", "dumpfile=", "tmpdir=",
                                  "svnadmin=", "skip-cleanup", "cvs-revnums",
-                                 "bdb-txn-nosync", "version", "profile", "keywords-off"])
+                                 "bdb-txn-nosync", "version", "profile",
+                                 "keywords-off", "tag-transform="])
   except getopt.GetoptError, e:
     sys.stderr.write(error_prefix + ': ' + str(e) + '\n\n')
     usage()
@@ -4319,6 +4330,8 @@
           'default,\nand passing the option is deprecated.\n')
     elif opt == '--profile':
       profiling = 1
+    elif opt == '--tag-transform':
+      tag_transforms.append(value.split(":"))
       
   if ctx.print_help:
     usage()

-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Feature enhancement for cvs2svn

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Eric S. Raymond wrote:

> Thanks for the copy of the Subversion book.  As you might have anticipated,
> it has renewed my interest in this software, and I am experimentally 
> converting some of my projects from RCS.

Good to hear!

> The following patch implements a feature for cvs2svn that supports massaging 
> illegal symbolic names into something useful rather than throwing them away.

This patch will probably have better luck over on the cvs2svn 
development list, dev@cvs2svn.tigris.org.  This list is devoted to 
Subversion core development, the core libraries and the command line 
client basically.

Thanks,

-garrett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Feature enhancement for cvs2svn

Posted by "Eric S. Raymond" <es...@thyrsus.com>.
Brian W. Fitzpatrick <fi...@red-bean.com>:
> Also, please update the doc in www/cvs2svn.html

Done in my copy.
 
> Aside from that, it looks good to me.

I should have second rev and comment within a few hours. Not immediately, 
I've got a kung fu class to make at 7:00.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Feature enhancement for cvs2svn

Posted by "Brian W. Fitzpatrick" <fi...@red-bean.com>.
[[Ugh.  Prematurely fired off the last mail... I really need a different
mailer]]

Anyway, picking up where I left off

On Mon, 2004-08-09 at 16:04, Eric S. Raymond wrote:

>@@ -1110,6 +1113,12 @@
>      header, for example: '1.7', '1.7.0.2', or '1.1.1' or '1.1.1.1'.
>      This function will determine what kind of symbolic name it is by
>      inspection, and record it in the right places."""
> +    for (pattern, replacement) in tag_transforms:
> +      newname = re.sub(pattern, replacement, name)
> +      sys.stderr.write("%s: in '%s':\n"
> +                       "   tag '%s' transformed to '%s'\n"
> +                       % (warning_prefix, self.fname, name, newname))

I'd like to see this use the Log facility like this:

      Log().write(LOG_WARN, "%s: in '%s':\n"
                            "   tag '%s' transformed to '%s'\n"
                            % (warning_prefix, self.fname, name, newname))

> +      name = newname
>      if not symbolic_name_re.match(name):
>        sys.stderr.write("%s: in '%s':\n"
>                         "   '%s' is not a valid tag or branch name, ignoring\n"
> @@ -4202,6 +4211,7 @@
>  
>  def main():
>    # Convenience var, so we don't have to keep instantiating this Borg.
> +  global tag_transforms

As mentioned above, tag_transforms should be in Ctx

>    ctx = Ctx()
>  
>    profiling = None
> @@ -4219,7 +4229,8 @@
>                                   "trunk-only", "no-prune", "dry-run",
>                                   "dump-only", "dumpfile=", "tmpdir=",
>                                   "svnadmin=", "skip-cleanup", "cvs-revnums",
> -                                 "bdb-txn-nosync", "version", "profile", "keywords-off"])
> +                                 "bdb-txn-nosync", "version", "profile",
> +                                 "keywords-off", "tag-transform="])
>    except getopt.GetoptError, e:
>      sys.stderr.write(error_prefix + ': ' + str(e) + '\n\n')
>      usage()
> @@ -4319,6 +4330,8 @@
>            'default,\nand passing the option is deprecated.\n')
>      elif opt == '--profile':
>        profiling = 1
> +    elif opt == '--tag-transform':
> +      tag_transforms.append(value.split(":"))
>        
>    if ctx.print_help:
>      usage()

Also, please update the doc in www/cvs2svn.html

Aside from that, it looks good to me.

-Fitz


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Feature enhancement for cvs2svn

Posted by "Eric S. Raymond" <es...@thyrsus.com>.
Brian W. Fitzpatrick <fi...@red-bean.com>:
> Can you write a log message to go with your patch?  See
> http://svn.collab.net/repos/cvs2svn/trunk/HACKING for log message
> guidelines.

I'll do that when I submit version 2 of this patch.
 
> > +# This should probably be local to some class
> > +tag_transforms = []
> > +
> 
> Please toss it into the Ctx class along with the rest of the application
> defaults.

That's how I started to do it originally. Then I discovered that Ctx
doesn't seem to be available at the point where I need the
tag-transforms list.  Changing that will make this a rather more
intrusive patch...but if that's how you want it, I'll do it that way.

> Hmm... since this transform is an expected behavior, I'd prefer to see
> the warning printed to STDOUT via the cvs2svn log facility...

Done.

Now I need to figure out how to make Ctx visible at the right place.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Feature enhancement for cvs2svn

Posted by "Brian W. Fitzpatrick" <fi...@red-bean.com>.
On Mon, 2004-08-09 at 16:04, Eric S. Raymond wrote:
> Thanks for the copy of the Subversion book.  As you might have anticipated,
> it has renewed my interest in this software, and I am experimentally 
> converting some of my projects from RCS.

Excellent.  The book is fulfilling its role as a subversive tool.

> The following patch implements a feature for cvs2svn that supports massaging 
> illegal symbolic names into something useful rather than throwing them away.
> 
> The use case for this feature is the way many solo developers use
> plain old RCS with per-project local repositories for version control.
> Emacs VC mode, which I originally wrote, encourages this; furthermore,
> I designed its Ctl-x v s command to allow developers to use the RCS
> tagging feature as a klugey form of release labeling.  Ctl-x v s
> accepts a tag name and applies it to the latest revision of all
> RCS-controlled files beneath the current directory.
> 
> Because dot is illegal in RCS symbol names, the natural way to label
> such snapshots is with symbol names like 1-0, 1-1, 2-1, etc.
> Unfortunately these are illegal to cvs2svn, so the user's most
> important version-control data is summarily discarded.
> 
> This patch allows cvs2svn users to give any number of --transform-tag options.
> Each option should be a string in two parts sepatated by a ":".  The first part
> is a pattern, the second should be a substitution (both in Python regexp
> syntax).  Whenever cvs2svn is about to store a symbolic name, each tag 
> transform is applied in the order it was specified.  Each transform 
> application generates a warning.  The result of all transforms is what is 
> registered (or discarded if it's still illegal).

Sounds good to me.  Comments inline below.

> Here is a representative application:
> 
> 	cvs2svn --tag-transform='([0-9])-(.*):release-\1.\2' -q -s SVN RCS
> 
> This transforms a local CVS repository into a local SVN repository, performing
> the following mappings of RCS symbolic names to SVN tags:
> 
> 1-0 => release-1.0
> 1-1 => release-1.1
> 2-0 => release-2.0
> 
> etc.  Ideally there should be another option arranging for all the
> commits associated with each release to be merged and their log
> message accumulated, but that's a more difficult problem.  Perhaps for
> my next patch...

Can you write a log message to go with your patch?  See
http://svn.collab.net/repos/cvs2svn/trunk/HACKING for log message
guidelines.

> --- cvs2svn	2004/08/08 18:43:00	1.1
> +++ cvs2svn	2004/08/08 20:04:00
> @@ -291,6 +291,9 @@
>  CRLF = "\x0d\x0a"
>  LF = "\x0a"
>  
> +# This should probably be local to some class
> +tag_transforms = []
> +

Please toss it into the Ctx class along with the rest of the application
defaults.

>  def temp(basename):
>    """Return a path to BASENAME in Ctx().tmpdir.
>    This is a convenience function to save horizontal space in source."""
> @@ -1110,6 +1113,12 @@
>      header, for example: '1.7', '1.7.0.2', or '1.1.1' or '1.1.1.1'.
>      This function will determine what kind of symbolic name it is by
>      inspection, and record it in the right places."""
> +    for (pattern, replacement) in tag_transforms:
> +      newname = re.sub(pattern, replacement, name)
> +      sys.stderr.write("%s: in '%s':\n"
> +                       "   tag '%s' transformed to '%s'\n"
> +                       % (warning_prefix, self.fname, name, newname))

Hmm... since this transform is an expected behavior, I'd prefer to see
the warning printed to STDOUT via the cvs2svn log facility... something
like:

Log().write(LOG_WARN, str % (warning_prefix, self.rel_name,
                                           delta))

> +      name = newname
>      if not symbolic_name_re.match(name):
>        sys.stderr.write("%s: in '%s':\n"
>                         "   '%s' is not a valid tag or branch name, ignoring\n"
> @@ -4202,6 +4211,7 @@
>  
>  def main():
>    # Convenience var, so we don't have to keep instantiating this Borg.
> +  global tag_transforms
>    ctx = Ctx()
>  
>    profiling = None
> @@ -4219,7 +4229,8 @@
>                                   "trunk-only", "no-prune", "dry-run",
>                                   "dump-only", "dumpfile=", "tmpdir=",
>                                   "svnadmin=", "skip-cleanup", "cvs-revnums",
> -                                 "bdb-txn-nosync", "version", "profile", "keywords-off"])
> +                                 "bdb-txn-nosync", "version", "profile",
> +                                 "keywords-off", "tag-transform="])
>    except getopt.GetoptError, e:
>      sys.stderr.write(error_prefix + ': ' + str(e) + '\n\n')
>      usage()
> @@ -4319,6 +4330,8 @@
>            'default,\nand passing the option is deprecated.\n')
>      elif opt == '--profile':
>        profiling = 1
> +    elif opt == '--tag-transform':
> +      tag_transforms.append(value.split(":"))
>        
>    if ctx.print_help:
>      usage()


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org