##// END OF EJS Templates
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara -
r14864:1b872599 stable
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7
7
8 from i18n import _
8 from i18n import _
9 import struct
9 import struct
10 import sys
10 import sys, os
11 import dispatch, encoding, util
11 import dispatch, encoding, util
12
12
13 logfile = None
13 logfile = None
@@ -131,6 +131,7 b' class server(object):'
131 based stream to stdout.
131 based stream to stdout.
132 """
132 """
133 def __init__(self, ui, repo, mode):
133 def __init__(self, ui, repo, mode):
134 self.cwd = os.getcwd()
134 self.ui = ui
135 self.ui = ui
135
136
136 logpath = ui.config("cmdserver", "log", None)
137 logpath = ui.config("cmdserver", "log", None)
@@ -183,11 +184,15 b' class server(object):'
183 self.repo.baseui = copiedui
184 self.repo.baseui = copiedui
184 self.repo.ui = self.repo.dirstate._ui = self.repoui.copy()
185 self.repo.ui = self.repo.dirstate._ui = self.repoui.copy()
185
186
186 req = dispatch.request(args, copiedui, self.repo, self.cin,
187 req = dispatch.request(args[:], copiedui, self.repo, self.cin,
187 self.cout, self.cerr)
188 self.cout, self.cerr)
188
189
189 ret = dispatch.dispatch(req) or 0 # might return None
190 ret = dispatch.dispatch(req) or 0 # might return None
190
191
192 # restore old cwd
193 if '--cwd' in args:
194 os.chdir(self.cwd)
195
191 self.cresult.write(struct.pack('>i', int(ret)))
196 self.cresult.write(struct.pack('>i', int(ret)))
192
197
193 def getencoding(self):
198 def getencoding(self):
@@ -120,6 +120,15 b' diff -r 000000000000 -r c103a3dec114 a'
120 runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch))
120 runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch))
121 runcommand(server, ['log'])
121 runcommand(server, ['log'])
122
122
123 def cwd(server):
124 """ check that --cwd doesn't persist between requests """
125 readchannel(server)
126 os.mkdir('foo')
127 open('foo/bar', 'w').write('a')
128 runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
129 runcommand(server, ['st', 'foo/bar'])
130 os.remove('foo/bar')
131
123 if __name__ == '__main__':
132 if __name__ == '__main__':
124 os.system('hg init')
133 os.system('hg init')
125
134
@@ -128,3 +137,4 b" if __name__ == '__main__':"
128 check(checkruncommand)
137 check(checkruncommand)
129 check(inputeof)
138 check(inputeof)
130 check(serverinput)
139 check(serverinput)
140 check(cwd)
@@ -36,3 +36,5 b' user: test'
36 date: Thu Jan 01 00:00:00 1970 +0000
36 date: Thu Jan 01 00:00:00 1970 +0000
37 summary: 1
37 summary: 1
38
38
39 ? bar
40 ? foo/bar
General Comments 0
You need to be logged in to leave comments. Login now