~maxiberta/isitdeployable/update-project-url

« back to all changes in this revision

Viewing changes to revtracker/tasks.py

  • Committer: Ubuntu One Auto Copilot
  • Author(s): Colin Watson
  • Date: 2018-02-09 15:01:57 UTC
  • mfrom: (277.1.1 breezy)
  • Revision ID: otto-copilot@canonical.com-20180209150157-ye8cssq13ophdn5w
Port to breezy.

Merged from https://code.launchpad.net/~cjwatson/isitdeployable/breezy/+merge/337328

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import shutil
7
7
import tempfile
8
8
 
9
 
from bzrlib import (
10
 
    errors as bzr_errors,
 
9
from breezy import (
 
10
    errors as brz_errors,
11
11
    revision as _mod_revision,
12
12
    transport,
 
13
    urlutils,
13
14
    )
14
 
from bzrlib.branch import Branch
15
 
from bzrlib.plugin import load_plugins
16
 
from bzrlib.revisionspec import RevisionSpec
 
15
from breezy.branch import Branch
 
16
from breezy.plugin import load_plugins
 
17
from breezy.revisionspec import RevisionSpec
17
18
from celery import shared_task
18
19
from django.conf import settings
19
20
from django.contrib.auth.models import User
134
135
                if not all_revs and branch_from_revs_count > 1000:
135
136
                    revision_id = branch_from_revs[1000]
136
137
                    print("Getting up to revision 1000")
137
 
                to_dir = branch_from.bzrdir.sprout(to_transport.base,
138
 
                                            create_tree_if_local=False,
139
 
                                            source_branch=branch_from,
140
 
                                            revision_id=revision_id)
 
138
                to_dir = branch_from.controldir.sprout(
 
139
                    to_transport.base,
 
140
                    create_tree_if_local=False,
 
141
                    source_branch=branch_from,
 
142
                    revision_id=revision_id)
141
143
                branch_to = to_dir.open_branch()
142
144
                branch_to.lock_write()
143
145
            finally:
199
201
                    "revno_to_revid is not implemented for git.")
200
202
        try:
201
203
            return self.branch.get_rev_id(revno)
202
 
        except bzr_errors.NoSuchRevision:
 
204
        except brz_errors.NoSuchRevision:
203
205
            raise NoSuchRevision(self, revno)
204
206
 
205
207
    def revid_to_revno(self, revid):
206
208
        if self.vcs == VCS.VCS_BAZAAR:
207
209
            try:
208
210
                return self.branch.revision_id_to_dotted_revno(revid)[0]
209
 
            except bzr_errors.NoSuchRevision:
 
211
            except brz_errors.NoSuchRevision:
210
212
                raise NoSuchRevision(self, revid)
211
213
        else:
212
214
            if revid is None:
554
556
        try:
555
557
            try:
556
558
                old_revision = branch.revspec_to_revision(old_revspec)
557
 
            except (bzr_errors.InvalidRevisionSpec, KeyError, ValueError):
 
559
            except (brz_errors.InvalidRevisionSpec, KeyError, ValueError):
558
560
                # Can't determine old revision, so just take one
559
561
                # revision
560
562
                old_revision = None
618
620
        branch = LocalBranch.get_or_create(vcs, fixed_branch_url, branch_id,
619
621
                git_branch=git_branch, fetched_branches=fetched_branches,
620
622
                all_revs=all_revs)
621
 
    except (bzr_errors.NotBranchError, bzr_errors.InvalidURL,
 
623
    except (brz_errors.NotBranchError, urlutils.InvalidURL,
622
624
            pygit2.GitError) as e:
623
625
        if not allow_missing:
624
626
            raise
657
659
    try:
658
660
        branch = get_branch(url, project.name, git_branch=project.git_branch,
659
661
                            fetched_branches=fetched_branches)
660
 
    except bzr_errors.LockContention as err:
 
662
    except brz_errors.LockContention as err:
661
663
        print('Can not acquire lock for {}. There is already a lock at {}. '
662
664
              'Skipping.'.format(url, err.msg))
663
665
        return