author Daniel Holbert <>
Wed, 01 Oct 2008 23:49:45 -0700
changeset 20072 d47a01a87c6c07e894685d7994d901d351afaea0
parent 15271 3599b2ccdf5752869d726ae5b959b0f4c664ef11
child 21611 f3d9ccfea0a3425a23d5217cb3cd7a6673cc8f83
permissions -rw-r--r--
Bug 458167 - (comments-only changes) Grammar Nazi Vol1: s/it's/its/ for the posessive version of the word, and a few other misc comment-typos, in these directories: accessible browser config profile rdf toolkit tools xpcom xpfe


NSPR_DIRS = ('nsprpub',)
NSS_DIRS  = ('dbm',

import os
import sys
import datetime
import shutil
from optparse import OptionParser

topsrcdir = os.path.dirname(__file__)
if topsrcdir == '':
    topsrcdir = '.'

    from subprocess import check_call
except ImportError:
    import subprocess
    def check_call(*popenargs, **kwargs):
        retcode =*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
                raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))

def check_call_noisy(cmd, *args, **kwargs):
    print "Executing command:", cmd
    check_call(cmd, *args, **kwargs)

def do_hg_pull(dir, repository, hg):
    fulldir = os.path.join(topsrcdir, dir)
    # clone if the dir doesn't exist, pull if it does
    if not os.path.exists(fulldir):
        fulldir = os.path.join(topsrcdir, dir)
        check_call_noisy([hg, 'clone', repository, fulldir])
        cmd = [hg, 'pull', '-u', '-R', fulldir]
        if repository is not None:
    check_call([hg, 'parent', '-R', fulldir,
                '--template=Updated to revision {node}.\n'])

def do_cvs_export(modules, tag, cvsroot, cvs):
    """Check out a CVS directory without CVS metadata, using "export"
    modules is a list of directories to check out, e.g. ['nsprpub']
    for module in modules:
        fullpath = os.path.join(topsrcdir, module)
        if os.path.exists(fullpath):
            print "Removing '%s'" % fullpath

        (parent, leaf) = os.path.split(module)
        print "CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
        check_call_noisy([cvs, '-d', cvsroot,
                          'export', '-r', tag, '-d', leaf,
                          'mozilla/%s' % module],
                         cwd=os.path.join(topsrcdir, parent))
        print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")

o = OptionParser(usage=" [options] update_nspr tagname | update_nss tagname")
o.add_option("--skip-mozilla", dest="skip_mozilla",
             action="store_true", default=False,

o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
             help="The location of the cvs binary")
o.add_option("--cvsroot", dest="cvsroot",
             default=os.environ.get('CVSROOT', ''),
             help="The CVSROOT (default:")

    options, args = o.parse_args()
    action = args[0]
except IndexError:

if action in ('checkout', 'co'):
    print >>sys.stderr, "Warning: checkout is obsolete."
elif action in ('update_nspr'):
    tag, = args[1:]
    do_cvs_export(NSPR_DIRS, tag, options.cvsroot, options.cvs)
elif action in ('update_nss'):
    tag, = args[1:]
    do_cvs_export(NSS_DIRS, tag, options.cvsroot, options.cvs)