87
87
for branch in BzrDir.find_branches(transport))
90
def get_branches(sourcecode_directory, new_branches):
90
def get_branches(sourcecode_directory, new_branches,
91
possible_transports=None):
91
92
"""Get the new branches into sourcecode."""
92
93
for project, (branch_url, optional) in new_branches.iteritems():
93
94
destination = os.path.join(sourcecode_directory, project)
95
remote_branch = Branch.open(
96
branch_url, possible_transports=possible_transports)
97
possible_transports.append(
98
remote_branch.bzrdir.root_transport)
94
99
print 'Getting %s from %s' % (project, branch_url)
95
os.system('bzr branch %s %s' % (branch_url, destination))
98
def update_branches(sourcecode_directory, update_branches):
100
remote_branch.bzrdir.sprout(
101
destination, create_tree_if_local=True,
102
source_branch=remote_branch,
103
possible_transports=possible_transports)
106
def update_branches(sourcecode_directory, update_branches,
107
possible_transports=None):
99
108
"""Update the existing branches in sourcecode."""
100
possible_transports = []
109
if possible_transports is None:
110
possible_transports = []
101
111
for project, (branch_url, optional) in update_branches.iteritems():
102
112
destination = os.path.join(sourcecode_directory, project)
103
113
print 'Updating %s' % (project,)
104
114
local_tree = WorkingTree.open(destination)
105
transport = get_transport(branch_url)
106
possible_transports.append(transport)
115
remote_branch = Branch.open(
116
branch_url, possible_transports=possible_transports)
117
possible_transports.append(
118
remote_branch.bzrdir.root_transport)
109
transport.base, possible_transports=possible_transports),
110
121
possible_transports=possible_transports)
128
139
config_file.close()
129
140
branches = find_branches(sourcecode_directory)
130
141
new, updated, removed = plan_update(branches, config)
131
get_branches(sourcecode_directory, new)
132
update_branches(sourcecode_directory, updated)
142
possible_transports = []
143
get_branches(sourcecode_directory, new, possible_transports)
144
update_branches(sourcecode_directory, updated, possible_transports)
133
145
remove_branches(sourcecode_directory, removed)