Пример #1
0
    def commit_change(self, repo, repo_name, cs, user, author, message, content,
                      f_path):

        if repo.alias == 'hg':
            from vcs.backends.hg import MercurialInMemoryChangeset as IMC
        elif repo.alias == 'git':
            from vcs.backends.git import GitInMemoryChangeset as IMC

        # decoding here will force that we have proper encoded values
        # in any other case this will throw exceptions and deny commit
        content = safe_str(content)
        message = safe_str(message)
        path = safe_str(f_path)
        author = safe_str(author)
        m = IMC(repo)
        m.change(FileNode(path, content))
        tip = m.commit(message=message,
                 author=author,
                 parents=[cs], branch=cs.branch)

        new_cs = tip.short_id
        action = 'push_local:%s' % new_cs

        action_logger(user, action, repo_name)

        self.mark_for_invalidation(repo_name)
Пример #2
0
    def create_node(self, repo, repo_name, cs, user, author, message, content,
                      f_path):
        if repo.alias == 'hg':
            from vcs.backends.hg import MercurialInMemoryChangeset as IMC
        elif repo.alias == 'git':
            from vcs.backends.git import GitInMemoryChangeset as IMC
        # decoding here will force that we have proper encoded values
        # in any other case this will throw exceptions and deny commit

        if isinstance(content, (basestring,)):
            content = safe_str(content)
        elif isinstance(content, file):
            content = content.read()

        message = safe_str(message)
        path = safe_str(f_path)
        author = safe_str(author)
        m = IMC(repo)

        if isinstance(cs, EmptyChangeset):
            # Emptychangeset means we we're editing empty repository
            parents = None
        else:
            parents = [cs]

        m.add(FileNode(path, content=content))
        tip = m.commit(message=message,
                 author=author,
                 parents=parents, branch=cs.branch)
        new_cs = tip.short_id
        action = 'push_local:%s' % new_cs

        action_logger(user, action, repo_name)

        self.mark_for_invalidation(repo_name)