~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/devscripts/sourcecode.py

  • Committer: Jonathan Lange
  • Date: 2009-09-10 06:04:42 UTC
  • mto: (9404.1.1 auto-land)
  • mto: This revision was merged to the branch mainline in revision 9408.
  • Revision ID: jml@canonical.com-20090910060442-0z0h6ary5iu0fgtm
Share transports when getting new branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        for branch in BzrDir.find_branches(transport))
88
88
 
89
89
 
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))
96
 
 
97
 
 
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)
 
104
 
 
105
 
 
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)
107
119
        local_tree.pull(
108
 
            Branch.open(
109
 
                transport.base, possible_transports=possible_transports),
 
120
            remote_branch,
110
121
            possible_transports=possible_transports)
111
122
 
112
123
 
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)
134
146
 
135
147