# HG changeset patch # User Matt Mackall # Date 1240782644 18000 # Node ID dd8d5be57d65ef03ebc7348b0e14aa8518685983 # Parent cce63ef1045b31ea292cb9005677f1deffc5e0e0 util: take propertycache from context.py diff -r cce63ef1045b -r dd8d5be57d65 mercurial/context.py --- a/mercurial/context.py Sun Apr 26 16:50:44 2009 -0500 +++ b/mercurial/context.py Sun Apr 26 16:50:44 2009 -0500 @@ -9,14 +9,7 @@ from i18n import _ import ancestor, bdiff, error, util, os, errno -class propertycache(object): - def __init__(self, func): - self.func = func - self.name = func.__name__ - def __get__(self, obj, type=None): - result = self.func(obj) - setattr(obj, self.name, result) - return result +propertycache = util.propertycache class changectx(object): """A changecontext object makes access to data related to a particular diff -r cce63ef1045b -r dd8d5be57d65 mercurial/util.py --- a/mercurial/util.py Sun Apr 26 16:50:44 2009 -0500 +++ b/mercurial/util.py Sun Apr 26 16:50:44 2009 -0500 @@ -137,6 +137,15 @@ return f +class propertycache(object): + def __init__(self, func): + self.func = func + self.name = func.__name__ + def __get__(self, obj, type=None): + result = self.func(obj) + setattr(obj, self.name, result) + return result + def pipefilter(s, cmd): '''filter string S through command CMD, returning its output''' (pin, pout) = popen2(cmd, 'b')