# HG changeset patch # User Mads Kiilerich # Date 2019-12-19 23:24:29 # Node ID 5b6174420e30904be6fed42ed2cc2ef65bd81879 # Parent 082780404e6c49ed9b39366abca02099120ed3e6 vcs: simplify get_scm diff --git a/kallithea/lib/vcs/utils/helpers.py b/kallithea/lib/vcs/utils/helpers.py --- a/kallithea/lib/vcs/utils/helpers.py +++ b/kallithea/lib/vcs/utils/helpers.py @@ -33,16 +33,14 @@ def get_scm(path, search_up=False, expli 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: + while True: + found_scms = [(scm, path) for scm in get_scms_for_path(path)] + if found_scms or not search_up: + break newpath = abspath(path, '..') if newpath == path: break path = newpath - found_scms = get_scms(path) if len(found_scms) > 1: for scm in found_scms: