Merge lp://staging/~xaav/loggerhead/export-tarball into lp://staging/loggerhead
- export-tarball
- Merge into trunk-rich
Status: | Superseded |
---|---|
Proposed branch: | lp://staging/~xaav/loggerhead/export-tarball |
Merge into: | lp://staging/loggerhead |
Diff against target: |
373 lines (+161/-13) (has conflicts) 9 files modified
loggerhead/apps/branch.py (+13/-2) loggerhead/config.py (+3/-0) loggerhead/controllers/__init__.py (+1/-1) loggerhead/controllers/download_ui.py (+39/-8) loggerhead/controllers/revision_ui.py (+19/-0) loggerhead/exporter.py (+46/-0) loggerhead/history.py (+5/-1) loggerhead/templates/revision.pt (+4/-1) loggerhead/tests/test_controllers.py (+31/-0) Text conflict in loggerhead/apps/branch.py Text conflict in loggerhead/controllers/revision_ui.py Text conflict in loggerhead/tests/test_controllers.py |
To merge this branch: | bzr merge lp://staging/~xaav/loggerhead/export-tarball |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil (community) | Needs Fixing | ||
Gavin Panella (community) | Needs Fixing | ||
Launchpad code reviewers | code | Pending | |
Robert Collins | Pending | ||
Martin Albisetti | Pending | ||
Review via email: mp+63931@code.staging.launchpad.net |
This proposal supersedes a proposal from 2011-05-31.
This proposal has been superseded by a proposal from 2011-06-30.
Commit message
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!
Martin Pool (mbp) wrote : Posted in a previous version of this proposal | # |
Robert Collins (lifeless) wrote : Posted in a previous version of this proposal | # |
This looks very interesting.
Three isues:
1)
+class TarExporterFile
+
+ 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 TarExporterFile
+
+ def __init__(self):
+ self._buffer = []
+
+ def write(self, str):
+ self._buffer.
+
+ def get_buffer(self):
+ try:
+ return ''.join(
+ 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.
xaav (xaav) wrote : Posted in a previous version of this proposal | # |
> 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.
Robert Collins (lifeless) wrote : Posted in a previous version of this proposal | # |
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.
xaav (xaav) wrote : Posted in a previous version of this proposal | # |
> 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.
xaav (xaav) wrote : Posted in a previous version of this proposal | # |
See Bug #791005 for further information on this.
xaav (xaav) wrote : Posted in a previous version of this proposal | # |
Okay, I think this should work, but I haven't tested it yet.
Martin Pool (mbp) wrote : | # |
Thanks, xaav.
When you say "haven't tested" do you mean just "not written any tests", or "not even been able to run it"?
xaav (xaav) wrote : | # |
I haven't written any tests (Sorry, I'll do this ASAP.)
I also have not been able to run it because I'm lazy and it requires too much work to get loggerhead running on W1nd0w$.
xaav (xaav) wrote : | # |
Okay, I've added a simple tarfile test. However, I am not able to run the test to I would appreciate if someone would do that for me and/or try to download a tarball from their browser.
Gavin Panella (allenap) wrote : | # |
Once I'd set up a virtualenv with the right prerequisites, I got the
following error when running the test suite:
{{{
Traceback (most recent call last):
...
File ".../loggerhead
from loggerhead.
File ".../loggerhead
from loggerhead.
File ".../loggerhead
from loggerhead.exporter import export_tarball
ImportError: cannot import name export_tarball
}}}
After fixing that I got the following error from
TestDownloadTar
{{{
Traceback (most recent call last):
File "/usr/lib/
return fn(*args, **kwargs)
File "/usr/lib/
return self._get_
File ".../loggerhead
app = self.setUpLogge
File ".../loggerhead
branch_app = BranchWSGIApp(
AttributeError: 'TestDownloadTa
}}}
Obviously this needs some work.
We've been talking about taking more of a "patch pilot" approach in
Launchpad. That seems to mean that one of the core team - fwiw, I
would be happy to do it - would actively help getting this landed,
rather than just reviewing it. Would you like that, or would you
prefer to iterate on your own?
xaav (xaav) wrote : | # |
Sorry, I had been gone. I will be sure and look into this right away!
On Thu, Jun 16, 2011 at 8:56 AM, Gavin Panella
<email address hidden>wrote:
> Review: Needs Fixing
> Once I'd set up a virtualenv with the right prerequisites, I got the
> following error when running the test suite:
>
> {{{
> Traceback (most recent call last):
> ...
> File ".../loggerhead
> from loggerhead.
> File ".../loggerhead
> from loggerhead.
> DownloadTarballUI
> File ".../loggerhead
> from loggerhead.exporter import export_tarball
> ImportError: cannot import name export_tarball
> }}}
>
> After fixing that I got the following error from
> TestDownloadTar
>
> {{{
> Traceback (most recent call last):
> File "/usr/lib/
> _run_user
> return fn(*args, **kwargs)
> File "/usr/lib/
> in _run_test_method
> return self._get_
> File ".../loggerhead
> test_download_
> app = self.setUpLogge
> File ".../loggerhead
> branch_app = BranchWSGIApp(
> AttributeError: 'TestDownloadTa
> }}}
>
> Obviously this needs some work.
>
> We've been talking about taking more of a "patch pilot" approach in
> Launchpad. That seems to mean that one of the core team - fwiw, I
> would be happy to do it - would actively help getting this landed,
> rather than just reviewing it. Would you like that, or would you
> prefer to iterate on your own?
>
> --
> https:/
> You are the owner of lp:~xaav/loggerhead/export-tarball.
>
xaav (xaav) wrote : | # |
We've been talking about taking more of a "patch pilot" approach in
Launchpad. That seems to mean that one of the core team - fwiw, I
would be happy to do it - would actively help getting this landed,
rather than just reviewing it. Would you like that, or would you
prefer to iterate on your own?
That would be great! Any help would be greatly appreciated.
xaav (xaav) wrote : | # |
Okay, I've fixed some stuff (the tests are still broken), but here is what I'm getting:
Traceback (most recent call last):
File "C:\Python27\
ine 1068, in process_
self.
File "C:\Python27\
self.
File "C:\Python27\
self.handle()
File "C:\Python27\
ine 442, in handle
BaseHTTPReq
File "C:\Python27\
self.
File "C:\Python27\
ine 437, in handle_one_request
self.
File "C:\Python27\
ine 289, in wsgi_execute
for chunk in result:
File "C:\Users\
xport_archive
for _ in get_export_
File "C:\Python27\
port_generator
root = get_root_name(dest)
File "C:\Python27\
ot_name
dest = os.path.
File "C:\Python27\
return split(p)[1]
File "C:\Python27\
d, p = splitdrive(p)
File "C:\Python27\
if p[1:2] == ':':
TypeError: 'NoneType' object is not subscriptable
Any help would be appreciated.
Gavin Panella (allenap) wrote : | # |
Cool. I am busy this week, but I might get to it. If not, next week for sure.
Vincent Ladeuil (vila) wrote : | # |
Hi,
I almost got the test running with some additional fixes
(available at lp:~vila/loggerhead/export-tarball) only to run
into a bug in bzr itself (I think you should be able to fix that
one ;).
Note that your code requires bzr >= 2.4 (launchpad only runs
2.3.3 so far) so we'll need some support from the lp guys to
deploy a more recent version there.
Summary of my fixes:
- you need to create a branch (with some content even) before
being able to call
app = self.setUpLogge
So I've added a setUp method for your class to do that. You
probably want to add *more* tests to check that you get a valid
tarball with the expected content (which an empty branch
doesn't allow ;).
- you're calling get_export_
the code in bzrlib defaults to dest to set root. This raises an
interesing point: which root should be used here (i.e. what do
we want to prefix all the paths in the archive
with). <project>-<branch nick>-<revno> may be nice (but ask
others for feedback too).
- you used '.tar.gz' for the format but bzr expects either 'tgz'
OR a dest file name to deduce the format from the file
suffix. I just used 'tgz' there.
With these fixes in place we get:
=======
ERROR: bzrlib.
-------
_StringException: Text attachment: log
------------
0.622 creating repository in file://
0.624 creating branch <bzrlib.
0.631 trying to create missing lock '/tmp/testbzr-
0.631 opening working tree '/tmp/testbzr-
0.642 export version <InventoryRevis
0.649 opening working tree '/tmp/testbzr-
------------
Text attachment: traceback
------------
Traceback (most recent call last):
File "/usr/lib/
return fn(*args, **kwargs)
File "/usr/lib/
return self._get_
File "/home/
res = app.get('/tarball')
File "/usr/lib/
return self.do_
File "/usr/lib/
**req.environ)
File "/usr/lib/
- 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.
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?