summaryrefslogtreecommitdiffstats
path: root/git_command.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-10 18:53:46 -0700
committerShawn O. Pearce <sop@google.com>2009-04-18 16:50:47 -0700
commitfb2316146f6e3036e0cc3e08653920964a428a15 (patch)
treef19c5c65a035f547ada03496f1576524e4602665 /git_command.py
parent8bd5e60b16080008771afcaa7de7084487b84780 (diff)
downloadgit-repo-fb2316146f6e3036e0cc3e08653920964a428a15.tar.gz
Automatically use SSH control master support during sync
By creating a background ssh "control master" process which lives for the duration of our sync cycle we can easily cut the time for a no-op sync of 132 projects from 60s to 18s. Bug: REPO-11 Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_command.py')
-rw-r--r--git_command.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/git_command.py b/git_command.py
index b6a4a343..954bebad 100644
--- a/git_command.py
+++ b/git_command.py
@@ -16,6 +16,7 @@
16import os 16import os
17import sys 17import sys
18import subprocess 18import subprocess
19import tempfile
19from error import GitError 20from error import GitError
20from trace import REPO_TRACE, IsTrace, Trace 21from trace import REPO_TRACE, IsTrace, Trace
21 22
@@ -26,6 +27,27 @@ GIT_DIR = 'GIT_DIR'
26LAST_GITDIR = None 27LAST_GITDIR = None
27LAST_CWD = None 28LAST_CWD = None
28 29
30_ssh_proxy_path = None
31_ssh_sock_path = None
32
33def _ssh_sock(create=True):
34 global _ssh_sock_path
35 if _ssh_sock_path is None:
36 if not create:
37 return None
38 _ssh_sock_path = os.path.join(
39 tempfile.mkdtemp('', 'ssh-'),
40 'master-%r@%h:%p')
41 return _ssh_sock_path
42
43def _ssh_proxy():
44 global _ssh_proxy_path
45 if _ssh_proxy_path is None:
46 _ssh_proxy_path = os.path.join(
47 os.path.dirname(__file__),
48 'git_ssh')
49 return _ssh_proxy_path
50
29 51
30class _GitCall(object): 52class _GitCall(object):
31 def version(self): 53 def version(self):
@@ -52,6 +74,7 @@ class GitCommand(object):
52 capture_stdout = False, 74 capture_stdout = False,
53 capture_stderr = False, 75 capture_stderr = False,
54 disable_editor = False, 76 disable_editor = False,
77 ssh_proxy = False,
55 cwd = None, 78 cwd = None,
56 gitdir = None): 79 gitdir = None):
57 env = dict(os.environ) 80 env = dict(os.environ)
@@ -68,6 +91,9 @@ class GitCommand(object):
68 91
69 if disable_editor: 92 if disable_editor:
70 env['GIT_EDITOR'] = ':' 93 env['GIT_EDITOR'] = ':'
94 if ssh_proxy:
95 env['REPO_SSH_SOCK'] = _ssh_sock()
96 env['GIT_SSH'] = _ssh_proxy()
71 97
72 if project: 98 if project:
73 if not cwd: 99 if not cwd: