3 NSPR_DIRS
= ('nsprpub',)
13 from optparse
import OptionParser
14 from build
.util
import check_call
16 topsrcdir
= os
.path
.dirname(__file__
)
20 def check_call_noisy(cmd
, *args
, **kwargs
):
21 print "Executing command:", cmd
22 check_call(cmd
, *args
, **kwargs
)
24 def do_hg_pull(dir, repository
, hg
):
25 fulldir
= os
.path
.join(topsrcdir
, dir)
26 # clone if the dir doesn't exist, pull if it does
27 if not os
.path
.exists(fulldir
):
28 fulldir
= os
.path
.join(topsrcdir
, dir)
29 check_call_noisy([hg
, 'clone', repository
, fulldir
])
31 cmd
= [hg
, 'pull', '-u', '-R', fulldir
]
32 if repository
is not None:
33 cmd
.append(repository
)
35 check_call([hg
, 'parent', '-R', fulldir
,
36 '--template=Updated to revision {node}.\n'])
38 def do_cvs_export(modules
, tag
, cvsroot
, cvs
):
39 """Check out a CVS directory without CVS metadata, using "export"
40 modules is a list of directories to check out, e.g. ['nsprpub']
42 for module
in modules
:
43 fullpath
= os
.path
.join(topsrcdir
, module
)
44 if os
.path
.exists(fullpath
):
45 print "Removing '%s'" % fullpath
46 shutil
.rmtree(fullpath
)
48 (parent
, leaf
) = os
.path
.split(module
)
49 print "CVS export begin: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
50 check_call_noisy([cvs
, '-d', cvsroot
,
51 'export', '-r', tag
, '-d', leaf
,
52 'mozilla/%s' % module
],
53 cwd
=os
.path
.join(topsrcdir
, parent
))
54 print "CVS export end: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
56 o
= OptionParser(usage
="client.py [options] update_nspr tagname | update_nss tagname")
57 o
.add_option("--skip-mozilla", dest
="skip_mozilla",
58 action
="store_true", default
=False,
61 o
.add_option("--cvs", dest
="cvs", default
=os
.environ
.get('CVS', 'cvs'),
62 help="The location of the cvs binary")
63 o
.add_option("--cvsroot", dest
="cvsroot",
64 default
=os
.environ
.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
65 help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
68 options
, args
= o
.parse_args()
74 if action
in ('checkout', 'co'):
75 print >>sys
.stderr
, "Warning: client.py checkout is obsolete."
77 elif action
in ('update_nspr'):
79 do_cvs_export(NSPR_DIRS
, tag
, options
.cvsroot
, options
.cvs
)
80 elif action
in ('update_nss'):
82 do_cvs_export(NSS_DIRS
, tag
, options
.cvsroot
, options
.cvs
)