You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 !
: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" :)
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.
def get_chunked_archive(self, **kwargs):
"""
Returns iterable archive. Tiny wrapper around
get_archive
method.}}}
Marcin, if you accept this, please change issue type to "enchancement" :)
Reference: https://bitbucket.org/marcinkuzminski/vcs/issues/45/
The text was updated successfully, but these errors were encountered: