~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/codehosting/codeimport/worker.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-21 01:24:40 UTC
  • mfrom: (13168.9.8 auto-upgrade-fix)
  • Revision ID: launchpad@pqm.canonical.com-20110621012440-waa76gmxu72in1i8
[r=henninge][bug=798560] Use scanner-compatible directory names when
        upgrading code import branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
        except NotBranchError:
134
134
            remote_branch = BzrDir.create_branch_and_repo(
135
135
                target_url, format=required_format)
 
136
            old_branch = None
 
137
        else:
 
138
            if remote_branch.bzrdir.needs_format_conversion(
 
139
                    required_format):
 
140
                # For upgrades, push to a new branch in
 
141
                # the new format. When done pushing,
 
142
                # retire the old .bzr directory and rename
 
143
                # the new one in place.
 
144
                old_branch = remote_branch
 
145
                upgrade_url = urljoin(target_url, "backup.bzr")
 
146
                try:
 
147
                    remote_branch.bzrdir.root_transport.delete_tree(
 
148
                        'backup.bzr')
 
149
                except NoSuchFile:
 
150
                    pass
 
151
                remote_branch = BzrDir.create_branch_and_repo(
 
152
                    upgrade_url, format=required_format)
 
153
            else:
 
154
                old_branch = None
136
155
        pull_result = remote_branch.pull(bzr_branch, overwrite=True)
137
156
        # Because of the way we do incremental imports, there may be revisions
138
157
        # in the branch's repo that are not in the ancestry of the branch tip.
139
158
        # We need to transfer them too.
140
159
        remote_branch.repository.fetch(bzr_branch.repository)
 
160
        if old_branch is not None:
 
161
            # The format has changed; move the new format
 
162
            # branch in place.
 
163
            base_transport = old_branch.bzrdir.root_transport
 
164
            base_transport.delete_tree('.bzr')
 
165
            base_transport.rename("backup.bzr/.bzr", ".bzr")
 
166
            base_transport.rmdir("backup.bzr")
141
167
        return pull_result.old_revid != pull_result.new_revid
142
168
 
143
169