Merge lp://staging/~xaav/loggerhead/export-tarball into lp://staging/loggerhead

Proposed by xaav
Status: Superseded
Proposed branch: lp://staging/~xaav/loggerhead/export-tarball
Merge into: lp://staging/loggerhead
Diff against target: 242 lines (+81/-6)
9 files modified
.bzrignore (+1/-0)
loggerhead/apps/branch.py (+9/-3)
loggerhead/config.py (+3/-0)
loggerhead/controllers/__init__.py (+1/-1)
loggerhead/controllers/download_ui.py (+18/-0)
loggerhead/controllers/revision_ui.py (+2/-1)
loggerhead/exporter.py (+40/-0)
loggerhead/history.py (+3/-0)
loggerhead/templates/revision.pt (+4/-1)
To merge this branch: bzr merge lp://staging/~xaav/loggerhead/export-tarball
Reviewer Review Type Date Requested Status
Robert Collins Needs Fixing
Martin Albisetti Pending
Review via email: mp+62941@code.staging.launchpad.net

This proposal has been superseded by a proposal from 2011-06-08.

Description of the change

This branch **may** accomplish exporting the tarball using chunked transfer encoding. The code all looks to be correct, but I have not tested it, so I would like your opinion.

Thanks!

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Thanks very much, that'd be a really useful feature to have. Thanks
also for making it optional, because probably some installations would
not want it on.

This looks broadly reasonable -- I'm not deeply familiar with
loggerhead -- but I am very curious why you apparently reimplemented
the export-to-tarball feature. I'd rather reuse the bzr code and if
necessary change it to let it be reused here.

When you say "not tested" do you mean you haven't even run it, or only
that you didn't add automatic tests?

Revision history for this message
Robert Collins (lifeless) wrote :

This looks very interesting.

Three isues:

1)
+class TarExporterFileObject(object):
+
+ def __init__(self):
+ self._buffer = ''
+
+ def write(self, str):
+ self._buffer += str
+
+ def get_buffer(self):
+ buffer = self._buffer
+ self._buffer = ''
+ return buffer

This is going to be somewhat inefficient. Try this:

+class TarExporterFileObject(object):
+
+ def __init__(self):
+ self._buffer = []
+
+ def write(self, str):
+ self._buffer.append(str)
+
+ def get_buffer(self):
+ try:
+ return ''.join(self._buffer)
+ finally:
+ self._buffer = []

2) There are no tests for this. the test suite is still pretty new, but its a good idea to test things - in particular in cases like this we need to be fairly confident it will be incremental and not block on the export - I can imagine the wsgi layer buffering everything, for instance. [in fact, I'll lay odds it will unless we fix a few things].

3) The export function is a copy-paste-tweak of the core from bzrlib. This will lead to bugs as that code base evolves - we should instead get a supported function in bzrlib lib that we can import and use.

I'm putting this back to WIP - but its a great start. Please keep at it and just shout if you need pointers.

review: Needs Fixing
Revision history for this message
xaav (xaav) wrote :

> 3) The export function is a copy-paste-tweak of the core from bzrlib. This will lead to bugs as
> that code base evolves - we should instead get a supported function in bzrlib lib that we can
> import and use.

Well, there is only one problem with that. According to the WSGI spec, you must return an iterable that will export the blocks. If I were to call the provided function, it would be impossible to break the response into pieces because the provided function would export it all at once. I know that it is a copy and paste tweak, but there is really no way I can inject the 'yield' keyword into the provided function. If you have another suggestion, I would be glad to hear it.

Issue number one I will be glad to fix.

Regarding issue number two, I have not written tests before but I will try my best.

Revision history for this message
Robert Collins (lifeless) wrote :

On Wed, Jun 1, 2011 at 9:46 AM, Geoff <email address hidden> wrote:
>> 3) The export function is a copy-paste-tweak of the core from bzrlib. This will lead to bugs as
>> that code base evolves - we should instead get a supported function in bzrlib lib that we can
>> import and use.
>
> Well, there is only one problem with that. According to the WSGI spec, you must return an iterable that will export the blocks. If I were to call the provided function, it would be impossible to break the response into pieces because the provided function would export it all at once. I know that it is a copy and paste tweak, but there is really no way I can inject the 'yield' keyword into the provided function. If you have another suggestion, I would be glad to hear it.

Extract the function in bzrlib into two parts - a generator (what you
have here) and a consumer than consumes it all triggering the writes.

Then we can reuse the generator.

Revision history for this message
xaav (xaav) wrote :

> On Wed, Jun 1, 2011 at 9:46 AM, Geoff <email address hidden> wrote:
> >> 3) The export function is a copy-paste-tweak of the core from bzrlib. This
> will lead to bugs as
> >> that code base evolves - we should instead get a supported function in
> bzrlib lib that we can
> >> import and use.
> >
> > Well, there is only one problem with that. According to the WSGI spec, you
> must return an iterable that will export the blocks. If I were to call the
> provided function, it would be impossible to break the response into pieces
> because the provided function would export it all at once. I know that it is a
> copy and paste tweak, but there is really no way I can inject the 'yield'
> keyword into the provided function. If you have another suggestion, I would be
> glad to hear it.
>
> Extract the function in bzrlib into two parts - a generator (what you
> have here) and a consumer than consumes it all triggering the writes.
>
> Then we can reuse the generator.

Okay, I see what you mean.

Revision history for this message
xaav (xaav) wrote :

See Bug #791005 for further information on this.

441. By xaav

Cleaned up TarExporterFileObject

442. By xaav

Updated exporter to use bzr patch.

443. By xaav

Cleaned up files.

Revision history for this message
xaav (xaav) wrote :

Okay, I think this should work, but I haven't tested it yet.

444. By xaav

Finished up.

445. By xaav

Added tarfile test.

446. By xaav

Fixed import.

447. By xaav

Fixed code issues.

448. By xaav <email address hidden>

modified bzrignore

449. By xaav <email address hidden>

Merged branch

450. By xaav

Fixed gzip bug.

451. By xaav <email address hidden>

Merged lp:loggerhead

452. By xaav <email address hidden>

Fixed extension issue

453. By xaav

Fixed buggy merging.

454. By xaav <email address hidden>

Fixed buggy merging and removed IDE files

455. By xaav

Fixed serve tarballs issue.

456. By xaav

Fixed tests.

457. By xaav

Added to UI.

458. By xaav

UI fixes.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches