def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): # fallback to the original system method if the output needs to be # captured (to self._buffers), or the output stream is not stdout # (e.g. stderr, cStringIO), because the chg client is not aware of # these situations and will behave differently (write to stdout). if (any(s[1] for s in self._bufferstates) or not util.safehasattr(self.fout, 'fileno') or self.fout.fileno() != sys.stdout.fileno()): return super(chgui, self).system(cmd, environ, cwd, onerr, errprefix) # copied from mercurial/util.py:system() self.flush() def py2shell(val): if val is None or val is False: return '0' if val is True: return '1' return str(val) env = os.environ.copy() if environ: env.update((k, py2shell(v)) for k, v in environ.iteritems()) env['HG'] = util.hgexecutable() rc = self._csystem(cmd, env, cwd) if rc and onerr: errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), util.explainexit(rc)[0]) if errprefix: errmsg = '%s: %s' % (errprefix, errmsg) raise onerr(errmsg) return rc
def _asyncsavemetadata(root, nodes): '''starts a separate process that fills metadata for the nodes This function creates a separate process and doesn't wait for it's completion. This was done to avoid slowing down pushes ''' maxnodes = 50 if len(nodes) > maxnodes: return nodesargs = [] for node in nodes: nodesargs.append('--node') nodesargs.append(node) with open(os.devnull, 'w+b') as devnull: cmdline = [ util.hgexecutable(), 'debugfillinfinitepushmetadata', '-R', root ] + nodesargs # Process will run in background. We don't care about the return code subprocess.Popen(cmdline, close_fds=True, shell=False, stdin=devnull, stdout=devnull, stderr=devnull)
def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True, strict_node_history=False): # Normalize path names, svn >= 1.5 only wants paths relative to # supplied URL relpaths = [] for p in paths: if not p.startswith('/'): p = self.module + '/' + p relpaths.append(p.strip('/')) args = [ self.baseurl, relpaths, start, end, limit, discover_changed_paths, strict_node_history ] arg = encodeargs(args) hgexe = util.hgexecutable() cmd = '%s debugsvnlog' % util.shellquote(hgexe) stdin, stdout = util.popen2(cmd) stdin.write(arg) stdin.close() return logstream(stdout)
def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True, strict_node_history=False): # Normalize path names, svn >= 1.5 only wants paths relative to # supplied URL relpaths = [] for p in paths: if not p.startswith('/'): p = self.module + '/' + p relpaths.append(p.strip('/')) args = [ self.baseurl, relpaths, start, end, limit, discover_changed_paths, strict_node_history ] arg = encodeargs(args) hgexe = util.hgexecutable() cmd = '%s debugsvnlog' % util.shellquote(hgexe) stdin, stdout = util.popen2(util.quotecommand(cmd)) stdin.write(arg) try: stdin.close() except IOError: raise util.Abort( _('Mercurial failed to run itself, check' ' hg executable is in PATH')) return logstream(stdout)
def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): # copied from mercurial/util.py:system() self.flush() def py2shell(val): if val is None or val is False: return '0' if val is True: return '1' return str(val) env = os.environ.copy() if environ: env.update((k, py2shell(v)) for k, v in environ.iteritems()) env['HG'] = util.hgexecutable() rc = self._csystem(cmd, env, cwd) if rc and onerr: errmsg = '%s %s' % (os.path.basename(cmd.split( None, 1)[0]), util.explainexit(rc)[0]) if errprefix: errmsg = '%s: %s' % (errprefix, errmsg) raise onerr(errmsg) return rc
def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True, strict_node_history=False): # Normalize path names, svn >= 1.5 only wants paths relative to # supplied URL relpaths = [] for p in paths: if not p.startswith('/'): p = self.module + '/' + p relpaths.append(p.strip('/')) args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths, strict_node_history] arg = encodeargs(args) hgexe = util.hgexecutable() cmd = '%s debugsvnlog' % util.shellquote(hgexe) stdin, stdout = util.popen2(cmd) stdin.write(arg) stdin.close() return logstream(stdout)
def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True, strict_node_history=False): # Normalize path names, svn >= 1.5 only wants paths relative to # supplied URL relpaths = [] for p in paths: if not p.startswith('/'): p = self.module + '/' + p relpaths.append(p.strip('/')) args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths, strict_node_history] arg = encodeargs(args) hgexe = util.hgexecutable() cmd = '%s debugsvnlog' % util.shellquote(hgexe) stdin, stdout = util.popen2(util.quotecommand(cmd)) stdin.write(arg) try: stdin.close() except IOError: raise util.Abort(_('Mercurial failed to run itself, check' ' hg executable is in PATH')) return logstream(stdout)