From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/7] Add caching to the new config class.
Date: Tue, 30 Jan 2007 00:05:30 +0100 [thread overview]
Message-ID: <20070129230530.7102.65330.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070129230117.7102.64322.stgit@gandelf.nowhere.earth>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
stgit/config.py | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/stgit/config.py b/stgit/config.py
index d42754b..901f600 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -39,6 +39,8 @@ class GitConfig:
'stgit.shortnr': '5'
}
+ __cache={}
+
def __run(self, cmd, args=None):
"""__run: runs cmd using spawnvp.
@@ -59,20 +61,31 @@ class GitConfig:
return 0
def get(self, name):
+ if self.__cache.has_key(name):
+ return self.__cache[name]
+
stream = os.popen('git repo-config --get %s' % name, 'r')
value = stream.readline().strip()
stream.close()
if len(value) > 0:
- return value
+ pass
elif (self.__defaults.has_key(name)):
- return self.__defaults[name]
+ value = self.__defaults[name]
else:
- return None
+ value = None
+
+ self.__cache[name] = value
+ return value
def getall(self, name):
+ if self.__cache.has_key(name):
+ return self.__cache[name]
+
stream = os.popen('git repo-config --get-all %s' % name, 'r')
values = [line.strip() for line in stream]
stream.close()
+
+ self.__cache[name] = values
return values
def getint(self, name):
next prev parent reply other threads:[~2007-01-29 23:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-29 23:05 [PATCH 0/7] StGIT, remotes, and parent Yann Dirson
2007-01-29 23:05 ` [PATCH 1/7] Make stgit.config use git-repo-config Yann Dirson
2007-01-29 23:05 ` Yann Dirson [this message]
2007-01-29 23:05 ` [PATCH 3/7] Move identification of parent branch's remote def up into stack class Yann Dirson
2007-01-29 23:05 ` [PATCH 4/7] Allows extraction of information about remotes Yann Dirson
2007-01-29 23:05 ` [PATCH 5/7] Basic support for keeping a ref to the parent branch Yann Dirson
2007-01-29 23:05 ` [PATCH 6/7] Have 'stg branch --create' record parent information Yann Dirson
2007-01-29 23:05 ` [PATCH 7/7] Make 'stg pull' use git-fetch and not git-pull Yann Dirson
2007-01-31 23:44 ` Catalin Marinas
2007-02-01 18:47 ` Yann Dirson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070129230530.7102.65330.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).