[MERGE] Add helper class versionedfile.VersionedFilesDecorator for use with RemoteRepository in future.
John Arbash Meinel
john at arbash-meinel.com
Tue Feb 24 15:08:05 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> As NEWS says, a helpful generic VersionedFilesDecorator; Andrew and I
> intend to use this to avoid calls to 'start_commit_group' on
> RemoteRepository having to call _ensure_real until actual operations are
> undertaken.
>
> -Rob
>
>
So IIRC, the idea is that you'll create one of this and *not* have
populated the _backing_vf yet. And then once a call is made, to
"repository.texts" (for example) it will call _ensure_real and then
populate _backing_vf and respond.
I'm a bit curious why you pass all the parameters to _hook_call, rather
than just alerting it that it is being called?
Also, why not use the __getattr__ pattern rather than having to proxy
each function?
If you are doing it this way, is there a way to hook it into the generic
tests, so that we are sure if we add a new VF api, that it also gets
implemented here?
I'm a little concerned about the overhead of calling _hook_call for
every action, though the only one we do a lot is get_parent_map. And
then it should be hundreds and not thousands (though on Emacs, it could
potentially be 80k or so). Probably it is ok.
+class RecordingVersionedFilesDecorator(VersionedFilesDecorator):
"""A minimal versioned files that records calls made on it.
...
Instead of passing a function to VFD.__init__ you create an explicit
'def _hook_call' function. I think it would be better as:
def _rvf_hook_call(self):
...
def __init__(self):
VFD.__init__(self, hook_call=self._rvf_hook_call)
Or some permutation on that.
I realize what you do *works*, but only as long as you don't call
super().__init__, which doesn't seem like a good policy to require. At a
minimum it needs to be documented in __init__. I would prefer if you
passed the hook_call parameter.
BB:tweak
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkmkDVUACgkQJdeBCYSNAAPvnwCffog22xvqMP03DLJlSOeQNUQE
x9EAnj2F0BHHWJBMBBc4kJl0eL2p1eYW
=V6Bb
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list