diff hgsubversion/layouts/standard.py @ 1026:66395f232b7c

layouts: pull tag location list management into layout module We keep a list of locations within subversion where we look for tags that persists across runs. This pulls the logic for constructiong that list from config on first clone, and for mainting the list afterwards out of svnmeta and into layouts.
author David Schleimer <dschleimer@fb.com>
date Tue, 21 May 2013 16:29:18 -0700
parents 0ed7cf23e801
children 16045f6f3fef
line wrap: on
line diff
--- a/hgsubversion/layouts/standard.py
+++ b/hgsubversion/layouts/standard.py
@@ -1,11 +1,17 @@
-
+import os.path
+import pickle
 
 import base
-
+import hgsubversion.util as util
 
 class StandardLayout(base.BaseLayout):
     """The standard trunk, branches, tags layout"""
 
+    def __init__(self, ui):
+        base.BaseLayout.__init__(self, ui)
+
+        self._tag_locations = None
+
     def localname(self, path):
         if path == 'trunk':
             return None
@@ -29,3 +35,24 @@ class StandardLayout(base.BaseLayout):
                 branchpath = 'branches/%s' % branch
 
         return '%s/%s' % (subdir or '', branchpath)
+
+    def taglocations(self, meta_data_dir):
+        if self._tag_locations is None:
+
+            tag_locations_file = os.path.join(meta_data_dir, 'tag_locations')
+
+            if os.path.exists(tag_locations_file):
+                f = open(tag_locations_file)
+                self._tag_locations = pickle.load(f)
+                f.close()
+            else:
+                self._tag_locations = self.ui.configlist('hgsubversion',
+                                                        'tagpaths',
+                                                        ['tags'])
+            util.pickle_atomic(self._tag_locations, tag_locations_file)
+
+            # ensure nested paths are handled properly
+            self._tag_locations.sort()
+            self._tag_locations.reverse()
+
+        return self._tag_locations