3 NSPR_DIRS
= ('nsprpub',)
13 from optparse
import OptionParser
15 topsrcdir
= os
.path
.dirname(__file__
)
20 from subprocess
import check_call
23 def check_call(*popenargs
, **kwargs
):
24 retcode
= subprocess
.call(*popenargs
, **kwargs
)
26 cmd
= kwargs
.get("args")
29 raise Exception("Command '%s' returned non-zero exit status %i" % (cmd
, retcode
))
31 def check_call_noisy(cmd
, *args
, **kwargs
):
32 print "Executing command:", cmd
33 check_call(cmd
, *args
, **kwargs
)
35 def do_hg_pull(dir, repository
, hg
):
36 fulldir
= os
.path
.join(topsrcdir
, dir)
37 # clone if the dir doesn't exist, pull if it does
38 if not os
.path
.exists(fulldir
):
39 fulldir
= os
.path
.join(topsrcdir
, dir)
40 check_call_noisy([hg
, 'clone', repository
, fulldir
])
42 cmd
= [hg
, 'pull', '-u', '-R', fulldir
]
43 if repository
is not None:
44 cmd
.append(repository
)
46 check_call([hg
, 'parent', '-R', fulldir
,
47 '--template=Updated to revision {node}.\n'])
49 def do_cvs_export(modules
, tag
, cvsroot
, cvs
):
50 """Check out a CVS directory without CVS metadata, using "export"
51 modules is a list of directories to check out, e.g. ['nsprpub']
53 for module
in modules
:
54 fullpath
= os
.path
.join(topsrcdir
, module
)
55 if os
.path
.exists(fullpath
):
56 print "Removing '%s'" % fullpath
57 shutil
.rmtree(fullpath
)
59 (parent
, leaf
) = os
.path
.split(module
)
60 print "CVS export begin: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
61 check_call_noisy([cvs
, '-d', cvsroot
,
62 'export', '-r', tag
, '-d', leaf
,
63 'mozilla/%s' % module
],
64 cwd
=os
.path
.join(topsrcdir
, parent
))
65 print "CVS export end: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
67 o
= OptionParser(usage
="client.py [options] update_nspr tagname | update_nss tagname")
68 o
.add_option("--skip-mozilla", dest
="skip_mozilla",
69 action
="store_true", default
=False,
72 o
.add_option("--cvs", dest
="cvs", default
=os
.environ
.get('CVS', 'cvs'),
73 help="The location of the cvs binary")
74 o
.add_option("--cvsroot", dest
="cvsroot",
75 default
=os
.environ
.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
76 help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
79 options
, args
= o
.parse_args()
85 if action
in ('checkout', 'co'):
86 print >>sys
.stderr
, "Warning: client.py checkout is obsolete."
88 elif action
in ('update_nspr'):
90 do_cvs_export(NSPR_DIRS
, tag
, options
.cvsroot
, options
.cvs
)
91 elif action
in ('update_nss'):
93 do_cvs_export(NSS_DIRS
, tag
, options
.cvsroot
, options
.cvs
)