1#!/usr/bin/env python 2# 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21# 22# 23# USAGE: random-commits.py 24# 25# Using the FILELIST (see config below), a series of COUNT commits will be 26# constructed, each changing up to MAXFILES files per commit. The commands 27# will be sent to stdout (formatted as a shell script). 28# 29# The FILELIST can be constructed using the find-textfiles script. 30# 31 32import random 33 34FILELIST = 'textfiles' 35COUNT = 1000 # this many commits 36MAXFILES = 10 # up to 10 files at a time 37 38files = open(FILELIST).readlines() 39 40print('#!/bin/sh') 41 42for i in range(COUNT): 43 n = random.randrange(1, MAXFILES+1) 44 l = [ ] 45 print("echo '--- begin commit #%d -----------------------------------'" % (i+1,)) 46 for j in range(n): 47 fname = random.choice(files)[:-1] # strip trailing newline 48 print("echo 'part of change #%d' >> %s" % (i+1, fname)) 49 l.append(fname) 50 print("svn commit -m 'commit #%d' %s" % (i+1, ' '.join(l))) 51