Skip to content

Simple method to obtain archived revision #45

@lukaszb

Description

@lukaszb

Let's not copy this functionality all the time ;-)

I propose two new methods for BaseChangeset. This way all backends could create archives for given changeset, plus methods can be easily overridden if backend offers own implementation (i.e. mercurial's archival module).

First I wanted to make default stream new StringIO instance, however on the second thought am not sure about memory consumption for big (in size) changesets. Am I correct here?

{{{
def get_archive(self, stream=None, kind=None, prefix=None):
"""
Returns archived changeset contents, as stream. Default stream is tempfile as for huge
changesets we could eat memory.

:param stream: file like object. Default: new ``tempfile.TemporaryFile`` instance.
:param kind: one of following: ``zip``, ``tar``, ``tgz`` or ``tbz2``. Default: ``tgz``.
:param prefix: name of root directory in archive. Default is repository name and
  changeset's raw_id joined with dash.
"""
# TODO !

def get_chunked_archive(self, **kwargs):
"""
Returns iterable archive. Tiny wrapper around get_archive method.

:param chunk_size: extra parameter which controls size of returned chunks. Default:
  8k.
"""
chunk_size = kwargs.pop('chunk_size', 8192)
archive = self.get_archive(**kwargs)
while True:
    data = archive.read(chunk_size)
    if not data:
        break
    yield data

}}}

Marcin, if you accept this, please change issue type to "enchancement" :)


Reference: https://bitbucket.org/marcinkuzminski/vcs/issues/45/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions