##// END OF EJS Templates
ssh: use pre-compiled backends for faster matching of vcs detection.
super-admin -
r4702:c3d9862a stable
parent child Browse files
Show More
@@ -34,6 +34,9 b' log = logging.getLogger(__name__)'
34
34
35
35
36 class SshWrapper(object):
36 class SshWrapper(object):
37 hg_cmd_pat = re.compile(r'^hg\s+\-R\s+(\S+)\s+serve\s+\-\-stdio$')
38 git_cmd_pat = re.compile(r'^git-(receive-pack|upload-pack)\s\'[/]?(\S+?)(|\.git)\'$')
39 svn_cmd_pat = re.compile(r'^svnserve -t')
37
40
38 def __init__(self, command, connection_info, mode,
41 def __init__(self, command, connection_info, mode,
39 user, user_id, key_id, shell, ini_path, env):
42 user, user_id, key_id, shell, ini_path, env):
@@ -101,24 +104,20 b' class SshWrapper(object):'
101 vcs_type = mode if mode in ['svn', 'hg', 'git'] else None
104 vcs_type = mode if mode in ['svn', 'hg', 'git'] else None
102 repo_name = None
105 repo_name = None
103
106
104 hg_pattern = r'^hg\s+\-R\s+(\S+)\s+serve\s+\-\-stdio$'
107 hg_match = self.hg_cmd_pat.match(self.command)
105 hg_match = re.match(hg_pattern, self.command)
106 if hg_match is not None:
108 if hg_match is not None:
107 vcs_type = 'hg'
109 vcs_type = 'hg'
108 repo_name = self.maybe_translate_repo_uid(hg_match.group(1).strip('/'))
110 repo_name = self.maybe_translate_repo_uid(hg_match.group(1).strip('/'))
109 return vcs_type, repo_name, mode
111 return vcs_type, repo_name, mode
110
112
111 git_pattern = r'^git-(receive-pack|upload-pack)\s\'[/]?(\S+?)(|\.git)\'$'
113 git_match = self.git_cmd_pat.match(self.command)
112 git_match = re.match(git_pattern, self.command)
113 if git_match is not None:
114 if git_match is not None:
114 vcs_type = 'git'
115 vcs_type = 'git'
115 repo_name = self.maybe_translate_repo_uid(git_match.group(2).strip('/'))
116 repo_name = self.maybe_translate_repo_uid(git_match.group(2).strip('/'))
116 mode = git_match.group(1)
117 mode = git_match.group(1)
117 return vcs_type, repo_name, mode
118 return vcs_type, repo_name, mode
118
119
119 svn_pattern = r'^svnserve -t'
120 svn_match = self.svn_cmd_pat.match(self.command)
120 svn_match = re.match(svn_pattern, self.command)
121
122 if svn_match is not None:
121 if svn_match is not None:
123 vcs_type = 'svn'
122 vcs_type = 'svn'
124 # Repo name should be extracted from the input stream, we're unable to
123 # Repo name should be extracted from the input stream, we're unable to
General Comments 0
You need to be logged in to leave comments. Login now