Esempio n. 1
0
    def _run_hg(self, args):
        """Runs the Mercurial command, returning a subprocess.Popen."""
        if not self.default_args:
            self._calculate_default_args()

        return SCMTool.popen(['hg'] + self.default_args + args,
                             local_site_name=self.local_site_name)
Esempio n. 2
0
    def _run_bzr(self, args):
        """Run a Bazaar command.

        This will run :command:`bzr` with the specified arguments, and sets
        up the environment to work with :command:`rbssh`.

        Args:
            args (list of unicode):
                The list of arguments to pass to :command:`bzr`.

        Returns:
            subprocess.Popen:
            The handle for the process.
        """
        if not BZRClient._bzr_plugin_path:
            BZRClient._bzr_plugin_path = (
                '%s:%s' %
                (os.path.join(os.path.dirname(__file__), 'plugins', 'bzrlib',
                              'plugins'), os.environ.get(
                                  b'BZR_PLUGIN_PATH', ''))).encode('utf-8')

        return SCMTool.popen(['bzr'] + args,
                             local_site_name=self.local_site_name,
                             env={
                                 b'BZR_PLUGIN_PATH':
                                 BZRClient._bzr_plugin_path,
                                 b'BZR_SSH': b'rbssh',
                             })
Esempio n. 3
0
    def _run_bzr(self, args):
        """Run a Bazaar command.

        This will run :command:`bzr` with the specified arguments, and sets
        up the environment to work with :command:`rbssh`.

        Args:
            args (list of unicode):
                The list of arguments to pass to :command:`bzr`.

        Returns:
            subprocess.Popen:
            The handle for the process.
        """
        bzr_exe = get_bzr_exe()
        plugin_path_envvar = _env_vars['PLUGIN_PATH'][bzr_exe]
        ssh_envvar = _env_vars['SSH'][bzr_exe]

        if not BZRClient._plugin_path:
            BZRClient._plugin_path = ('%s:%s' % (os.path.join(
                os.path.dirname(__file__), 'plugins', 'bzrlib',
                'plugins'), os.environ.get(str(plugin_path_envvar),
                                           str('')))).encode('utf-8')

        return SCMTool.popen([bzr_exe] + args,
                             local_site_name=self.local_site_name,
                             env={
                                 plugin_path_envvar: BZRClient._plugin_path,
                                 ssh_envvar: 'rbssh',
                                 'TZ': 'UTC',
                             })
Esempio n. 4
0
    def _run_bzr(self, args):
        """Run a Bazaar command.

        This will run :command:`bzr` with the specified arguments, and sets
        up the environment to work with :command:`rbssh`.

        Args:
            args (list of unicode):
                The list of arguments to pass to :command:`bzr`.

        Returns:
            subprocess.Popen:
            The handle for the process.
        """
        if not BZRClient._bzr_plugin_path:
            BZRClient._bzr_plugin_path = (
                '%s:%s' % (
                    os.path.join(os.path.dirname(__file__), 'plugins',
                                 'bzrlib', 'plugins'),
                    os.environ.get(str('BZR_PLUGIN_PATH'), str('')))
            ).encode('utf-8')

        return SCMTool.popen(
            ['bzr'] + args,
            local_site_name=self.local_site_name,
            env={
                b'BZR_PLUGIN_PATH': BZRClient._bzr_plugin_path,
                b'BZR_SSH': b'rbssh',
                b'TZ': b'UTC',
            })
Esempio n. 5
0
    def _run_hg(self, args):
        """Runs the Mercurial command, returning a subprocess.Popen."""
        if not self.default_args:
            self._calculate_default_args()

        return SCMTool.popen(
            ['hg'] + self.default_args + args,
            local_site_name=self.local_site_name)
Esempio n. 6
0
 def check_repository(self):
     # Running 'cvs version' and specifying a CVSROOT will bail out if said
     # CVSROOT is invalid, which is perfect for us. This used to use
     # 'cvs rls' which is maybe slightly more correct, but rls is only
     # available in CVS 1.12+
     p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'version'],
                       self.local_site_name)
     errmsg = six.text_type(p.stderr.read())
     if p.wait() != 0:
         raise SCMError(errmsg)
Esempio n. 7
0
 def check_repository(self):
     # Running 'cvs version' and specifying a CVSROOT will bail out if said
     # CVSROOT is invalid, which is perfect for us. This used to use
     # 'cvs rls' which is maybe slightly more correct, but rls is only
     # available in CVS 1.12+
     p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'version'],
                       self.local_site_name)
     errmsg = six.text_type(p.stderr.read())
     if p.wait() != 0:
         raise SCMError(errmsg)
