[PATCH 2 of 6] revlog: introduce _chunkbase to allow filelog to override
Matt Mackall
mpm at selenic.com
Mon Feb 7 15:32:28 CST 2011
On Mon, 2011-02-07 at 11:27 +0100, Sune Foldager wrote:
> On 01-02-2011 00:44, Matt Mackall wrote:
> > On Mon, 2011-01-31 at 11:21 +0100, Sune Foldager wrote:
> >> # HG changeset patch
> >> # User Sune Foldager<cryo at cyanite.org>
> >> # Date 1296294467 -3600
> >> # Node ID 228f2570b1922c797b969dab28a28e3f1ec99cf7
> >> # Parent 90afd2364f5d05afe149156379fc3ee6dfd604fe
> >> revlog: introduce _chunkbase to allow filelog to override
> >>
> >> Used by revlog.revision to retrieve the base-chunk in a delta chain.
> >
> > Still not clear on why this is better than the normal superclass
> > technique.
>
> Hmm.. what do you mean? Not sure I follow completely :/
Your code does something like this with _chunkbase:
class a(object):
def foo(self):
return "a"
bar = foo # let us override foo
def baz(self):
print self.bar() # knows about override potential
class b(a):
def foo2(self):
# combine behavior from a and b
return self.foo() + "b"
bar = foo2
The normal 'superclass' approach is:
class a(object)
def foo(self):
return "a"
def baz(self):
print self.foo()
class b(b):
def foo(self):
return super(b, self).foo() + "b"
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list