Show More
@@ -30,7 +30,7 def get_repo(path=None, alias=None, crea | |||||
30 | if path is None: |
|
30 | if path is None: | |
31 | path = abspath(os.path.curdir) |
|
31 | path = abspath(os.path.curdir) | |
32 | try: |
|
32 | try: | |
33 |
scm, path = get_scm(path, search_ |
|
33 | scm, path = get_scm(path, search_up=True) | |
34 | path = abspath(path) |
|
34 | path = abspath(path) | |
35 | alias = scm |
|
35 | alias = scm | |
36 | except VCSError: |
|
36 | except VCSError: |
@@ -15,14 +15,14 from rhodecode.lib.vcs.utils.paths impor | |||||
15 | ALIASES = ['hg', 'git'] |
|
15 | ALIASES = ['hg', 'git'] | |
16 |
|
16 | |||
17 |
|
17 | |||
18 |
def get_scm(path, search_ |
|
18 | def get_scm(path, search_up=False, explicit_alias=None): | |
19 | """ |
|
19 | """ | |
20 | Returns one of alias from ``ALIASES`` (in order of precedence same as |
|
20 | Returns one of alias from ``ALIASES`` (in order of precedence same as | |
21 | shortcuts given in ``ALIASES``) and top working dir path for the given |
|
21 | shortcuts given in ``ALIASES``) and top working dir path for the given | |
22 | argument. If no scm-specific directory is found or more than one scm is |
|
22 | argument. If no scm-specific directory is found or more than one scm is | |
23 | found at that directory, ``VCSError`` is raised. |
|
23 | found at that directory, ``VCSError`` is raised. | |
24 |
|
24 | |||
25 |
:param search_ |
|
25 | :param search_up: if set to ``True``, this function would try to | |
26 | move up to parent directory every time no scm is recognized for the |
|
26 | move up to parent directory every time no scm is recognized for the | |
27 | currently checked path. Default: ``False``. |
|
27 | currently checked path. Default: ``False``. | |
28 | :param explicit_alias: can be one of available backend aliases, when given |
|
28 | :param explicit_alias: can be one of available backend aliases, when given | |
@@ -37,7 +37,7 def get_scm(path, search_recursively=Fal | |||||
37 | return [(scm, path) for scm in get_scms_for_path(path)] |
|
37 | return [(scm, path) for scm in get_scms_for_path(path)] | |
38 |
|
38 | |||
39 | found_scms = get_scms(path) |
|
39 | found_scms = get_scms(path) | |
40 |
while |
|
40 | while not found_scms and search_up: | |
41 | newpath = abspath(path, '..') |
|
41 | newpath = abspath(path, '..') | |
42 | if newpath == path: |
|
42 | if newpath == path: | |
43 | break |
|
43 | break |
General Comments 0
You need to be logged in to leave comments.
Login now