Esempio n. 8
0
    def _cat_specific_file(self, filename, revision):
        # Somehow CVS sometimes seems to write .cvsignore files to current
        # working directory even though we force stdout with -p.
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)

        p = SCMTool.popen([
            'cvs', '-f', '-d', self.cvsroot, 'checkout', '-r',
            str(revision), '-p', filename
        ], self.local_site_name)
        contents = p.stdout.read()
        errmsg = p.stderr.read()
        failure = p.wait()

        # Unfortunately, CVS is not consistent about exiting non-zero on
        # errors.  If the file is not found at all, then CVS will print an
        # error message on stderr, but it doesn't set an exit code with
        # pservers.  If the file is found but an invalid revision is requested,
        # then cvs exits zero and nothing is printed at all. (!)
        #
        # But, when it is successful, cvs will print a header on stderr like
        # so:
        #
        # ===================================================================
        # Checking out foobar
        # RCS: /path/to/repo/foobar,v
        # VERS: 1.1
        # ***************

        # So, if nothing is in errmsg, or errmsg has a specific recognized
        # message, call it FileNotFound.
        if not errmsg or \
           errmsg.startswith('cvs checkout: cannot find module') or \
           errmsg.startswith('cvs checkout: could not read RCS file'):
            self.cleanup()
            raise FileNotFoundError(filename, revision)

        # Otherwise, if there's an exit code, or errmsg doesn't look like
        # successful header, then call it a generic SCMError.
        #
        # If the .cvspass file doesn't exist, CVS will return an error message
        # stating this. This is safe to ignore.
        if (failure and not errmsg.startswith('==========')) and \
           not ".cvspass does not exist - creating new file" in errmsg:
            self.cleanup()
            raise SCMError(errmsg)

        self.cleanup()
        return contents
Esempio n. 9
0
    def _cat_specific_file(self, filename, revision):
        # Somehow CVS sometimes seems to write .cvsignore files to current
        # working directory even though we force stdout with -p.
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)

        p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'checkout',
                           '-r', six.text_type(revision), '-p', filename],
                          self.local_site_name)
        contents = p.stdout.read()
        errmsg = six.text_type(p.stderr.read())
        failure = p.wait()

        # Unfortunately, CVS is not consistent about exiting non-zero on
        # errors.  If the file is not found at all, then CVS will print an
        # error message on stderr, but it doesn't set an exit code with
        # pservers.  If the file is found but an invalid revision is requested,
        # then cvs exits zero and nothing is printed at all. (!)
        #
        # But, when it is successful, cvs will print a header on stderr like
        # so:
        #
        # ===================================================================
        # Checking out foobar
        # RCS: /path/to/repo/foobar,v
        # VERS: 1.1
        # ***************

        # So, if nothing is in errmsg, or errmsg has a specific recognized
        # message, call it FileNotFound.
        if (not errmsg or
                errmsg.startswith('cvs checkout: cannot find module') or
                errmsg.startswith('cvs checkout: could not read RCS file')):
            self.cleanup()
            raise FileNotFoundError(filename, revision)

        # Otherwise, if there's an exit code, or errmsg doesn't look like
        # successful header, then call it a generic SCMError.
        #
        # If the .cvspass file doesn't exist, CVS will return an error message
        # stating this. This is safe to ignore.
        if ((failure and not errmsg.startswith('==========')) and
                not '.cvspass does not exist - creating new file' in errmsg):
            self.cleanup()
            raise SCMError(errmsg)

        self.cleanup()
        return contents
Esempio n. 10
0
    def check_repository(self):
        # Running 'cvs version' and specifying a CVSROOT will bail out if said
        # CVSROOT is invalid, which is perfect for us. This used to use
        # 'cvs rls' which is maybe slightly more correct, but rls is only
        # available in CVS 1.12+
        p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'version'],
                          self.local_site_name)
        errmsg = six.text_type(p.stderr.read())

        if p.wait() != 0:
            logging.error(
                'CVS repository validation failed for '
                'CVSROOT %s: %s', self.cvsroot, errmsg)

            auth_failed_prefix = 'cvs version: authorization failed: '

            # See if there's an "authorization failed" anywhere in here. If so,
            # we want to raise AuthenticationError with that error message.
            for line in errmsg.splitlines():
                if line.startswith(auth_failed_prefix):
                    raise AuthenticationError(
                        msg=line[len(auth_failed_prefix):].strip())

            raise SCMError(errmsg)
Esempio n. 11
0
    def check_repository(self):
        # Running 'cvs version' and specifying a CVSROOT will bail out if said
        # CVSROOT is invalid, which is perfect for us. This used to use
        # 'cvs rls' which is maybe slightly more correct, but rls is only
        # available in CVS 1.12+
        p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'version'],
                          self.local_site_name)
        errmsg = six.text_type(p.stderr.read())

        if p.wait() != 0:
            logging.error('CVS repository validation failed for '
                          'CVSROOT %s: %s',
                          self.cvsroot, errmsg)

            auth_failed_prefix = 'cvs version: authorization failed: '

            # See if there's an "authorization failed" anywhere in here. If so,
            # we want to raise AuthenticationError with that error message.
            for line in errmsg.splitlines():
                if line.startswith(auth_failed_prefix):
                    raise AuthenticationError(
                        msg=line[len(auth_failed_prefix):].strip())

            raise SCMError(errmsg)
Esempio n. 12
0
 def _run_git(self, args):
     """Runs a git command, returning a subprocess.Popen."""
     return SCMTool.popen(['git'] + args,
                          local_site_name=self.local_site_name)
Esempio n. 13
0
 def check_repository(self):
     p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'rls'],
                       self.local_site_name)
     errmsg = six.text_type(p.stderr.read())
     if p.wait() != 0:
         raise SCMError(errmsg)
Esempio n. 14
0
 def check_repository(self):
     p = SCMTool.popen(['cvs', '-f', '-d', self.cvsroot, 'rls'],
                       self.local_site_name)
     errmsg = six.text_type(p.stderr.read())
     if p.wait() != 0:
         raise SCMError(errmsg)