On 3 October 2014 14:04, Andy Bradford
<amb-sendok-1414951486.goflecofghbmjnaaa...@bradfords.org> wrote:
> Are you simply looking for a way to be notified via email when there are
> changes that  have been  updated into  your working  checkout?

Yes.  I want an email when a change happens, but not an empty email
every 5 minutes (from each of the half dozen fossils I want up-to-date
on the server).

> If  so, I think the above script could be substituted for ``fossil update 
> -q'':
>
> shouldiupdate.sh && fossil update 2>&1 | mail -s 'Fossil update' m...@he.re

Absolutely.  It should work fine and it's better than my original
shell-only version.  I don't really want to do it that way for a
couple of reasons: 1) I don't want to *have* to be running a fossil
server (I do updates via ssh); and 2) it seems like a lot of overhead
(execution as well as "old version" files) and redundancy.

In the interests of getting into the code a bit, I looked at
implementing this.  Making it truly a quiet option was going to
require fairly major surgery, but after a bit of thought, I realized
that all I really needed was the exit status.  I thought of making
update always exit with this status (a 1-line change), but I was
worried about legacy issues so I added that with a switch (patch
attached - 1 line of code beyond declaring and parsing the switch).
So instead of ``fossil update -q" I would write ``fossil update -s -n
>/dev/null".  I think this is better as it's more incremental and also
more orthogonal.

I'd love for this (or something like it - if someone has a better name
for the switch, or wants to implement a real -q, or wants to make
update always exit with this status) to be part of fossil, as I don't
really want to maintain a fork.

Thanks,  ../Dave

: ~/fs/fossil ; fs diff --from trunk
Index: src/update.c
==================================================================
--- src/update.c
+++ src/update.c
@@ -86,10 +86,16 @@
 ** new checkout.
 **
 ** The -n or --dry-run option causes this command to do a "dry run".
 ** It prints out what would have happened but does not actually make
 ** any changes to the current checkout or the repository.
+**
+** The -s or --status option causes this command to produce a false
+** exit status if no work was done (or would be done in the case of
+** a "dry run").  This exit status is testable in a shell.  Does not
+** otherwise affect the operation of the command.  Typically used with
+** the -n or --dry-run option.
 **
 ** The -v or --verbose option prints status information about
 ** unchanged files in addition to those file that actually do change.
 **
 ** Options:
@@ -96,10 +102,11 @@
 **   --case-sensitive <BOOL> override case-sensitive setting
 **   --debug          print debug information on stdout
 **   --latest         acceptable in place of VERSION, update to latest version
 **   --force-missing  force update if missing content after sync
 **   -n|--dry-run     If given, display instead of run actions
+**   -s|--status      Exits with false status if no work (would be) done
 **   -v|--verbose     print status information about all files
 **   -W|--width <num> Width of lines (default is to auto-detect). Must be >20
 **                    or 0 (= no limit, resulting in a single line per entry).
 **
 ** See also: revert
@@ -108,10 +115,11 @@
   int vid;              /* Current version */
   int tid=0;            /* Target version - version we are changing to */
   Stmt q;
   int latestFlag;       /* --latest.  Pick the latest version if true */
   int dryRunFlag;       /* -n or --dry-run.  Do a dry run */
+  int statusFlag;       /* -s or --status.  Produces false exit
status if no work (would be) done */
   int verboseFlag;      /* -v or --verbose.  Output extra information */
   int forceMissingFlag; /* --force-missing.  Continue if missing content */
   int debugFlag;        /* --debug option */
   int setmtimeFlag;     /* --setmtime.  Set mtimes on files */
   int nChng;            /* Number of file renames */
@@ -136,10 +144,11 @@
     }
   }else{
     width = -1;
   }
   latestFlag = find_option("latest",0, 0)!=0;
+  statusFlag = find_option("status","s",0)!=0;
   dryRunFlag = find_option("dry-run","n",0)!=0;
   if( !dryRunFlag ){
     dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */
   }
   verboseFlag = find_option("verbose","v",0)!=0;
@@ -582,10 +591,11 @@
     }
     if( !internalUpdate ) undo_finish();
     if( setmtimeFlag ) vfile_check_signature(tid, CKSIG_SETMTIME);
     db_end_transaction(0);
   }
+  if ( statusFlag ) fossil_exit(nUpdate==0);
 }

 /*
 ** Make sure empty directories are created
 */
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to