changeset 745:6252f0cc7b7a

svnmeta: cache the UUID in an attribute. We use a try/except clause in the getter to keep complicated logic in the setter.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 11 Nov 2010 21:30:31 +0100
parents 6d6be5284056
children 174f03c288d4
files hgsubversion/svnmeta.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -44,7 +44,7 @@ class SVNMeta(object):
 
         if not os.path.isdir(self.meta_data_dir):
             os.makedirs(self.meta_data_dir)
-        self._set_uuid(uuid)
+        self.uuid = uuid
         # TODO: validate subdir too
         self.revmap = maps.RevMap(repo)
 
@@ -127,7 +127,11 @@ class SVNMeta(object):
         return self._editor
 
     def _get_uuid(self):
-        return open(os.path.join(self.meta_data_dir, 'uuid')).read()
+        try:
+            return self.__uuid
+        except AttributeError:
+            self.__uuid = open(os.path.join(self.meta_data_dir, 'uuid')).read()
+            return self.__uuid
 
     def _set_uuid(self, uuid):
         if not uuid:
@@ -145,6 +149,8 @@ class SVNMeta(object):
             else:
                 raise hgutil.Abort('unable to operate on unrelated repository')
 
+        self.__uuid = uuid
+
     uuid = property(_get_uuid, _set_uuid, None,
                     'Error-checked UUID of source Subversion repository.')