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.

stephan 2024-08-27 11:19 trunk
Commit f8800f34645e7cda785409ccad39e19864925e4b30114f32160d14040907fe84
1 file changed +14 -5
+14 -5
--- src/xfer.c
+++ src/xfer.c
@@ -1989,10 +1989,11 @@
19891989
sqlite3_int64 mtime; /* Modification time on a UV file */
19901990
int autopushFailed = 0; /* Autopush following commit failed if true */
19911991
const char *zCkinLock; /* Name of check-in to lock. NULL for none */
19921992
const char *zClientId; /* A unique identifier for this check-out */
19931993
unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
1994
+ const int bOutIsTty = fossil_isatty(fossil_fileno(stdout));
19941995
19951996
if( pnRcvd ) *pnRcvd = 0;
19961997
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
19971998
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
19981999
&& configRcvMask==0
@@ -2304,12 +2305,14 @@
23042305
blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
23052306
xfer.nFileSent, xfer.nDeltaSent);
23062307
}else{
23072308
nRoundtrip++;
23082309
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
+ }
23112314
}
23122315
nCardSent = 0;
23132316
nCardRcvd = 0;
23142317
xfer.nFileSent = 0;
23152318
xfer.nDeltaSent = 0;
@@ -2805,12 +2808,14 @@
28052808
if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
28062809
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
28072810
blob_size(&recv), nCardRcvd,
28082811
xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
28092812
}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
+ }
28122817
}
28132818
nUncRcvd += blob_size(&recv);
28142819
blob_reset(&recv);
28152820
nCycle++;
28162821
@@ -2864,11 +2869,15 @@
28642869
}else if( rSkew*24.0*3600.0 < -10.0 ){
28652870
fossil_warning("*** time skew *** server is slow by %s",
28662871
db_timespan_name(-rSkew));
28672872
g.clockSkewSeen = 1;
28682873
}
2869
-
2874
+ if( bOutIsTty==0 ){
2875
+ fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
2876
+ nRoundtrip, nArtifactSent, nArtifactRcvd);
2877
+ fossil_force_newline();
2878
+ }
28702879
fossil_force_newline();
28712880
if( g.zHttpCmd==0 ){
28722881
if( syncFlags & SYNC_VERBOSE ){
28732882
fossil_print(
28742883
"%s done, wire bytes sent: %lld received: %lld remote: %s%s\n",
28752884
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button