code: def get_scm(path, search_up=False, explicit_alias=None):
      
      if not os.path.isdir(path):
          raise VCSError("Given path %s is not a directory" % path)
  
      def get_scms(path):
          return [(scm, path) for scm in get_scms_for_path(path)]
  
      found_scms = get_scms(path)
      while not found_scms and search_up:
          newpath = abspath(path, '..')
          if newpath == path:
              break
          path = newpath
          found_scms = get_scms(path)
  
      if len(found_scms) > 1:
          for scm in found_scms:
              if scm[0] == explicit_alias:
                  return scm
          raise VCSError('More than one [%s] scm found at given path %s'
                         % (','.join((x[0] for x in found_scms)), path))
  
      if len(found_scms) is 0:
          raise VCSError('No scm found at given path %s' % path)
  
      return found_scms[0]
docs: Returns one of alias from ``ALIASES`` (in order of precedence same as
      shortcuts given in ``ALIASES``) and top working dir path for the given
      argument. If no scm-specific directory is found or more than one scm is
      found at that directory, ``VCSError`` is raised.
  
      :param search_up: if set to ``True``, this function would try to
        move up to parent directory every time no scm is recognized for the
        currently checked path. Default: ``False``.
      :param explicit_alias: can be one of available backend aliases, when given
        it will return given explicit alias in repositories under more than one
        version control, if explicit_alias is different than found it will raise
        VCSError