def validate_repo(self, ui, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup() cmd = '%s %s %s' % (sshcmd, args, util.shellquote("%s -R %s serve --stdio" % (_serverquote(remotecmd), _serverquote(self.path)))) ui.note(_('running %s\n') % cmd) cmd = util.quotecommand(cmd) self.pipeo, self.pipei, self.pipee = util.popen3(cmd) # skip any noise generated by remote shell self._callstream("hello") r = self._callstream("between", pairs=("%s-%s" % ("0" * 40, "0" * 40))) lines = ["", "dummy"] max_noise = 500 while lines[-1] and max_noise: l = r.readline() self.readerr() if lines[-1] == "1\n" and l == "\n": break if l: ui.debug("remote: ", l) lines.append(l) max_noise -= 1 else: self._abort( error.RepoError(_("no suitable response from remote hg"))) self.capabilities = set() for l in reversed(lines): if l.startswith("capabilities:"): self.capabilities.update(l[:-1].split(":")[1].split()) break
def validate_repo(self, ui, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup() cmd = '%s %s "%s -R %s serve --stdio"' cmd = cmd % (sshcmd, args, remotecmd, self.path) cmd = util.quotecommand(cmd) ui.note(_('running %s\n') % cmd) self.pipeo, self.pipei, self.pipee = util.popen3(cmd, 'b') # skip any noise generated by remote shell self.do_cmd("hello") r = self.do_cmd("between", pairs=("%s-%s" % ("0"*40, "0"*40))) lines = ["", "dummy"] max_noise = 500 while lines[-1] and max_noise: l = r.readline() self.readerr() if lines[-1] == "1\n" and l == "\n": break if l: ui.debug(_("remote: "), l) lines.append(l) max_noise -= 1 else: self.abort(error.RepoError(_("no suitable response from remote hg"))) self.capabilities = util.set() lines.reverse() for l in lines: if l.startswith("capabilities:"): self.capabilities.update(l[:-1].split(":")[1].split()) break
def _svncommand(self, commands): cmd = ['svn'] + commands + [self._path] cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) env = dict(os.environ) # Avoid localized output, preserve current locale for everything else. env['LC_MESSAGES'] = 'C' write, read, err = util.popen3(cmd, env=env, newlines=True) retdata = read.read() err = err.read().strip() if err: raise util.Abort(err) return retdata
def _svncommand(self, commands): path = os.path.join(self._ctx._repo.origroot, self._path) cmd = ['svn'] + commands + [path] cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) env = dict(os.environ) # Avoid localized output, preserve current locale for everything else. env['LC_MESSAGES'] = 'C' write, read, err = util.popen3(cmd, env=env, newlines=True) retdata = read.read() err = err.read().strip() if err: raise util.Abort(err) return retdata
def _validaterepo(self, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup() cmd = '%s %s %s' % (sshcmd, args, util.shellquote("%s -R %s serve --stdio" % (_serverquote(remotecmd), _serverquote(self.path)))) self.ui.debug('running %s\n' % cmd) cmd = util.quotecommand(cmd) # while self.subprocess isn't used, having it allows the subprocess to # to clean up correctly later # # no buffer allow the use of 'select' # feel free to remove buffering and select usage when we ultimately # move to threading. sub = util.popen4(cmd, bufsize=0) self.pipeo, self.pipei, self.pipee, self.subprocess = sub self.pipei = util.bufferedinputpipe(self.pipei) self.pipei = doublepipe(self.ui, self.pipei, self.pipee) self.pipeo = doublepipe(self.ui, self.pipeo, self.pipee) # skip any noise generated by remote shell self._callstream("hello") r = self._callstream("between", pairs=("%s-%s" % ("0" * 40, "0" * 40))) lines = ["", "dummy"] max_noise = 500 while lines[-1] and max_noise: l = r.readline() self.readerr() if lines[-1] == "1\n" and l == "\n": break if l: self.ui.debug("remote: ", l) lines.append(l) max_noise -= 1 else: self._abort( error.RepoError(_('no suitable response from ' 'remote hg'))) self._caps = set() for l in reversed(lines): if l.startswith("capabilities:"): self._caps.update(l[:-1].split(":")[1].split()) break
def _svncommand(self, commands, filename=''): path = os.path.join(self._ctx._repo.origroot, self._path, filename) cmd = ['svn'] + commands + [path] cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) env = dict(os.environ) # Avoid localized output, preserve current locale for everything else. env['LC_MESSAGES'] = 'C' p = subprocess.Popen(cmd, shell=True, bufsize=-1, close_fds=util.closefds, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, env=env) stdout, stderr = p.communicate() stderr = stderr.strip() if stderr: raise util.Abort(stderr) return stdout
def _validaterepo(self, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup() cmd = '%s %s %s' % (sshcmd, args, util.shellquote("%s -R %s serve --stdio" % (_serverquote(remotecmd), _serverquote(self.path)))) self.ui.debug('running %s\n' % cmd) cmd = util.quotecommand(cmd) # while self.subprocess isn't used, having it allows the subprocess to # to clean up correctly later # # no buffer allow the use of 'select' # feel free to remove buffering and select usage when we ultimately # move to threading. sub = util.popen4(cmd, bufsize=0) self.pipeo, self.pipei, self.pipee, self.subprocess = sub self.pipei = util.bufferedinputpipe(self.pipei) self.pipei = doublepipe(self.ui, self.pipei, self.pipee) self.pipeo = doublepipe(self.ui, self.pipeo, self.pipee) # skip any noise generated by remote shell self._callstream("hello") r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) lines = ["", "dummy"] max_noise = 500 while lines[-1] and max_noise: l = r.readline() self.readerr() if lines[-1] == "1\n" and l == "\n": break if l: self.ui.debug("remote: ", l) lines.append(l) max_noise -= 1 else: self._abort(error.RepoError(_('no suitable response from ' 'remote hg'))) self._caps = set() for l in reversed(lines): if l.startswith("capabilities:"): self._caps.update(l[:-1].split(":")[1].split()) break
def validate_repo(self, ui, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup() cmd = '%s %s %s' % (sshcmd, args, util.shellquote("%s -R %s serve --stdio" % (_serverquote(remotecmd), _serverquote(self.path)))) ui.note(_('running %s\n') % cmd) cmd = util.quotecommand(cmd) # while self.subprocess isn't used, having it allows the subprocess to # to clean up correctly later self.pipeo, self.pipei, self.pipee, self.subprocess = util.popen4(cmd) # skip any noise generated by remote shell self._callstream("hello") r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) lines = ["", "dummy"] max_noise = 500 while lines[-1] and max_noise: l = r.readline() self.readerr() if lines[-1] == "1\n" and l == "\n": break if l: ui.debug("remote: ", l) lines.append(l) max_noise -= 1 else: self._abort(error.RepoError(_('no suitable response from ' 'remote hg'))) self._caps = set() for l in reversed(lines): if l.startswith("capabilities:"): self._caps.update(l[:-1].split(":")[1].split()) break