changeset 1027:16045f6f3fef

layouts: pull svn path -> potential tag name mapping into layouts
author David Schleimer <dschleimer@fb.com>
date Wed, 26 Jun 2013 14:40:31 -0500
parents 66395f232b7c
children c4b25a903ad3
files hgsubversion/layouts/base.py hgsubversion/layouts/single.py hgsubversion/layouts/standard.py hgsubversion/svnmeta.py
diffstat 4 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/layouts/base.py
+++ b/hgsubversion/layouts/base.py
@@ -49,3 +49,17 @@ class BaseLayout(object):
 
         """
         self.__unimplemented('tagpaths')
+
+    def get_path_tag(self, path, taglocations):
+        """Get the tag name for the given svn path, if it is a possible tag.
+
+        This function should return None if the path cannot be a tag.
+        Returning a non-empty sring does not imply that the path is a
+        tag, only that it is a candidate to be a tag.  Returning an
+        empty string is an error.
+
+        Path should be relative to the repo url.
+        taglocations should be as returned by self.taglocations()
+
+        """
+        self.__unimplemented('get_path_tag')
--- a/hgsubversion/layouts/single.py
+++ b/hgsubversion/layouts/single.py
@@ -16,3 +16,6 @@ class SingleLayout(base.BaseLayout):
 
     def taglocations(self, meta_data_dir):
         return []
+
+    def get_path_tag(self, path, taglocations):
+        return None
--- a/hgsubversion/layouts/standard.py
+++ b/hgsubversion/layouts/standard.py
@@ -56,3 +56,11 @@ class StandardLayout(base.BaseLayout):
             self._tag_locations.reverse()
 
         return self._tag_locations
+
+    def get_path_tag(self, path, taglocations):
+        for tagspath in taglocations:
+            if path.startswith(tagspath + '/'):
+                    tag = path[len(tagspath) + 1:]
+                    if tag:
+                        return tag
+        return None
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -251,14 +251,9 @@ class SVNMeta(object):
         Note that it's only a tag if it was copied from the path '' in a branch
         (or tag) we have, for our purposes.
         """
-        if self.layout != 'single':
-            path = self.normalize(path)
-            for tagspath in self.layoutobj.taglocations(self.meta_data_dir):
-                if path.startswith(tagspath + '/'):
-                    tag = path[len(tagspath) + 1:]
-                    if tag:
-                        return tag
-        return None
+        path = self.normalize(path)
+        taglocations = self.layoutobj.taglocations(self.meta_data_dir)
+        return self.layoutobj.get_path_tag(path, taglocations)
 
     def split_branch_path(self, path, existing=True):
         """Figure out which branch inside our repo this path represents, and