# -*- coding: utf-8 -*-

# Copyright (c) 2002 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the general part of the interface to version control systems.

The general part of the VCS interface defines classes to implement common
dialogs. These are a dialog to enter command options, a dialog to display
some repository information and an abstract base class. The individual 
interfaces (i.e. CVS) have to be subclasses of this base class.
"""

import Preferences

######################################################################
## Below is the factory function to instantiate the appropriate
## vcs object depending on the project settings.
######################################################################

def factory(vcs):
    """
    Modul factory function to generate the right vcs object.
    
    @param vcs name of the VCS system to be used (string)
    @return the instantiated VCS object
    """
    v = vcs.lower()
    try:
        if v == "cvs":
            from vcsCVS.cvs import Cvs
            vc = Cvs()
        elif v in ["subversion", "pysvn"]:
            if v == "pysvn":
                try:
                    from vcsPySvn.subversion import Subversion
                except ImportError:
                    from vcsSubversion.subversion import Subversion
            else:
                from vcsSubversion.subversion import Subversion
            vc = Subversion()
        else:
            vc = None       # should not happen
    except ImportError:
        vc = None           # should not happen
    return vc
