Merge lp:~jelmer/bzr/repo-size into lp:bzr
| Status: | Rejected |
|---|---|
| Rejected by: | Jelmer Vernooij on 2010-02-28 |
| Proposed branch: | lp:~jelmer/bzr/repo-size |
| Merge into: | lp:bzr |
| Diff against target: |
136 lines (+55/-1) 7 files modified
NEWS (+3/-0) bzrlib/remote.py (+10/-0) bzrlib/repository.py (+6/-1) bzrlib/smart/repository.py (+13/-0) bzrlib/smart/request.py (+3/-0) bzrlib/tests/per_repository/test_statistics.py (+10/-0) bzrlib/tests/test_smart.py (+10/-0) |
| To merge this branch: | bzr merge lp:~jelmer/bzr/repo-size |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Robert Collins (community) | 2009-12-25 | Needs Fixing on 2009-12-25 | |
|
Review via email:
|
|||
| Jelmer Vernooij (jelmer) wrote : | # |
| Robert Collins (lifeless) wrote : | # |
On Fri, 2009-12-25 at 15:36 +0000, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr/repo-size into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #123653 "bzr info" depends on private Repository.
> https:/
>
>
> This patch adds a custom implementation of Repository.__len__ that
> returns the number of revisions in the repository.
>
> This is mainly convenient for foreign branch plugins, which do not
> provide Repository.
> on len(Repository.
> it.
Generally we avoid giving objects that are not dicts or sequences a
__len__, and I think its awfully prone to confusion here too, so we
should not do that. I thought that this had been written down somewhere
- you may wish to briefly look for it in the dev docs and if not found
add a note to this effect: only make things look like containers if they
feel like them too. (that is that you won't be surprised as a user).
Rather, I suggest you put the revision count into the output of
gather_stats: its not guaranteed to be cheap for all repositories, so
there is every reason to make it optional.
review needs-fixing
| Jelmer Vernooij (jelmer) wrote : | # |
On Fri, 2009-12-25 at 19:21 +0000, Robert Collins wrote:
> Review: Needs Fixing
> On Fri, 2009-12-25 at 15:36 +0000, Jelmer Vernooij wrote:
> > Jelmer Vernooij has proposed merging lp:~jelmer/bzr/repo-size into lp:bzr.
> >
> > Requested reviews:
> > bzr-core (bzr-core)
> > Related bugs:
> > #123653 "bzr info" depends on private Repository.
> > https:/
> >
> >
> > This patch adds a custom implementation of Repository.__len__ that
> > returns the number of revisions in the repository.
> >
> > This is mainly convenient for foreign branch plugins, which do not
> > provide Repository.
> > on len(Repository.
> > it.
>
> Generally we avoid giving objects that are not dicts or sequences a
> __len__, and I think its awfully prone to confusion here too, so we
> should not do that. I thought that this had been written down somewhere
> - you may wish to briefly look for it in the dev docs and if not found
> add a note to this effect: only make things look like containers if they
> feel like them too. (that is that you won't be surprised as a user).
>
> Rather, I suggest you put the revision count into the output of
> gather_stats: its not guaranteed to be cheap for all repositories, so
> there is every reason to make it optional.
As I mentioned in my merge request, it's already part of gather_stats()
but I'd like to have it in a separate function so I can override it for
subclasses. Would it be acceptable if I just renamed __len__ to
_get_revision_
Cheers,
Jelmer
| Robert Collins (lifeless) wrote : | # |
On Sat, 2009-12-26 at 00:51 +0000, Jelmer Vernooij wrote:
> > Generally we avoid giving objects that are not dicts or sequences a
> > __len__, and I think its awfully prone to confusion here too, so we
> > should not do that. I thought that this had been written down somewhere
> > - you may wish to briefly look for it in the dev docs and if not found
> > add a note to this effect: only make things look like containers if they
> > feel like them too. (that is that you won't be surprised as a user).
> >
> > Rather, I suggest you put the revision count into the output of
> > gather_stats: its not guaranteed to be cheap for all repositories, so
> > there is every reason to make it optional.
> As I mentioned in my merge request, it's already part of gather_stats()
> but I'd like to have it in a separate function so I can override it for
> subclasses. Would it be acceptable if I just renamed __len__ to
> _get_revision_
Or you could just delete printing the number of revisions. I don't think
a method on repository is a particularly good idea; if anything a method
on repository.
overridden, trying to avoid overriding it is odd to me :).
Another alternative would be to make the check for whether to attempt to
calculate the revision count more sophisticated.
-Rob
| Jelmer Vernooij (jelmer) wrote : | # |
Le samedi 26 décembre 2009 à 19:51 +0000, Robert Collins a écrit :
> On Sat, 2009-12-26 at 00:51 +0000, Jelmer Vernooij wrote:
> > > Generally we avoid giving objects that are not dicts or sequences a
> > > __len__, and I think its awfully prone to confusion here too, so we
> > > should not do that. I thought that this had been written down somewhere
> > > - you may wish to briefly look for it in the dev docs and if not found
> > > add a note to this effect: only make things look like containers if they
> > > feel like them too. (that is that you won't be surprised as a user).
> > >
> > > Rather, I suggest you put the revision count into the output of
> > > gather_stats: its not guaranteed to be cheap for all repositories, so
> > > there is every reason to make it optional.
> > As I mentioned in my merge request, it's already part of gather_stats()
> > but I'd like to have it in a separate function so I can override it for
> > subclasses. Would it be acceptable if I just renamed __len__ to
> > _get_revision_
> Or you could just delete printing the number of revisions. I don't think
> a method on repository is a particularly good idea; if anything a method
> on repository.
Except the foreign repository implementations don't necessarily
have .revisions set to something sane.
> However, gather_stats is *intended* to be
> overridden, trying to avoid overriding it is odd to me :).
>
> Another alternative would be to make the check for whether to attempt to
> calculate the revision count more sophisticated.
So, the reason I am trying to avoid overriding it is because it is quite
a big function and I would like to avoid duplicating all of that code in
all of the foreign branch plugins.
I think printing the number of revisions in "bzr info" is actually quite
useful, I've used it on several occasions.
Cheers,
Jelmer
| Martin Pool (mbp) wrote : | # |
2009/12/26 Robert Collins <email address hidden>:
> Generally we avoid giving objects that are not dicts or sequences a
> __len__, and I think its awfully prone to confusion here too, so we
> should not do that. I thought that this had been written down somewhere
> - you may wish to briefly look for it in the dev docs and if not found
> add a note to this effect: only make things look like containers if they
> feel like them too. (that is that you won't be surprised as a user).
+1
--
Martin <http://
| Robert Collins (lifeless) wrote : | # |
> > However, gather_stats is *intended* to be
> > overridden, trying to avoid overriding it is odd to me :).
> >
> > Another alternative would be to make the check for whether to attempt to
> > calculate the revision count more sophisticated.
> So, the reason I am trying to avoid overriding it is because it is quite
> a big function and I would like to avoid duplicating all of that code in
> all of the foreign branch plugins.
>
> I think printing the number of revisions in "bzr info" is actually quite
> useful, I've used it on several occasions.
So, its expensive for you because there isn't a size/len/area style function on .revisions? How about we add one there?
| Jelmer Vernooij (jelmer) wrote : | # |
Well, we don't have .revisions in the case of e.g. subversion, Repository.
| Robert Collins (lifeless) wrote : | # |
I'm basically very hesitant to be adding more methods to Repository as a whole. Its overly big (still).
| Jelmer Vernooij (jelmer) wrote : | # |
> I'm basically very hesitant to be adding more methods to Repository as a
> whole. Its overly big (still).
Darn, that's a good point. I'll look at alternatives.
| Vincent Ladeuil (vila) wrote : | # |
>>>>> "Jelmer" == Jelmer Vernooij <email address hidden> writes:
Jelmer> Well, we don't have .revisions in the case of e.g. subversion, Repository.
Set it to [] instead ;-p
Vincent
Unmerged revisions
- 4926. By Jelmer Vernooij on 2009-12-25
-
Repository.__len__ will now return the number of revisions in the repository.

This patch adds a custom implementation of Repository.__len__ that
returns the number of revisions in the repository.
This is mainly convenient for foreign branch plugins, which do not revisions. Currently Repository. gather_ stats() relies revisions) , so foreign branch plugins have to override
provide Repository.
on len(Repository.
it.
Cheers,
Jelmer