Commits

David Schleimer committed 16045f6

layouts: pull svn path -> potential tag name mapping into layouts

Comments (0)

Files changed (4)

hgsubversion/layouts/base.py

 
         """
         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')

hgsubversion/layouts/single.py

 
     def taglocations(self, meta_data_dir):
         return []
+
+    def get_path_tag(self, path, taglocations):
+        return None

hgsubversion/layouts/standard.py

             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

hgsubversion/svnmeta.py

         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