Changeset - 291be8fa4d4f
[Not reviewed]
beta
0 2 0
Mads Kiilerich - 13 years ago 2012-12-12 18:12:18
madski@unity3d.com
Grafted from: 44b57042f4bd
rename search_recursively to search_up - that is what it is
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/backends/__init__.py
Show inline comments
 
@@ -27,13 +27,13 @@ def get_repo(path=None, alias=None, crea
 
        if not (path or alias):
 
            raise TypeError("If create is specified, we need path and scm type")
 
        return get_backend(alias)(path, create=True)
 
    if path is None:
 
        path = abspath(os.path.curdir)
 
    try:
 
        scm, path = get_scm(path, search_recursively=True)
 
        scm, path = get_scm(path, search_up=True)
 
        path = abspath(path)
 
        alias = scm
 
    except VCSError:
 
        raise VCSError("No scm found at %s" % path)
 
    if alias is None:
 
        alias = get_scm(path)[0]
rhodecode/lib/vcs/utils/helpers.py
Show inline comments
 
@@ -12,20 +12,20 @@ from rhodecode.lib.vcs.exceptions import
 
from rhodecode.lib.vcs.exceptions import RepositoryError
 
from rhodecode.lib.vcs.utils.paths import abspath
 

	
 
ALIASES = ['hg', 'git']
 

	
 

	
 
def get_scm(path, search_recursively=False, explicit_alias=None):
 
def get_scm(path, search_up=False, explicit_alias=None):
 
    """
 
    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_recursively: if set to ``True``, this function would try to
 
    :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
 
@@ -34,13 +34,13 @@ def get_scm(path, search_recursively=Fal
 
        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_recursively:
 
    while not found_scms and search_up:
 
        newpath = abspath(path, '..')
 
        if newpath == path:
 
            break
 
        path = newpath
 
        found_scms = get_scms(path)
 

	
0 comments (0 inline, 0 general)