Mercurial > public > mercurial-scm > hg
comparison mercurial/commandserver.py @ 14707:964a72038bb0 stable
cmdserver, runcommand: properly handle the client sending no arguments
No real reason for a client to do this, but still possible.
Previously if the client sent no arguments, a list with an empty string ['']
would be used as the arguments to dispatch, which would cause hg to complain
about an ambiguous command.
Instead, we simply check for no arguments and use an empty list instead (which
is equivalent to invoking hg with no args on the command line).
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Tue, 21 Jun 2011 15:38:10 +0300 |
parents | 5fd5dd9a610a |
children | c19de7f32961 |
comparison
equal
deleted
inserted
replaced
14706:5fd5dd9a610a | 14707:964a72038bb0 |
---|---|
169 def runcommand(self): | 169 def runcommand(self): |
170 """ reads a list of \0 terminated arguments, executes | 170 """ reads a list of \0 terminated arguments, executes |
171 and writes the return code to the result channel """ | 171 and writes the return code to the result channel """ |
172 | 172 |
173 length = struct.unpack('>I', self._read(4))[0] | 173 length = struct.unpack('>I', self._read(4))[0] |
174 args = self._read(length).split('\0') | 174 if not length: |
175 args = [] | |
176 else: | |
177 args = self._read(length).split('\0') | |
175 | 178 |
176 # copy the ui so changes to it don't persist between requests | 179 # copy the ui so changes to it don't persist between requests |
177 req = dispatch.request(args, self.ui.copy(), self.repo, self.cin, | 180 req = dispatch.request(args, self.ui.copy(), self.repo, self.cin, |
178 self.cout, self.cerr) | 181 self.cout, self.cerr) |
179 | 182 |