[devel] desktop-file-utils moved to git
[jhbuild.git] / scripts / changecvsroot.py
blob7284b8bf1a5a72ede7ddbfab9d9033d9eae38f82
1 #!/usr/bin/env python
2 # jhbuild - a build script for GNOME 1.x and 2.x
3 # Copyright (C) 2001-2006 James Henstridge
5 # changecvsroot.py: script to alter the CVS root of a working copy
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 import os
23 def changecvsroot(oldroot, newroot, *dirs):
24 def handle((oldroot, newroot), dirname, fnames):
25 if os.path.basename(dirname) == 'CVS' and 'Root' in fnames:
26 r = open(os.path.join(dirname, 'Root'), 'r').read().strip()
27 if r == oldroot:
28 fp = open(os.path.join(dirname, 'Root'), 'w')
29 fp.write('%s\n' % newroot)
30 fp.close()
31 for dir in dirs:
32 os.path.walk(dir, handle, (oldroot, newroot))
34 if __name__ == '__main__':
35 import sys
36 if len(sys.argv) < 4:
37 sys.stderr.write('usage: changecvsroot.py oldroot newroot dirs ...\n')
38 sys.exit(1)
39 changecvsroot(sys.argv[1], sys.argv[2], *sys.argv[2:])