parameters: (options)
return_statement: return (VCS_UNKNOWN, None)
docstring: Helper to guess the version control system.
  
    This examines the current directory, guesses which VersionControlSystem
    we're using, and returns an string indicating which VCS is detected.
  
    Returns:
      A pair (vcs, output).  vcs is a string indicating which VCS was detected
      and is one of VCS_GIT, VCS_MERCURIAL, VCS_SUBVERSION, VCS_PERFORCE,
      VCS_CVS, or VCS_UNKNOWN.
      Since local perforce repositories can't be easily detected, this method
      will only guess VCS_PERFORCE if any perforce options have been specified.
      output is a string containing any interesting output from the vcs
      detection routine, or None if there is nothing interesting.
docstring_summary: Helper to guess the version control system.
docstring_tokens: Helper to guess the version control system .
function: def GuessVCSName(options):
    """Helper to guess the version control system.
  
    This examines the current directory, guesses which VersionControlSystem
    we're using, and returns an string indicating which VCS is detected.
  
    Returns:
      A pair (vcs, output).  vcs is a string indicating which VCS was detected
      and is one of VCS_GIT, VCS_MERCURIAL, VCS_SUBVERSION, VCS_PERFORCE,
      VCS_CVS, or VCS_UNKNOWN.
      Since local perforce repositories can't be easily detected, this method
      will only guess VCS_PERFORCE if any perforce options have been specified.
      output is a string containing any interesting output from the vcs
      detection routine, or None if there is nothing interesting.
    """
    for attribute, value in options.__dict__.iteritems():
      if attribute.startswith("p4") and value != None:
        return (VCS_PERFORCE, None)
  
    def RunDetectCommand(vcs_type, command):
      """Helper to detect VCS by executing command.
  
      Returns:
         A pair (vcs, output) or None. Throws exception on error.
      """
      try:
        out, returncode = RunShellWithReturnCode(command)
        if returncode == 0:
          return (vcs_type, out.strip())
      except OSError, (errcode, message):
        if errcode != errno.ENOENT:  # command not found code
          raise
  
    # Mercurial has a command to get the base directory of a repository
    # Try running it, but don't die if we don't have hg installed.
    # NOTE: we try Mercurial first as it can sit on top of an SVN working copy.
    res = RunDetectCommand(VCS_MERCURIAL, ["hg", "root"])
    if res != None:
      return res
  
    # Subversion from 1.7 has a single centralized .svn folder
    # ( see http://subversion.apache.org/docs/release-notes/1.7.html#wc-ng )
    # That's why we use 'svn info' instead of checking for .svn dir
    res = RunDetectCommand(VCS_SUBVERSION, ["svn", "info"])
    if res != None:
      return res
  
    # Git has a command to test if you're in a git tree.
    # Try running it, but don't die if we don't have git installed.
    res = RunDetectCommand(VCS_GIT, ["git", "rev-parse",
                                     "--is-inside-work-tree"])
    if res != None:
      return res
  
    # detect CVS repos use `cvs status && $? == 0` rules
    res = RunDetectCommand(VCS_CVS, ["cvs", "status"])
    if res != None:
      return res
  
    return (VCS_UNKNOWN, None)
function_tokens: def GuessVCSName ( options ) : for attribute , value in options . __dict__ . iteritems ( ) : if attribute . startswith ( "p4" ) and value != None : return ( VCS_PERFORCE , None ) def RunDetectCommand ( vcs_type , command ) : """Helper to detect VCS by executing command.
  
      Returns:
         A pair (vcs, output) or None. Throws exception on error.
      """ try : out , returncode = RunShellWithReturnCode ( command ) if returncode == 0 : return ( vcs_type , out . strip ( ) ) except OSError , ( errcode , message ) : if errcode != errno . ENOENT : # command not found code raise # Mercurial has a command to get the base directory of a repository # Try running it, but don't die if we don't have hg installed. # NOTE: we try Mercurial first as it can sit on top of an SVN working copy. res = RunDetectCommand ( VCS_MERCURIAL , [ "hg" , "root" ] ) if res != None : return res # Subversion from 1.7 has a single centralized .svn folder # ( see http://subversion.apache.org/docs/release-notes/1.7.html#wc-ng ) # That's why we use 'svn info' instead of checking for .svn dir res = RunDetectCommand ( VCS_SUBVERSION , [ "svn" , "info" ] ) if res != None : return res # Git has a command to test if you're in a git tree. # Try running it, but don't die if we don't have git installed. res = RunDetectCommand ( VCS_GIT , [ "git" , "rev-parse" , "--is-inside-work-tree" ] ) if res != None : return res # detect CVS repos use `cvs status && $? == 0` rules res = RunDetectCommand ( VCS_CVS , [ "cvs" , "status" ] ) if res != None : return res return ( VCS_UNKNOWN , None )