예제 #1
0
class VCS(object):
    """Base object for VCS wrappers.

    .. warning::
        Instantiation will raise ``OSError`` if the necessary command line tool
        is not available on the system.

    .. attribute:: cmd_name

        If set this will override the guess-from-class-name method of defining
        the command name for the given VCS.
    """
    def __init__(self):
        cmd_name = getattr(self, 'cmd_name', self.__class__.__name__.lower())
        try:
            self.command = Command(cmd_name)
        except CommandNotFound:
            raise OSError(errno.ENOPROTOOPT, '%s not found' % cmd_name)

    def validate(self, allow_modified=False):
        """Ensure cwd is a VCS repository.

        :param bool allow_modified: Allow operation on dirty trees
        """
        raise NotImplementedError

    def add(self, files):
        """Add files to be committed.

        :param list files: Files to add
        """
        self.command.add(*files)

    def commit(self, files, message):
        """Commit files to repository.

        :param list files: Files to add
        """
        raise NotImplementedError

    def tag(self, name, message):
        """Create version tag

        :param str name: Tag to create
        :param str message: Message to associate with tag
        """
        raise NotImplementedError