view hgsubversion/layouts/base.py @ 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 513f2b607b06
line wrap: on
line source

"""Module to hold the base API for layout classes.

This module should not contain any implementation, just a definition
of the API concrete layouts are expected to implement.

"""

from mercurial import util as hgutil

class BaseLayout(object):

    def __init__(self, ui):
        self.ui = ui

    def __unimplemented(self, method_name):
        raise NotImplementedError(
            "Incomplete layout implementation: %s.%s doesn't implement %s" %
            (self.__module__, self.__name__, method_name))

    def localname(self, path):
        """Compute the local name for a branch located at path.

        path should be relative to the repo url.

        """
        self.__unimplemented('localname')

    def remotename(self, branch):
        """Compute a subversion path for a mercurial branch name

        This should return a path relative to the repo url

        """
        self.__unimplemented('remotename')

    def remotepath(self, branch, subdir='/'):
        """Compute a  subversion path for a mercurial branch name.

        This should return an absolute path, assuming our repo root is at subdir
        A false subdir shall be taken to mean /.

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

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