Fossil SCM
When stdout is not a tty, avoid doing the carriage-return-to-reuse-the-console-line trick for emiting metrics while syncing, and instead emit the stats after the end of the loop. This means that log files from cron jobs no longer contain the carriage-return clutter.
Commit
f8800f34645e7cda785409ccad39e19864925e4b30114f32160d14040907fe84
Parent
898a70ce82a524c…
1 file changed
+14
-5
+14
-5
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1989,10 +1989,11 @@ | ||
| 1989 | 1989 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1990 | 1990 | int autopushFailed = 0; /* Autopush following commit failed if true */ |
| 1991 | 1991 | const char *zCkinLock; /* Name of check-in to lock. NULL for none */ |
| 1992 | 1992 | const char *zClientId; /* A unique identifier for this check-out */ |
| 1993 | 1993 | unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */ |
| 1994 | + const int bOutIsTty = fossil_isatty(fossil_fileno(stdout)); | |
| 1994 | 1995 | |
| 1995 | 1996 | if( pnRcvd ) *pnRcvd = 0; |
| 1996 | 1997 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1997 | 1998 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1998 | 1999 | && configRcvMask==0 |
| @@ -2304,12 +2305,14 @@ | ||
| 2304 | 2305 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 2305 | 2306 | xfer.nFileSent, xfer.nDeltaSent); |
| 2306 | 2307 | }else{ |
| 2307 | 2308 | nRoundtrip++; |
| 2308 | 2309 | nArtifactSent += xfer.nFileSent + xfer.nDeltaSent; |
| 2309 | - fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, | |
| 2310 | - nRoundtrip, nArtifactSent, nArtifactRcvd); | |
| 2310 | + if( bOutIsTty!=0 ){ | |
| 2311 | + fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, | |
| 2312 | + nRoundtrip, nArtifactSent, nArtifactRcvd); | |
| 2313 | + } | |
| 2311 | 2314 | } |
| 2312 | 2315 | nCardSent = 0; |
| 2313 | 2316 | nCardRcvd = 0; |
| 2314 | 2317 | xfer.nFileSent = 0; |
| 2315 | 2318 | xfer.nDeltaSent = 0; |
| @@ -2805,12 +2808,14 @@ | ||
| 2805 | 2808 | if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){ |
| 2806 | 2809 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:", |
| 2807 | 2810 | blob_size(&recv), nCardRcvd, |
| 2808 | 2811 | xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); |
| 2809 | 2812 | }else{ |
| 2810 | - fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, | |
| 2811 | - nRoundtrip, nArtifactSent, nArtifactRcvd); | |
| 2813 | + if( bOutIsTty!=0 ){ | |
| 2814 | + fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, | |
| 2815 | + nRoundtrip, nArtifactSent, nArtifactRcvd); | |
| 2816 | + } | |
| 2812 | 2817 | } |
| 2813 | 2818 | nUncRcvd += blob_size(&recv); |
| 2814 | 2819 | blob_reset(&recv); |
| 2815 | 2820 | nCycle++; |
| 2816 | 2821 | |
| @@ -2864,11 +2869,15 @@ | ||
| 2864 | 2869 | }else if( rSkew*24.0*3600.0 < -10.0 ){ |
| 2865 | 2870 | fossil_warning("*** time skew *** server is slow by %s", |
| 2866 | 2871 | db_timespan_name(-rSkew)); |
| 2867 | 2872 | g.clockSkewSeen = 1; |
| 2868 | 2873 | } |
| 2869 | - | |
| 2874 | + if( bOutIsTty==0 ){ | |
| 2875 | + fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, | |
| 2876 | + nRoundtrip, nArtifactSent, nArtifactRcvd); | |
| 2877 | + fossil_force_newline(); | |
| 2878 | + } | |
| 2870 | 2879 | fossil_force_newline(); |
| 2871 | 2880 | if( g.zHttpCmd==0 ){ |
| 2872 | 2881 | if( syncFlags & SYNC_VERBOSE ){ |
| 2873 | 2882 | fossil_print( |
| 2874 | 2883 | "%s done, wire bytes sent: %lld received: %lld remote: %s%s\n", |
| 2875 | 2884 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1989,10 +1989,11 @@ | |
| 1989 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1990 | int autopushFailed = 0; /* Autopush following commit failed if true */ |
| 1991 | const char *zCkinLock; /* Name of check-in to lock. NULL for none */ |
| 1992 | const char *zClientId; /* A unique identifier for this check-out */ |
| 1993 | unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */ |
| 1994 | |
| 1995 | if( pnRcvd ) *pnRcvd = 0; |
| 1996 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1997 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1998 | && configRcvMask==0 |
| @@ -2304,12 +2305,14 @@ | |
| 2304 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 2305 | xfer.nFileSent, xfer.nDeltaSent); |
| 2306 | }else{ |
| 2307 | nRoundtrip++; |
| 2308 | nArtifactSent += xfer.nFileSent + xfer.nDeltaSent; |
| 2309 | fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, |
| 2310 | nRoundtrip, nArtifactSent, nArtifactRcvd); |
| 2311 | } |
| 2312 | nCardSent = 0; |
| 2313 | nCardRcvd = 0; |
| 2314 | xfer.nFileSent = 0; |
| 2315 | xfer.nDeltaSent = 0; |
| @@ -2805,12 +2808,14 @@ | |
| 2805 | if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){ |
| 2806 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:", |
| 2807 | blob_size(&recv), nCardRcvd, |
| 2808 | xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); |
| 2809 | }else{ |
| 2810 | fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, |
| 2811 | nRoundtrip, nArtifactSent, nArtifactRcvd); |
| 2812 | } |
| 2813 | nUncRcvd += blob_size(&recv); |
| 2814 | blob_reset(&recv); |
| 2815 | nCycle++; |
| 2816 | |
| @@ -2864,11 +2869,15 @@ | |
| 2864 | }else if( rSkew*24.0*3600.0 < -10.0 ){ |
| 2865 | fossil_warning("*** time skew *** server is slow by %s", |
| 2866 | db_timespan_name(-rSkew)); |
| 2867 | g.clockSkewSeen = 1; |
| 2868 | } |
| 2869 | |
| 2870 | fossil_force_newline(); |
| 2871 | if( g.zHttpCmd==0 ){ |
| 2872 | if( syncFlags & SYNC_VERBOSE ){ |
| 2873 | fossil_print( |
| 2874 | "%s done, wire bytes sent: %lld received: %lld remote: %s%s\n", |
| 2875 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1989,10 +1989,11 @@ | |
| 1989 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1990 | int autopushFailed = 0; /* Autopush following commit failed if true */ |
| 1991 | const char *zCkinLock; /* Name of check-in to lock. NULL for none */ |
| 1992 | const char *zClientId; /* A unique identifier for this check-out */ |
| 1993 | unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */ |
| 1994 | const int bOutIsTty = fossil_isatty(fossil_fileno(stdout)); |
| 1995 | |
| 1996 | if( pnRcvd ) *pnRcvd = 0; |
| 1997 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1998 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1999 | && configRcvMask==0 |
| @@ -2304,12 +2305,14 @@ | |
| 2305 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 2306 | xfer.nFileSent, xfer.nDeltaSent); |
| 2307 | }else{ |
| 2308 | nRoundtrip++; |
| 2309 | nArtifactSent += xfer.nFileSent + xfer.nDeltaSent; |
| 2310 | if( bOutIsTty!=0 ){ |
| 2311 | fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, |
| 2312 | nRoundtrip, nArtifactSent, nArtifactRcvd); |
| 2313 | } |
| 2314 | } |
| 2315 | nCardSent = 0; |
| 2316 | nCardRcvd = 0; |
| 2317 | xfer.nFileSent = 0; |
| 2318 | xfer.nDeltaSent = 0; |
| @@ -2805,12 +2808,14 @@ | |
| 2808 | if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){ |
| 2809 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:", |
| 2810 | blob_size(&recv), nCardRcvd, |
| 2811 | xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); |
| 2812 | }else{ |
| 2813 | if( bOutIsTty!=0 ){ |
| 2814 | fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, |
| 2815 | nRoundtrip, nArtifactSent, nArtifactRcvd); |
| 2816 | } |
| 2817 | } |
| 2818 | nUncRcvd += blob_size(&recv); |
| 2819 | blob_reset(&recv); |
| 2820 | nCycle++; |
| 2821 | |
| @@ -2864,11 +2869,15 @@ | |
| 2869 | }else if( rSkew*24.0*3600.0 < -10.0 ){ |
| 2870 | fossil_warning("*** time skew *** server is slow by %s", |
| 2871 | db_timespan_name(-rSkew)); |
| 2872 | g.clockSkewSeen = 1; |
| 2873 | } |
| 2874 | if( bOutIsTty==0 ){ |
| 2875 | fossil_print(zBriefFormat /*works-like:"%d%d%d"*/, |
| 2876 | nRoundtrip, nArtifactSent, nArtifactRcvd); |
| 2877 | fossil_force_newline(); |
| 2878 | } |
| 2879 | fossil_force_newline(); |
| 2880 | if( g.zHttpCmd==0 ){ |
| 2881 | if( syncFlags & SYNC_VERBOSE ){ |
| 2882 | fossil_print( |
| 2883 | "%s done, wire bytes sent: %lld received: %lld remote: %s%s\n", |
| 2884 |