[patch] hashcache fixes
Martin Pool
mbp at canonical.com
Mon Jul 10 11:56:23 BST 2006
On 10 Jul 2006, Andrew Bennetts <andrew at canonical.com> wrote:
> I assumed you could also set ctime directly, but digging around a bit I appear
> to be wrong about that.
No, you can't.
> Looking at the problem from a strict testability point of view, this suggests
> the code isn't factored well enough. What if the _fingerprint function was a
> method of HashCache objects instead, so test cases can override it to return
> modified results -- e.g.:
>
> class InstrumentedHashCache(HashCache):
>
> def _fingerprint(self, abspath):
> # always return a ctime at least 1 day in the past
> fp = list(HashCache._fingerprint(self, abspath))
> fp[FP_CTIME_COLUMN] -= 86400
> return tuple(fp)
>
> Or whatever logic the test wants (e.g. you could conditionally change behaviour
> depending on the filename).
Yes, that's pretty tasteful.
--
Martin
More information about the bazaar
mailing list