[PATCH 1 of 5 STABLE] filecache: pass func name that constructs the full path of the given file
mpm at selenic.com
Wed Feb 29 13:10:26 CST 2012
On Wed, 2012-02-29 at 10:54 +0200, Idan Kamara wrote:
> On Wed, Feb 29, 2012 at 2:20 AM, Matt Mackall <mpm at selenic.com> wrote:
> > On Wed, 2012-02-29 at 01:40 +0200, Idan Kamara wrote:
> > > On Wed, Feb 29, 2012 at 12:59 AM, Matt Mackall <mpm at selenic.com> wrote:
> > > > Making this work cleanly is a simple matter of localizing the
> > > > path-joining logic to a single method that the derived class overrides:
> > > >
> > > > class storecache(scmutil.filecache):
> > > > def join(self, obj, fname):
> > > > return obj.sjoin(fname)
> > >
> > >
> > > I guess that's better, except it forces all clients of such classes
> > > to name their join function the same.
> > No, because this entire class is now specifically tailored for caching
> > store files for localrepo methods (note the 'sjoin'). The class is
> > tailored to the client, the client just needs to use the appropriate
> > class.
> localrepo and dirstate both need a cache for repo files, so now we have
> two 'repocache' classes, one for localrepo's 'join' and another that uses
> whatever dirstate calls its repo-relative join function?
> Unless I misunderstand what you mean here, I don't see how this is
> less yucky than my original suggestion.
If you don't already see that passing around pointers to functions as
strings is hacky in the extreme, I really don't know what to tell you.
The only other place we pass around function names by string is
extensions.wrapfunction, which is inherently introspective. I expect
you'll have a hard time finding anywhere else this is done in the Python
 Though we could try to map a symbol back to its string name by
walking the container dictionary, that's unreliable since it may not be
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel