[PATCH] Enable bisect --command to run shell scripts

Christian Ebert blacktrash at gmx.net
Sat Feb 14 01:39:36 CST 2009


* Jonathan Watt on Saturday, February 14, 2009 at 17:24:47 +1300
> # HG changeset patch
> # User Jonathan Watt <jwatt at jwatt.org>
> # Date 1234585428 -46800
> # Node ID b7c73fc4fdf8198c908594d9df570f192cba8e39
> # Parent  9f73bddb9d0bf1531523f4b328e8ae0de1247f09
> Enable bisect --command to run shell scripts. Issue1512.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -7,16 +7,20 @@
> 
> from node import hex, nullid, nullrev, short
> from i18n import _, gettext
> import os, re, sys
> import hg, util, revlog, bundlerepo, extensions, copies, context, error
> import difflib, patch, time, help, mdiff, tempfile, url
> import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
> import merge as merge_
> +try:
> +  import subprocess
> +except ImportError:
> +  pass
> 
> # Commands start here, listed alphabetically
> 
> def add(ui, repo, *pats, **opts):
>     """add the specified files on the next commit
> 
>     Schedule files to be version controlled and added to the repository.
> 
> @@ -326,17 +330,21 @@ def bisect(ui, repo, rev=None, extra=Non
>     state = hbisect.load_state(repo)
> 
>     if command:
>         commandpath = util.find_exe(command)
>         changesets = 1
>         try:
>             while changesets:
>                 # update state
> -                status = os.spawnl(os.P_WAIT, commandpath)
> +                if 'subprocess' in globals(): # false for python 2.3
> +                  status = subprocess.call(commandpath)
> +                else:
> +                  # this doesn't run shell scripts well
> +                  status = os.spawnl(os.P_WAIT, commandpath)

Perhaps:

try:
    status = subprocess.call(commandpath)
except NameError:
    status = os.spawnl(os.P_WAIT, commandpath)

>                 if status == 125:
>                     transition = "skip"
>                 elif status == 0:
>                     transition = "good"
>                 # status < 0 means process was killed
>                 elif status == 127:
>                     raise util.Abort(_("failed to execute %s") % command)
>                 elif status < 0:
> diff --git a/setup.py b/setup.py
> old mode 100644
> new mode 100755

Why did you make setup.py executable?

> diff --git a/tests/test-bisect3 b/tests/test-bisect3
> new file mode 100755
> --- /dev/null
> +++ b/tests/test-bisect3
> @@ -0,0 +1,41 @@
> +#!/bin/sh
> +
> +# This test tests the -c option of the bisect command

This test passes here on MacOS 10.5.6 _without_ your patch
applied. You had the problem on Mac, right?

$ python --version
Python 2.6
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.5.6
BuildVersion:	9G55

c
-- 
\black\trash movie    _C O W B O Y_  _C A N O E_  _C O M A_
Ein deutscher Western/A German Western
-->> http://www.blacktrash.org/underdogma/ccc.html
-->> http://www.blacktrash.org/underdogma/ccc-en.html


More information about the Mercurial-devel mailing list