Advertisement
ggenellina

Change CVSROOT

Mar 17th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. """\
  2. Modify CVSROOT recursively.
  3.  
  4. Usage:
  5.    %s <new CVSROOT> <top directory>
  6. """
  7. import os, sys
  8.  
  9. __author__ = 'Gabriel Genellina'
  10.  
  11. CVSROOT=''
  12.  
  13. def changeCVSROOT(basepath):
  14.     path = os.path.join(basepath, 'CVS', 'Root')
  15.     if os.access(path, os.W_OK):
  16.         print basepath
  17.         open(path, 'wt').write('%s\n' % CVSROOT)
  18.     for dir in os.listdir(basepath):
  19.         path = os.path.join(basepath, dir)
  20.         if dir!='CVS' and os.path.isdir(path):
  21.             changeCVSROOT(path)
  22.  
  23. if __name__=='__main__':
  24.     if len(sys.argv)==3:
  25.         CVSROOT, basepath  = sys.argv[1:]
  26.         print 'Change CVSROOT -> %s starting from %s' % (CVSROOT, basepath)
  27.         changeCVSROOT(basepath)
  28.     else:
  29.         print __doc__ % os.path.basename(sys.argv[0])
  30.         CVSROOT = raw_input('New CVSROOT: ')
  31.         if CVSROOT:
  32.             basepath = raw_input('Starting from: ')
  33.             if basepath:
  34.                 print 'Change CVSROOT -> %s starting from %s' % (CVSROOT, basepath)
  35.                 changeCVSROOT(basepath)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement