monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] [PATCH] New lua command execute_redirout which exec


From: Timothy Brownawell
Subject: Re: [Monotone-devel] [PATCH] New lua command execute_redirout which executes an os command and captures standard output
Date: Mon, 14 Aug 2006 01:09:18 -0500

On Mon, 2006-08-14 at 01:00 -0400, Daniel Dickinson wrote:
> The following diff adds a new command for use in lua hooks. The command
> is called execute_redirout.  I chose the name based on spawn_redir and
> execute.

Ok...

>  Also, I couldn't figure out how
> to get mtn diff to not include the .po files, which aren't really
> relevant and the only changes are the line numbers of the strings,
> which should be automagically updated anyway.

"mtn revert po". I hear the translators don't like people committing
changes to these files anyway, so you will want to do that eventually.
po/ seems to only get modified on a fresh build, so you shouldn't have
to keep doing this every time.

Or do "mtn diff --exclude po".

> Comments on the code are welcome, and I'll make any changes, hopefully
> quickly enough to get into 0.29.

It's horribly large, which is completely not needed.

I'd suggest just making process_spawn_redirected take an empty filename
as meaning to not redirect that stream, so your execute_redirout does
   local outfile = mkstemp()
   spawn_redirected("", outfile, "", <program and args>)
   output = readfile(outfile)
and it does what you want. The non-lua part would look something like:

# 
# old_revision [1ca66cde65e09bfe8286388a1eedd3a8587b2b65]
# 
# patch "unix/process.cc"
#  from [04e4acb200ae781f7b94bef190f2972179504424]
#    to [ab25d795e3ac9fdeea61a2bb1ca3e35af54a402e]
# 
# patch "win32/process.cc"
#  from [993e5bdc06b7b7aa5fa5236e635bc97f37020968]
#    to [e705e1f021d215049cd51d5e0d1f5cd5ed641dba]
# 
============================================================
--- unix/process.cc     04e4acb200ae781f7b94bef190f2972179504424
+++ unix/process.cc     ab25d795e3ac9fdeea61a2bb1ca3e35af54a402e
@@ -116,6 +116,8 @@ redir::redir(int which, char const * fil
 redir::redir(int which, char const * file)
  : savedfd(-1), fd(which)
 {
+  if (file == 0 || file[0] == '\0')
+    return;
   int tempfd = open(file, (which==0?O_RDONLY:O_WRONLY|O_CREAT|O_TRUNC),
0664);
   if (tempfd == -1)
     {
============================================================
--- win32/process.cc    993e5bdc06b7b7aa5fa5236e635bc97f37020968
+++ win32/process.cc    e705e1f021d215049cd51d5e0d1f5cd5ed641dba
@@ -156,8 +156,12 @@ redir::redir(int which, char const * fil
   ~redir();
 };
 redir::redir(int which, char const * filename)
- : what(which)
+ : what(-1)
 {
+  if (file == 0 || file[0] == '\0')
+    return;
+  what = which;
+
   HANDLE file;
   SECURITY_ATTRIBUTES sa;
   sa.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -203,6 +207,7 @@ redir::~redir()
     CloseHandle(GetStdHandle(STD_ERROR_HANDLE));
     SetStdHandle(STD_ERROR_HANDLE, saved);
     break;
+  default:
   }
 }
 pid_t process_spawn_redirected(char const * in,






reply via email to

[Prev in Thread] Current Thread [Next in Thread]