Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple method to obtain archived revision #45

Open
lukaszb opened this issue Jan 23, 2011 · 0 comments
Open

Simple method to obtain archived revision #45

lukaszb opened this issue Jan 23, 2011 · 0 comments

Comments

@lukaszb
Copy link
Member

lukaszb commented Jan 23, 2011

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant