def testspawndetachedfailure1(self): """spawndetached() should throw if executing the process fails.""" try: util.spawndetached(["no_such_program", "arg1", "arg2"]) self.fail("expected spawndetached to fail with ENOENT") except (OSError, IOError) as ex: self.assertEqual(ex.errno, errno.ENOENT)
def testspawndetachedfailure2(self): """spawndetached() should throw if executing the process fails.""" try: util.spawndetached([os.devnull, "arg1", "arg2"]) self.fail("expected spawndetached to fail with EACCES") except (OSError, IOError) as ex: self.assertEqual(ex.errno, errno.EPERM)
def testspawndetachednoblock(self): """spawndetached() should return without waiting for the process to finish.""" start = time.time() util.spawndetached(["sleep", "5"]) end = time.time() if end - start >= 1.0: self.fail("spawndetached() took took %s seconds, should have " "returned immediately" % (end - start))
def backgroundrepack(repo, incremental=True): cmd = [util.hgexecutable(), "-R", repo.origroot, "repack"] msg = _("(running background repack)\n") if incremental: cmd.append("--incremental") msg = _("(running background incremental repack)\n") if not repo.ui.quiet: repo.ui.write_err(msg) util.spawndetached(cmd)
def backgroundprefetch( self, revs, base=None, repack=False, pats=None, opts=None ): """Runs prefetch in background with optional repack""" cmd = [util.hgexecutable(), "-R", self.origroot, "prefetch"] if repack: cmd.append("--repack") if revs: cmd += ["-r", revs] if base: cmd += ["-b", base] util.spawndetached(cmd)