Re: svn commit: r9112 - in tags: 0.10 0.10.0 0.15 0.15.0 0.16 0.16.0 0.17 0.17.0 0.18 0.18.0 0.19 0.19.0 0.20 0.20.0 0.21 0.21.0 0.22 0.22.0 0.23 0.23.0 0.24 0.24.0 0.25 0.25.0 0.26 0.26.0 0.28 0.28.0 0.6 0.6.0 0.7 0.7.0 0.8 0.8.0 0.9 0.9.0

"C. Michael Pilato" <[email protected]> 18 Mar 2004 12:22:49 -0600
Newsgroups gmane.mail.eyebrowse.devel,gmane.comp.version-control.subversion.svn
Message-ID <[email protected]>
[email protected] writes:

> Rename tags for 3-tuple consistency.  This change brought to you by
> a custom one-off script written in Python to the Subversion bindings.
> Kids, do not try this at home. 

In case anyone was wondering:

   #!/usr/bin/env python2
   import sys
   from svn import core, repos, fs
   
   log_msg = \
   """Rename tags for 3-tuple consistency.  This change brought to you by
   a custom one-off script written in Python to the Subversion bindings.
   Kids, do not try this at home. """
   
   core.apr_initialize()
   pool = core.svn_pool_create(None)
   repo = repos.svn_repos_open(sys.argv[1], pool)
   fsptr = repos.svn_repos_fs(repo)
   youngest = fs.youngest_rev(fsptr, pool)
   rev_root = fs.revision_root(fsptr, youngest, pool)
   fn = repos.svn_repos_fs_begin_txn_for_commit
   txnp = fn (repo, youngest, 'cmpilato', log_msg, pool)
   txn_root = fs.txn_root(txnp, pool)
   entries = fs.dir_entries(txn_root, '/tags', pool).keys()
   sub = core.svn_pool_create(pool)
   for entry in entries:
       core.svn_pool_clear(sub)
       pieces = entry.split('.')
       if len(pieces) == 2:
           try:
               int(pieces[0])
               int(pieces[1])
               new_entry = entry + '.0'
               fs.copy(rev_root, '/tags/' + entry, txn_root,
                       '/tags/' + new_entry, sub)
               print 'Renaming tag: %s -> %s' % (entry, new_entry)
               fs.delete(txn_root, '/tags/' + entry, sub)
           except ValueError:
               pass
   fs.commit_txn(txnp, pool)
   core.svn_pool_destroy(sub)