10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.4
by Karl Fogel
Add the copyright header block to more files; tweak format in a few files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
5 |
|
4984.1.4
by jml at canonical
Add docstrings and remove unnecessary sys.exit() call. |
6 |
"""Create dummy Bazaar branches for all HOSTED branches in the database.
|
7 |
||
8 |
The Launchpad sample data includes a number of HOSTED branches that users can
|
|
9 |
branch from, push to and view on the website. However, some of these things
|
|
10 |
will break if we are missing the actual Bazaar branches, so we have a script
|
|
11 |
to create them.
|
|
12 |
||
13 |
NOTE: This script will delete any existing sample data branches, so that the
|
|
14 |
sample data on the filesystem is consistent with the sample data in the
|
|
15 |
database.
|
|
16 |
"""
|
|
17 |
||
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
18 |
import _pythonpath |
19 |
||
4984.1.2
by jml at canonical
Add make-dummy-hosted-branches as a target to branches, remove branch dir |
20 |
import os |
21 |
import shutil |
|
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
22 |
import sys |
5027.1.1
by jml at canonical
Mask BZR_HOME, rather than editing people's configuration files! |
23 |
import tempfile |
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
24 |
|
5821.2.34
by James Henstridge
Don't bother with initZopeless(). |
25 |
import transaction |
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
26 |
from zope.component import getUtility |
27 |
||
8555.2.12
by Tim Penhey
Fix cronscripts and utilities too. |
28 |
from lp.code.enums import BranchType |
29 |
from lp.code.model.branch import Branch |
|
8426.6.1
by Michael Hudson
bzr ls --versioned --recursive --kind=file | xargs sed -i -e 's,from canonical.codehosting,from lp.codehosting,' |
30 |
from lp.codehosting.tests.helpers import make_bazaar_branch_and_tree |
14605.1.1
by Curtis Hovey
Moved canonical.config to lp.services. |
31 |
from lp.services.config import config |
14606.3.4
by William Grant
Replace canonical.database usage everywhere, and format-imports. |
32 |
from lp.services.database.sqlbase import sqlvalues |
14565.2.15
by Curtis Hovey
Moved canonical.launchpad.scripts __init__ to lp.services.scripts. |
33 |
from lp.services.scripts import execute_zcml_for_scripts |
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
34 |
|
35 |
||
36 |
def main(argv): |
|
5027.1.1
by jml at canonical
Mask BZR_HOME, rather than editing people's configuration files! |
37 |
os.environ['BZR_HOME'] = tempfile.mkdtemp() |
14486.5.1
by William Grant
Port dev/test stuff away from it, and drop hosted_branches_root. |
38 |
if os.path.exists(config.codehosting.mirrored_branches_root): |
39 |
shutil.rmtree(config.codehosting.mirrored_branches_root) |
|
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
40 |
execute_zcml_for_scripts() |
41 |
try: |
|
42 |
branches = Branch.select( |
|
43 |
"Branch.branch_type = %s" % sqlvalues(BranchType.HOSTED)) |
|
44 |
for branch in branches: |
|
45 |
make_bazaar_branch_and_tree(branch) |
|
46 |
finally: |
|
5821.2.34
by James Henstridge
Don't bother with initZopeless(). |
47 |
transaction.abort() |
4984.1.5
by jml at canonical
Add output on success. |
48 |
print "Created %d branches based on sample data." % len(list(branches)) |
4984.1.1
by jml at canonical
Add a script to make dummy hosted branches for all of the hosted branches in |
49 |
|
50 |
||
51 |
if __name__ == '__main__': |
|
4984.1.4
by jml at canonical
Add docstrings and remove unnecessary sys.exit() call. |
52 |
main(sys.argv) |