~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-06-01 15:59:45 UTC
  • mto: This revision was merged to the branch mainline in revision 13158.
  • Revision ID: jelmer@canonical.com-20110601155945-jldp4m1w3yxn7qx8
Use new fetch(limit=) API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
555
555
        """The probers that should be tried for this import."""
556
556
        raise NotImplementedError
557
557
 
558
 
    def getExtraPullArgs(self):
559
 
        """Return extra arguments to `InterBranch.pull`.
560
 
 
561
 
        This method only really exists because only bzr-git and bzr-svn
562
 
        support the 'limit' argument to this method.  When bzr-hg plugin does
563
 
        too, this method can go away.
 
558
    def getRevisionLimit(self):
 
559
        """Return maximum number of revisions to fetch (None for no limit).
564
560
        """
565
 
        return {}
 
561
        return None
566
562
 
567
563
    def _doImport(self):
568
564
        self._logger.info("Starting job.")
587
583
            remote_branch_tip = remote_branch.last_revision()
588
584
            inter_branch = InterBranch.get(remote_branch, bazaar_branch)
589
585
            self._logger.info("Importing branch.")
590
 
            pull_result = inter_branch.pull(
591
 
                overwrite=True, **self.getExtraPullArgs())
 
586
            inter_branch.fetch(limit=self.getRevisionLimit())
 
587
            if bazaar_branch.repository.has_revision(remote_branch_tip):
 
588
                pull_result = inter_branch.pull(overwrite=True)
 
589
                if pull_result.old_revid != pull_result.new_revid:
 
590
                    result = CodeImportWorkerExitCode.SUCCESS
 
591
                else:
 
592
                    result = CodeImportWorkerExitCode.SUCCESS_NOCHANGE
 
593
            else:
 
594
                result = CodeImportWorkerExitCode.SUCCESS_PARTIAL
592
595
            self._logger.info("Pushing local import branch to central store.")
593
596
            self.pushBazaarBranch(bazaar_branch)
594
 
            last_imported_revison = bazaar_branch.last_revision()
595
597
            self._logger.info("Job complete.")
596
 
            if last_imported_revison == remote_branch_tip:
597
 
                if pull_result.old_revid != pull_result.new_revid:
598
 
                    return CodeImportWorkerExitCode.SUCCESS
599
 
                else:
600
 
                    return CodeImportWorkerExitCode.SUCCESS_NOCHANGE
601
 
            else:
602
 
                return CodeImportWorkerExitCode.SUCCESS_PARTIAL
 
598
            return result
603
599
        finally:
604
600
            bzrlib.ui.ui_factory = saved_factory
605
601
 
617
613
            LocalGitProber, RemoteGitProber)
618
614
        return [LocalGitProber, RemoteGitProber]
619
615
 
620
 
    def getExtraPullArgs(self):
621
 
        """See `PullingImportWorker.getExtraPullArgs`."""
622
 
        return {'limit': config.codeimport.git_revisions_import_limit}
 
616
    def getRevisionLimit(self):
 
617
        """See `PullingImportWorker.getRevisionLimit`."""
 
618
        return config.codeimport.git_revisions_import_limit
623
619
 
624
620
    def getBazaarBranch(self):
625
621
        """See `ImportWorker.getBazaarBranch`.
671
667
        from bzrlib.plugins.hg import HgProber
672
668
        return [HgProber]
673
669
 
 
670
    def getRevisionLimit(self):
 
671
        """See `PullingImportWorker.getRevisionLimit`."""
 
672
        return config.codeimport.hg_revisions_import_limit
 
673
 
674
674
    def getBazaarBranch(self):
675
675
        """See `ImportWorker.getBazaarBranch`.
676
676
 
713
713
class BzrSvnImportWorker(PullingImportWorker):
714
714
    """An import worker for importing Subversion via bzr-svn."""
715
715
 
716
 
    def getExtraPullArgs(self):
717
 
        """See `PullingImportWorker.getExtraPullArgs`."""
718
 
        return {'limit': config.codeimport.svn_revisions_import_limit}
 
716
    def getRevisionLimit(self):
 
717
        """See `PullingImportWorker.getRevisionLimit`."""
 
718
        return config.codeimport.svn_revisions_import_limit
719
719
 
720
720
    @property
721
721
    def probers(self):