Ejemplo n.º 1
0
 def setUp(self):
     self.repos = phlgitu_fixture.CentralisedWithTwoWorkers()
     self.repo_central = self.repos.central_repo
     self.repo_dev = self.repos.w0.repo
     sys_repo = self.repos.w1.repo
     refcache_repo = phlgitx_refcache.Repo(sys_repo)
     differ_cache = abdt_differresultcache.Cache(refcache_repo)
     self.repo_arcyd = abdt_git.Repo(refcache_repo, differ_cache, 'origin',
                                     'myrepo')
def process(args):

    _ = args  # NOQA
    fs = abdt_fs.make_default_accessor()

    with fs.lockfile_context():
        pid = fs.get_pid_or_none()
        if pid is not None and phlsys_pid.is_running(pid):
            raise Exception("cannot fetch whilst arcyd is running.")

        repo_config_path_list = fs.repo_config_path_list()
        repo_name_config_list = abdi_repoargs.parse_config_file_list(
            repo_config_path_list)

        url_watcher_wrapper = phlurl_watcher.FileCacheWatcherWrapper(
            fs.layout.urlwatcher_cache_path)

        # Let the user know what's happening before potentially blocking for a
        # while.
        print('Refreshing repository snoop status ..', end=' ')
        # Make sure that the output is actually visible by flushing stdout
        # XXX: Will use 'flush' parameter to 'print()' in Python 3.3
        sys.stdout.flush()
        print("done")

        url_watcher_wrapper.watcher.refresh()

        for repo_name, repo_config in repo_name_config_list:
            print(repo_name + ' ..', end=' ')

            # Make sure that the output is actually visible by flushing stdout
            # XXX: Will use 'flush' parameter to 'print()' in Python 3.3
            sys.stdout.flush()

            snoop_url = abdi_repoargs.get_repo_snoop_url(repo_config)

            sys_repo = phlsys_git.Repo(repo_config.repo_path)
            refcache_repo = phlgitx_refcache.Repo(sys_repo)
            differ_cache = abdt_differresultcache.Cache(refcache_repo)
            abd_repo = abdt_git.Repo(refcache_repo, differ_cache, "origin",
                                     repo_config.repo_desc)

            did_fetch = abdi_processrepoarglist.fetch_if_needed(
                url_watcher_wrapper.watcher, snoop_url, abd_repo,
                repo_config.repo_desc)

            if did_fetch:
                print('fetched')
            else:
                print('skipped')

            url_watcher_wrapper.save()
Ejemplo n.º 3
0
    def __init__(self, repo_name, repo_args, conduit_manager,
                 url_watcher_wrapper, sys_admin_emails, mail_sender):

        self._active_state = _RepoActiveRetryState(
            retry_timestr_list=["10 seconds", "10 minutes", "1 hours"])
        sys_repo = phlsys_git.Repo(repo_args.repo_path)
        self._refcache_repo = phlgitx_refcache.Repo(sys_repo)
        self._differ_cache = abdt_differresultcache.Cache(self._refcache_repo)
        self._abd_repo = abdt_git.Repo(self._refcache_repo, self._differ_cache,
                                       "origin", repo_args.repo_desc)
        self._name = repo_name
        self._args = repo_args
        self._conduit_manager = conduit_manager

        conduit_cache = conduit_manager.get_conduit_and_cache_for_args(
            repo_args)
        self._arcyd_conduit, self._review_cache = conduit_cache

        self._mail_sender = mail_sender
        self._url_watcher_wrapper = url_watcher_wrapper
        self._mail_sender = mail_sender
        self._on_exception = abdt_exhandlers.make_exception_delay_handler(
            sys_admin_emails, repo_name)
Ejemplo n.º 4
0
    def test_A_Breathing(self):
        with phlgitu_fixture.lone_worker_context() as worker:

            branch_name = 'diff_branch'

            breakable_repo = _BreakableRepo(worker.repo)
            refcache_repo = phlgitx_refcache.Repo(breakable_repo)
            differ = abdt_differresultcache.Cache(refcache_repo)

            # pylint has faulty detection here
            # pylint: disable=not-callable
            worker.repo('checkout', '-b', branch_name)

            # pylint: enable=not-callable

            def make_diff(max_bytes):
                return differ.checkout_make_raw_diff(
                    "refs/heads/master", "refs/heads/{}".format(branch_name),
                    max_bytes)

            # make sure that the repo raises if used when disabled
            with self.assertRaises(_BreakableRepoUsedError):
                with breakable_repo.disabled_context():
                    with self.assertRaises(abdt_differ.NoDiffError):
                        make_diff(1)

            # An empty diff raises abdt_differ.NoDiffError
            with self.assertRaises(abdt_differ.NoDiffError):
                make_diff(1)

            # An empty diff raises abdt_differ.NoDiffError again, this time the
            # refcache_repo won't be used to do diffing so it won't need to
            # reset the cache
            with self.assertRaises(abdt_differ.NoDiffError):
                make_diff(1)

            # An empty diff raises abdt_differ.NoDiffError again
            # make sure that the repo isn't used at all, by disabling it
            with breakable_repo.disabled_context():
                with self.assertRaises(abdt_differ.NoDiffError):
                    make_diff(1)

            # the differ will detach HEAD so attach to branch again before
            # making any more commits on the branch
            # pylint has faulty detection here
            # pylint: disable=not-callable
            worker.repo('checkout', branch_name)
            # pylint: enable=not-callable

            worker.commit_new_file("make a test diff", "newfile",
                                   "test content")

            # a diff within the limits passes straight through
            diff_result = make_diff(1000)
            self.assertIn("test content", diff_result.diff)

            # a diff within the limits passes straight through again
            diff_result = make_diff(1000)
            self.assertIn("test content", diff_result.diff)

            # raise if a diff cannot be reduced to the limits
            with self.assertRaises(abdt_exception.LargeDiffException):
                make_diff(1)

            # raise if a diff cannot be reduced to the limits again
            with self.assertRaises(abdt_exception.LargeDiffException):
                make_diff(1)