@ -156,7 +156,7 @@ class FakeReposBase(object):
# It is 1-based too.
# It is 1-based too.
self . git_hashes = { }
self . git_hashes = { }
self . gitdaemon = None
self . gitdaemon = None
self . git_pid_file = None
self . git_pid_file _name = None
self . git_root = None
self . git_root = None
self . git_dirty = False
self . git_dirty = False
self . git_port = None
self . git_port = None
@ -196,16 +196,16 @@ class FakeReposBase(object):
logging . debug ( ' Killing git-daemon pid %s ' % self . gitdaemon . pid )
logging . debug ( ' Killing git-daemon pid %s ' % self . gitdaemon . pid )
self . gitdaemon . kill ( )
self . gitdaemon . kill ( )
self . gitdaemon = None
self . gitdaemon = None
if self . git_pid_file :
if self . git_pid_file_name :
pid = int ( self . git_pid_file . read ( ) )
pid = int ( open ( self . git_pid_file_name ) . read ( ) )
self . git_pid_file . close ( )
logging . debug ( ' Killing git daemon pid %s ' % pid )
logging . debug ( ' Killing git daemon pid %s ' % pid )
try :
try :
subprocess2 . kill_pid ( pid )
subprocess2 . kill_pid ( pid )
except OSError as e :
except OSError as e :
if e . errno != errno . ESRCH : # no such process
if e . errno != errno . ESRCH : # no such process
raise
raise
self . git_pid_file = None
os . remove ( self . git_pid_file_name )
self . git_pid_file_name = None
wait_for_port_to_free ( self . host , self . git_port )
wait_for_port_to_free ( self . host , self . git_port )
self . git_port = None
self . git_port = None
self . git_base = None
self . git_base = None
@ -238,7 +238,7 @@ class FakeReposBase(object):
self . set_up ( )
self . set_up ( )
if self . gitdaemon :
if self . gitdaemon :
return True
return True
assert self . git_pid_file == None
assert self . git_pid_file _name == None
try :
try :
subprocess2 . check_output ( [ ' git ' , ' --version ' ] )
subprocess2 . check_output ( [ ' git ' , ' --version ' ] )
except ( OSError , subprocess2 . CalledProcessError ) :
except ( OSError , subprocess2 . CalledProcessError ) :
@ -249,12 +249,14 @@ class FakeReposBase(object):
self . git_port = find_free_port ( self . host , 20000 )
self . git_port = find_free_port ( self . host , 20000 )
self . git_base = ' git:// %s : %d /git/ ' % ( self . host , self . git_port )
self . git_base = ' git:// %s : %d /git/ ' % ( self . host , self . git_port )
# Start the daemon.
# Start the daemon.
self . git_pid_file = tempfile . NamedTemporaryFile ( )
git_pid_file = tempfile . NamedTemporaryFile ( delete = False )
self . git_pid_file_name = git_pid_file . name
git_pid_file . close ( )
cmd = [ ' git ' , ' daemon ' ,
cmd = [ ' git ' , ' daemon ' ,
' --export-all ' ,
' --export-all ' ,
' --reuseaddr ' ,
' --reuseaddr ' ,
' --base-path= ' + self . root_dir ,
' --base-path= ' + self . root_dir ,
' --pid-file= ' + self . git_pid_file . name,
' --pid-file= ' + self . git_pid_file _ name,
' --port= %d ' % self . git_port ]
' --port= %d ' % self . git_port ]
if self . host == ' 127.0.0.1 ' :
if self . host == ' 127.0.0.1 ' :
cmd . append ( ' --listen= ' + self . host )
cmd . append ( ' --listen= ' + self . host )