1. Augie Fackler
  2. hgsubversion

Commits

David Schleimer  committed 66395f2

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.

  • Participants
  • Parent commits 2bf860f
  • Branches default

Comments (0)

Files changed (4)

File hgsubversion/layouts/base.py

View file
 
         """
         self.__unimplemented('remotepath')
+
+    def taglocations(self, meta_data_dir):
+        """Return a list of locations within svn to search for tags
+
+        Should be returned in reverse-sorted order.
+
+        """
+        self.__unimplemented('tagpaths')

File hgsubversion/layouts/single.py

View file
 
     def remotepath(self, branch, subdir='/'):
         return subdir or '/'
+
+    def taglocations(self, meta_data_dir):
+        return []

File hgsubversion/layouts/standard.py

View file
-
+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
                 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

File hgsubversion/svnmeta.py

View file
 
         author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
         authors = util.configpath(self.ui, 'authormap')
-        tag_locations = self.ui.configlist('hgsubversion', 'tagpaths', ['tags'])
         self.usebranchnames = self.ui.configbool('hgsubversion',
                                                  'usebranchnames', True)
         branchmap = util.configpath(self.ui, 'branchmap')
             f.close()
         self.prevbranches = dict(self.branches)
         self.tags = maps.Tags(repo)
-        if os.path.exists(self.tag_locations_file):
-            f = open(self.tag_locations_file)
-            self.tag_locations = pickle.load(f)
-            f.close()
-        else:
-            self.tag_locations = tag_locations
         self._layout = layouts.detect.layout_from_file(self.meta_data_dir,
                                                        ui=self.repo.ui)
         self._layoutobj = None
-        util.pickle_atomic(self.tag_locations, self.tag_locations_file)
-        # ensure nested paths are handled properly
-        self.tag_locations.sort()
-        self.tag_locations.reverse()
 
         self.authors = maps.AuthorMap(self.ui, self.authors_file,
                                  defaulthost=author_host)
         return os.path.join(self.meta_data_dir, 'branch_info')
 
     @property
-    def tag_locations_file(self):
-        return os.path.join(self.meta_data_dir, 'tag_locations')
-
-    @property
     def authors_file(self):
         return os.path.join(self.meta_data_dir, 'authors')
 
         """
         if self.layout != 'single':
             path = self.normalize(path)
-            for tagspath in self.tag_locations:
+            for tagspath in self.layoutobj.taglocations(self.meta_data_dir):
                 if path.startswith(tagspath + '/'):
                     tag = path[len(tagspath) + 1:]
                     if tag: