Hi,

Bhuvaneswaran A wrote:
> Did we discuss about correcting old revisions pointing to svn.collab.net
> repository referenced in log messages? Like this one:
> $ svn log -r r880575

This is my first attempt at ctypes-python bindings for subversion :) The
attached script will do the above. I plan to run this script on -r 836401:HEAD
over https://svn.apache.org/repos/asf/subversion/trunk around "15:30:00
Saturday November 28, 2009 in UTC"

Already ran a test on r880575 and the script did what it was supposed to do.

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/
#!/usr/bin/env python
#    Licensed to the Apache Software Foundation (ASF) under one
#    or more contributor license agreements.  See the NOTICE file
#    distributed with this work for additional information
#    regarding copyright ownership.  The ASF licenses this file
#    to you under the Apache License, Version 2.0 (the
#    "License"); you may not use this file except in compliance
#    with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing,
#    software distributed under the License is distributed on an
#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#    KIND, either express or implied.  See the License for the
#    specific language governing permissions and limitations
#    under the License.

from csvn.repos import *
from csvn.auth import User
import csvn.core
from optparse import OptionParser
import re

usage = """python log_revnum_change_asf.py [OPTION]... URL

Change the revision numbers relatively in the log messages of new ASF
subversion repository.
"""

parser = OptionParser(usage=usage)
parser.add_option("-u", "", dest="username",
                  help="commit the changes as USERNAME")
parser.add_option("-p", "", dest="password",
                  help="commit the changes with PASSWORD")
parser.add_option("-r", "", dest="rev",
                  help="revision range")

(options, args) = parser.parse_args()

if len(args) != 1:
    parser.print_help()
    sys.exit(1)

csvn.core.svn_cmdline_init("", csvn.core.stderr)
repos_url = args[0]
revs = options.rev
if revs and ":" in revs:
    [start_rev, end_rev] = revs.split(":")
elif revs:
    start_rev = revs
    end_rev = revs
else:
    start_rev = 1
    end_rev = "HEAD"

session = RemoteRepository(repos_url, user=User(options.username,
                                                options.password))

if end_rev == "HEAD":
    end_rev = session.latest_revnum()
if start_rev == "HEAD":
    start_rev = session.latest_revnum()
start_rev = int(start_rev)
end_rev = int(end_rev)

def repl_newrev(matchobj):
    if matchobj.group(0):
      old_rev = int(matchobj.group(0)[1:])
      if old_rev <= 45000:
        return 'r'+str(old_rev + 840074)
      else:
        return 'r'+str(old_rev)

for entry in session.log(start_rev, end_rev):
    new_log = re.sub(r'(r\d+)', repl_newrev, entry.message)
    rev = session.revprop_set(propname='svn:log',
                              propval=new_log,
                              revnum=entry.revision,
                              force=True)

Reply via email to