Exemple #1
0
    def add_file_from_string(self, filename, list_strings, commit_msg='',
                                 user=None):
        """
        Add a ``filename`` to the repo using the list of strings to create
        the file. A commit will be written to the repo is ``commit_msg`` is not
        empty.
        """
        fname = os.path.join(storage_dir, self.repo_path, filename)
        f = open(fname, 'w')
        f.writelines(list_strings)
        f.close()

        repo = DVCSRepo(backend, os.path.join(storage_dir, self.repo_path),
                             dvcs_executable=revisioning_executable)
        # Save the location for next time
        globals()['revisioning_executable'] = repo.executable

        # Only add this file
        try:
            repo.add([fname])
        except DVCSError as e:
            # Happens if a file with the same name already exists in the repo
            if e.value == 'Could not add one or more files to repository.':
                pass
            else:
                raise

        if commit_msg:
            repo.commit(commit_msg, user=user)
Exemple #2
0
    def add_file_from_string(self,
                             filename,
                             list_strings,
                             commit_msg='',
                             user=None):
        """
        Add a ``filename`` to the repo using the list of strings to create
        the file. A commit will be written to the repo is ``commit_msg`` is not
        empty.
        """
        fname = os.path.join(storage_dir, self.repo_path, filename)
        f = open(fname, 'w')
        f.writelines(list_strings)
        f.close()

        repo = DVCSRepo(backend,
                        os.path.join(storage_dir, self.repo_path),
                        dvcs_executable=revisioning_executable)
        # Save the location for next time
        globals()['revisioning_executable'] = repo.executable

        # Only add this file
        try:
            repo.add([fname])
        except DVCSError as e:
            # Happens if a file with the same name already exists in the repo
            if e.value == 'Could not add one or more files to repository.':
                pass
            else:
                raise

        if commit_msg:
            repo.commit(commit_msg, user=user)
Exemple #3
0
    def add_file(self, pattern, commit_msg='', user=None, repo=None):
        """
        Add a single file, or a file ``pattern``, to the repo.
        A commit will be written to the repo if ``commit_msg`` is not empty.
        """
        if repo is None:
            repo = DVCSRepo(backend,
                            os.path.join(storage_dir, self.repo_path),
                            do_init=False,
                            dvcs_executable=revisioning_executable)

        try:
            repo.add([pattern])
        except DVCSError as e:
            logger.error('DVCS error: %s' % e.original_message)

        if commit_msg:
            repo.commit(commit_msg, user=user)
Exemple #4
0
    def add_file(self, pattern, commit_msg='', user=None, repo=None):
        """
        Add a single file, or a file ``pattern``, to the repo.
        A commit will be written to the repo if ``commit_msg`` is not empty.
        """
        if repo is None:
            repo = DVCSRepo(backend, os.path.join(storage_dir, self.repo_path),
                            do_init=False,
                            dvcs_executable=revisioning_executable)


        try:
            repo.add([pattern])
        except DVCSError as e:
            logger.error('DVCS error: %s' % e.original_message)


        if commit_msg:
            repo.commit(commit_msg, user=user)