[RFC] fake editor for testing edit_commit_message

Martin Pool mbp at sourcefrog.net
Thu Jan 5 08:53:28 GMT 2006


On Thu, 2006-01-05 at 01:55 +0200, Alexander Belchenko wrote:
> John Arbash Meinel пишет:
> > Alexander Belchenko wrote:
> >>I've got WindowsError in subprocess.py when I'm trying to do commit. I
> >>don't understand why. Fully qualfied path to script also does not help. :-(
> > 
> > I think the problem is that it is trying to spawn a program named
> > "python fed.py" not a program "python" feeding it the argument "fed.py".
> > This is definitely a tricky thing to do on windows, since windows
> > doesn't support having executable scripts (other than .bat files).
> > I suppose you could do:
> > 
> > echo '@echo off' > test.bat
> > echo 'python fed.py' >> test.bat
> > And then use
> > set BZR_EDITOR='test.bat'
> 
> Hmm. It seems working solution. I'm trying to use batch wrapper but 
> without visible success. But this one is working:
> 
> echo @echo off > fed.bat
> echo python fed.py %1 >> fed.bat

But wouldn't it be enough to just make fed.bat containing something like
this?

  @echo off
  echo new commit message > %1

I had also been wishing for some kind of test for the external editor
function.  If a batch file will work on Windows then a shell script
should work nicely on Linux.

> But what about Linux systems? For Linux it should be fed.sh script, 
> isn't? If I simply create in test directory fed.bat or fed.sh depending 
> on what current OS is it will enough? Probably for Linux it should be 
> setting executable permission bit. I'm no Linux expert so someone help 
> is needed.
> 
> > We also can't just split based on whitespace, especially on windows,
> > where you have "C:\Program Files\..."
> 
> Hmm... Looks on this code (msgeditor.py:: _run_editor() function):
> 
> def _run_editor(filename):
>      """Try to execute an editor to edit the commit message."""
>      for e in _get_editor():
>          edargs = e.split(' ')          # <<<<<<< HERE SPLIT ON SPACE
>          x = call(edargs + [filename])
>          if x == 0:
>              return True
>          elif x == 127:
>              continue
>          else:
>              break
>      raise BzrError("Could not start any editor. "
>                     "Please specify $EDITOR or use ~/.bzr.conf/editor")

> Probably this split is incorrect?

Yes, I think so.  Rather than splitting ourselves, we should probably
just append (" " + filename) and then pass shell=True to subprocess, so
the shell will split the string in a system-appropriate manner.  (This
might still cause trouble with quoting on Windows but at least it's not
our fault. :-)

> >>1) Is this `fed` is appropriate for using as part of selftest for
> >>testing bzrlib/msgeditor.py::edit_commit_message() function?
> 
> > The problem is now bzr selftest requires that you have a working
> > compiler, and that we know what it is. (cl, icc, gcc, mingw, etc)
> 
> That's why I want to use SCons.

I love scons too, but distutils can probably at least build a little
static binary for us, if we need it.  But as John says I'd rather not.

I'd certainly be very happy to get a test added.

-- 
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/a9ce9bed/attachment.pgp 


More information about the bazaar mailing list