コード例 #1
0
    def clone_from(self, source_url):
        '''Initialize a repo as a clone of another using svnsync'''
        self.init(default_dirs=False, skip_special_files=True)
        # Need a pre-revprop-change hook for cloning
        fn = os.path.join(self._repo.fs_path, self._repo.name, 'hooks',
                          'pre-revprop-change')
        with open(fn, 'wb') as fp:
            fp.write('#!/bin/sh\n')
        os.chmod(fn, 0755)

        def check_call(cmd):
            p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
            stdout, stderr = p.communicate(input='p\n')
            if p.returncode != 0:
                self._repo.status = 'ready'
                session(self._repo).flush(self._repo)
                raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)

        self._repo.status = 'importing'
        session(self._repo).flush(self._repo)
        log.info('Initialize %r as a clone of %s', self._repo, source_url)
        check_call(['svnsync', 'init', self._url, source_url])
        check_call(['svnsync', '--non-interactive', 'sync', self._url])
        log.info('... %r cloned', self._repo)
        if not svn_path_exists("file://%s%s/%s" %
                               (self._repo.fs_path, self._repo.name,
                                c.app.config.options['checkout_url'])):
            c.app.config.options['checkout_url'] = ""
        self._repo.refresh(notify=False)
        self._setup_special_files()
コード例 #2
0
ファイル: svn.py プロジェクト: Bitergia/allura
    def clone_from(self, source_url, copy_hooks=False):
        """Initialize a repo as a clone of another using svnsync"""
        self.init(default_dirs=False, skip_special_files=True)
        # Need a pre-revprop-change hook for cloning
        fn = os.path.join(self._repo.fs_path, self._repo.name, "hooks", "pre-revprop-change")
        with open(fn, "wb") as fp:
            fp.write("#!/bin/sh\n")
        os.chmod(fn, 0755)

        def check_call(cmd):
            p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
            stdout, stderr = p.communicate(input="p\n")
            if p.returncode != 0:
                self._repo.status = "ready"
                session(self._repo).flush(self._repo)
                raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)

        self._repo.status = "importing"
        session(self._repo).flush(self._repo)
        log.info("Initialize %r as a clone of %s", self._repo, source_url)
        check_call(["svnsync", "init", self._url, source_url])
        check_call(["svnsync", "--non-interactive", "sync", self._url])
        log.info("... %r cloned", self._repo)
        if not svn_path_exists(
            "file://%s%s/%s" % (self._repo.fs_path, self._repo.name, c.app.config.options["checkout_url"])
        ):
            c.app.config.options["checkout_url"] = ""
        self._repo.refresh(notify=False)
        self._setup_special_files(source_url, copy_hooks)
コード例 #3
0
ファイル: svn.py プロジェクト: pombredanne/SourceForge-Allura
    def clone_from(self, source_url):
        '''Initialize a repo as a clone of another using svnsync'''
        self.init(default_dirs=False, skip_special_files=True)
        # Need a pre-revprop-change hook for cloning
        fn = os.path.join(self._repo.fs_path, self._repo.name,
                          'hooks', 'pre-revprop-change')
        with open(fn, 'wb') as fp:
            fp.write('#!/bin/sh\n')
        os.chmod(fn, 0755)

        def check_call(cmd):
            p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
            stdout, stderr = p.communicate(input='p\n')
            if p.returncode != 0:
                self._repo.status = 'ready'
                session(self._repo).flush(self._repo)
                raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)

        self._repo.status = 'importing'
        session(self._repo).flush(self._repo)
        log.info('Initialize %r as a clone of %s',
                 self._repo, source_url)
        check_call(['svnsync', 'init', self._url, source_url])
        check_call(['svnsync', '--non-interactive', 'sync', self._url])
        log.info('... %r cloned', self._repo)
        if not svn_path_exists("file://%s%s/%s" %
                         (self._repo.fs_path,
                          self._repo.name,
                          c.app.config.options['checkout_url'])):
            c.app.config.options['checkout_url'] = ""
        self._repo.refresh(notify=False)
        self._setup_special_files()
コード例 #4
0
 def set_checkout_url(self, **post_data):
     if svn_path_exists("file://%s%s/%s" %
                       (self.app.repo.fs_path,
                        self.app.repo.name,
                        post_data['checkout_url'])):
         self.app.config.options['checkout_url'] = post_data['checkout_url']
         flash("Checkout URL successfully changed")
     else:
         flash("%s is not a valid path for this repository" % post_data['checkout_url'], "error")
コード例 #5
0
 def set_checkout_url(self, **post_data):
     if svn_path_exists("file://%s%s/%s" %
                        (self.app.repo.fs_path, self.app.repo.name,
                         post_data['checkout_url'])):
         self.app.config.options['checkout_url'] = post_data['checkout_url']
         flash("Checkout URL successfully changed")
     else:
         flash(
             "%s is not a valid path for this repository" %
             post_data['checkout_url'], "error")
コード例 #6
0
 def test_svn_path_exists(self):
     repo_path = pkg_resources.resource_filename('forgesvn',
                                                 'tests/data/testsvn')
     assert svn_path_exists("file://%s/a" % repo_path)
     assert svn_path_exists("file://%s" % repo_path)
     assert not svn_path_exists("file://%s/badpath" % repo_path)
コード例 #7
0
ファイル: test_repository.py プロジェクト: Bitergia/allura
 def test_svn_path_exists(self):
     repo_path = pkg_resources.resource_filename(
         'forgesvn', 'tests/data/testsvn')
     assert svn_path_exists("file://%s/a" % repo_path)
     assert svn_path_exists("file://%s" % repo_path)
     assert not svn_path_exists("file://%s/badpath" % repo_path)