Files @ 9855b31d033b
Branch filter:

Location: kallithea/rhodecode/lib/vcs/utils/archivers.py

Mads Kiilerich
pullrequests: fix changesets ordering being reversed when creating new pull requests

41b4edf77b5b tried to make the displayed order of changeset consistent: The
topmost is always the latest.

That did however also reverse the ordering of the changesets sent back in the
post when used in the pull request creation form. Displaying the pull request
later on would reverse it again and thus show it in the 'wrong' order.

We now undo that reversing when creating the pull requests, and the stored data
will thus be the same as before.
# -*- coding: utf-8 -*-
"""
    vcs.utils.archivers
    ~~~~~~~~~~~~~~~~~~~

    set of archiver functions for creating archives from repository content

    :created_on: Jan 21, 2011
    :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""


class BaseArchiver(object):

    def __init__(self):
        self.archive_file = self._get_archive_file()

    def addfile(self):
        """
        Adds a file to archive container
        """
        pass

    def close(self):
        """
        Closes and finalizes operation of archive container object
        """
        self.archive_file.close()

    def _get_archive_file(self):
        """
        Returns container for specific archive
        """
        raise NotImplementedError()


class TarArchiver(BaseArchiver):
    pass


class Tbz2Archiver(BaseArchiver):
    pass


class TgzArchiver(BaseArchiver):
    pass


class ZipArchiver(BaseArchiver):
    pass


def get_archiver(self, kind):
    """
    Returns instance of archiver class specific to given kind

    :param kind: archive kind
    """

    archivers = {
        'tar': TarArchiver,
        'tbz2': Tbz2Archiver,
        'tgz': TgzArchiver,
        'zip': ZipArchiver,
    }

    return archivers[kind]()