gnu-arch-users
[Top][All Lists]
Advanced

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

[Gnu-arch-users] Patch : precomimt hook


From: Erik de Castro Lopo
Subject: [Gnu-arch-users] Patch : precomimt hook
Date: Wed, 1 Oct 2003 20:12:07 +1000

Hi all,

I spent about 10 mintues hacking around in the tla code (very clean and
well organised) and came up with the following patch. It adds another
hook called "precommit", which gets called at the start of the 
"tla commit" command. If the hook script returns a non-zero error
code the commit will be aborted so that errors can be corrected before
the commit is attempted again. 

One simple use for this feature is to do a make in the hook script. If
the code fails to build, the commit fails, hence no more broken code
in the archive.

I've been running the patched version for a day now (still learning,
making new test archives from scratch etc) and I don't think I have
broken anything, but obviously I can't have covered every possibility.

OK, patch (agains 1.1pre5) below my .sig. Whats the chance of this going 
in?

Cheers,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  address@hidden (Yes it's valid)
+-----------------------------------------------------------+
Traditional capital was stuck in a company's bank account or investments.
It could not walk away in disgust. Human capital has free will. It can
walk out the door; traditional capital cannot.


diff -r -c tla-1.1pre5/src/tla/libarch/commit.c 
tla-1.1pre5-precommit/src/tla/libarch/commit.c
*** tla-1.1pre5/src/tla/libarch/commit.c        Fri Aug  1 08:42:54 2003
--- tla-1.1pre5-precommit/src/tla/libarch/commit.c      Wed Oct  1 11:21:03 2003
***************
*** 72,77 ****
--- 72,78 ----
    t_uchar * cooked_log = 0;
    t_uchar * my_uid = 0;
    t_uchar * txn_id = 0;
+   int error ;
  
    invariant (!!raw_log);
  
***************
*** 80,85 ****
--- 81,94 ----
    prev_revision = arch_previous_revision (arch, revision);
    prev_level = arch_parse_package_name (arch_ret_patch_level, 0, 
prev_revision);
  
+   /* Check the error return code for the "precommit" hook and exit if 
non-zero. */
+   error = arch_run_hook ("precommit", "ARCH_ARCHIVE", arch->name, 
"ARCH_REVISION", revision, "ARCH_TREE_ROOT", tree_root, 0) ;
+   if (error)
+     {
+       safe_printfmt (2, "arch_commit: precommit hook function failed with 
error. commit cancelled.\n", error) ;
+       exit (2);
+       }
+ 
    changeset_path = arch_prepare_commit_changeset (&changelog_loc, chatter_fd, 
&cooked_log, tree_root, raw_log, arch, revision, prev_level, file_list);
  
    invariant (!!prev_level);
diff -r -c tla-1.1pre5/src/tla/libarch/hooks.c 
tla-1.1pre5-precommit/src/tla/libarch/hooks.c
*** tla-1.1pre5/src/tla/libarch/hooks.c Fri Aug  1 08:42:54 2003
--- tla-1.1pre5-precommit/src/tla/libarch/hooks.c       Wed Oct  1 10:49:55 2003
***************
*** 104,111 ****
              }
            else
              {
-               int exit_status;
- 
                exit_status = WEXITSTATUS (status);
              }
          }
--- 104,109 ----




reply via email to

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