[prev in list] [next in list] [prev in thread] [next in thread]
List: fossil-users
Subject: Re: [fossil-users] Quiet mode for update and sync
From: David Mason <dmason () ryerson ! ca>
Date: 2014-10-19 17:22:13
Message-ID: CALFgxqDVbvnJyndwS+VnoYOzGcXofPX9g41927sfCwVxHStk0A () mail ! gmail ! com
[Download RAW message or body]
Is there any hope this is going to make it into trunk?
I think -hush is the best name for the flag (because it's not *quiet*,
it's *quieter*), and I don't see any need for a short form, it's
really only for use in scipts where typing 3 extra characters
shouldn't be an issue.
../Dave
On 7 October 2014 09:22, David Mason <dmason@ryerson.ca> wrote:
> On 7 October 2014 02:30, Andy Bradford
> <amb-sendok-1415255446.lmkmojimnoldkcbjbhob@bradfords.org> wrote:
>> fossil sync >/dev/null && fossil update -n | grep '^changes:.*files modified\.' && {
>> fossil update 2>&1 | mail -s 'Fossil update' me@he.re
>> }
>
> Best yet, although you actually want a -q switch on grep so you don't
> get that line mailed to you.
> fossil sync >/dev/null && fossil update -n | grep -q
> '^changes:.*files modified\.' && {
>
>> Or if you're running from cron, and cron is correctly figured, the mail
>> command is superfluous:
>
> The mail command is because I actually want to send the mail to several people.
>
> But Stephan's concern about the extra work of running update twice led
> me to the enclosed patch which adds a -m switch (and fixes a typo in
> the help doc). It's a few more lines of code, but it's really just
> formatting. So you would use this like:
> fossil sync >/dev/null && fossil update -m | mail -s "fossil
> update" me@he.re other@the.re
>
> I don't know about the switch name, but otherwise this seems like a
> useful and trivial patch. -h|--hush was another possibility that I
> actually like better, but some people think -h always means help.
> Just --hush without a short form might be the best choice.
>
> Thanks ../Dave
>
> : ~/fs/fossil ; ./fossil diff --from trunk --to update-mail
> Index: src/update.c
> ==================================================================
> --- src/update.c
> +++ src/update.c
> @@ -83,22 +83,28 @@
> ** If FILES is omitted, all files in the current checkout are subject
> ** to being updated and the version of the current checkout is changed
> ** to VERSION. Any uncommitted changes are retained and applied to the
> ** new checkout.
> **
> +** The -m or --mail-quiet option suppresses status info unless there was
> +** some change that took place in the current checkout. This is useful
> +** in a cron script to send mail only when an update is performed, such as:
> +** fossil update -m | mail -E -s "update occurred" a@ex.com b@ex.com
> +**
> ** 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 -v or --verbose option prints status information about
> -** unchanged files in addition to those file that actually do change.
> +** unchanged files in addition to those files that actually do change.
> **
> ** Options:
> ** --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
> +** -m|--mail-quiet quiet unless there are actual changes
> ** -n|--dry-run If given, display instead of run actions
> ** -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).
> **
> @@ -112,10 +118,11 @@
> int dryRunFlag; /* -n or --dry-run. Do a dry run */
> 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 hideInfoFlag; /* -m or --mail-quiet. Quiet unless there are
> actual changes */
> int nChng; /* Number of file renames */
> int *aChng; /* Array of file renames */
> int i; /* Loop counter */
> int nConflict = 0; /* Number of merge conflicts */
> int nOverwrite = 0; /* Number of unmanaged files overwritten */
> @@ -144,10 +151,11 @@
> }
> verboseFlag = find_option("verbose","v",0)!=0;
> forceMissingFlag = find_option("force-missing",0,0)!=0;
> debugFlag = find_option("debug",0,0)!=0;
> setmtimeFlag = find_option("setmtime",0,0)!=0;
> + hideInfoFlag = find_option("mail-quiet","m",0)!=0;
>
> /* We should be done with options.. */
> verify_all_options();
>
> db_must_be_within_tree();
> @@ -514,15 +522,18 @@
> free(zFullPath);
> free(zFullNewPath);
> }
> db_finalize(&q);
> db_finalize(&mtimeXfer);
> - fossil_print("%.79c\n",'-');
> if( nUpdate==0 ){
> - show_common_info(tid, "checkout:", 1, 0);
> - fossil_print("%-13s None. Already up-to-date\n", "changes:");
> + if ( !hideInfoFlag ){
> + fossil_print("%.79c\n",'-');
> + show_common_info(tid, "checkout:", 1, 0);
> + fossil_print("%-13s None. Already up-to-date\n", "changes:");
> + }
> }else{
> + fossil_print("%.79c\n",'-');
> show_common_info(tid, "updated-to:", 1, 0);
> fossil_print("%-13s %d file%s modified.\n", "changes:",
> nUpdate, nUpdate>1 ? "s" : "");
> }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic