Fossil SCM

Rename the new --www option (check-in [f3961f453aee1ef5]) to --browser and -b. Add the --by option as shorthand for --browser --sidebyside, as that is expected to be a common usage pattern.

drh 2021-08-26 14:01 trunk
Commit 9a3372eec5e549aaf4ffdf57099333e2def162c20bd0f0e12194f5729cd1d9a4
2 files changed +7 -3 +15 -14
+7 -3
--- src/diff.c
+++ src/diff.c
@@ -43,11 +43,11 @@
4343
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
4444
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
4545
#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
4646
#define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */
4747
#define DIFF_WEBPAGE (((u64)0x40)<<32) /* Complete webpage */
48
-#define DIFF_WWW (((u64)0x80)<<32) /* The --www option */
48
+#define DIFF_BROWSER (((u64)0x80)<<32) /* The --browser option */
4949
5050
/*
5151
** These error messages are shared in multiple locations. They are defined
5252
** here for consistency.
5353
*/
@@ -2042,12 +2042,16 @@
20422042
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
20432043
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
20442044
if( find_option("webpage",0,0)!=0 ){
20452045
diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO;
20462046
}
2047
- if( find_option("www",0,0)!=0 ){
2048
- diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_WWW;
2047
+ if( find_option("browser","b",0)!=0 ){
2048
+ diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_BROWSER;
2049
+ }
2050
+ if( find_option("by",0,0)!=0 ){
2051
+ diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_BROWSER
2052
+ |DIFF_SIDEBYSIDE;
20492053
}
20502054
return diffFlags;
20512055
}
20522056
20532057
/*
20542058
--- src/diff.c
+++ src/diff.c
@@ -43,11 +43,11 @@
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
46 #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */
47 #define DIFF_WEBPAGE (((u64)0x40)<<32) /* Complete webpage */
48 #define DIFF_WWW (((u64)0x80)<<32) /* The --www option */
49
50 /*
51 ** These error messages are shared in multiple locations. They are defined
52 ** here for consistency.
53 */
@@ -2042,12 +2042,16 @@
2042 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
2043 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
2044 if( find_option("webpage",0,0)!=0 ){
2045 diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO;
2046 }
2047 if( find_option("www",0,0)!=0 ){
2048 diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_WWW;
 
 
 
 
2049 }
2050 return diffFlags;
2051 }
2052
2053 /*
2054
--- src/diff.c
+++ src/diff.c
@@ -43,11 +43,11 @@
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
46 #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */
47 #define DIFF_WEBPAGE (((u64)0x40)<<32) /* Complete webpage */
48 #define DIFF_BROWSER (((u64)0x80)<<32) /* The --browser option */
49
50 /*
51 ** These error messages are shared in multiple locations. They are defined
52 ** here for consistency.
53 */
@@ -2042,12 +2042,16 @@
2042 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
2043 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
2044 if( find_option("webpage",0,0)!=0 ){
2045 diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO;
2046 }
2047 if( find_option("browser","b",0)!=0 ){
2048 diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_BROWSER;
2049 }
2050 if( find_option("by",0,0)!=0 ){
2051 diffFlags |= DIFF_HTML|DIFF_WEBPAGE|DIFF_LINENO|DIFF_BROWSER
2052 |DIFF_SIDEBYSIDE;
2053 }
2054 return diffFlags;
2055 }
2056
2057 /*
2058
+15 -14
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -237,24 +237,24 @@
237237
@ </body>
238238
@ </html>
239239
;
240240
241241
/*
242
-** State variables used by the --www option for diff
242
+** State variables used by the --browser option for diff
243243
*/
244244
static char *tempDiffFilename; /* File holding the diff HTML */
245245
static FILE *diffOut; /* Open to write into tempDiffFilename */
246246
247247
/* Amount of delay (in milliseconds) between launching the
248
-** web browser and deleting the temporary file used by --www
248
+** web browser and deleting the temporary file used by --browser
249249
*/
250
-#ifndef FOSSIL_WWW_DIFF_DELAY
251
-# define FOSSIL_WWW_DIFF_DELAY 5000 /* 5 seconds by default */
250
+#ifndef FOSSIL_BROWSER_DIFF_DELAY
251
+# define FOSSIL_BROWSER_DIFF_DELAY 5000 /* 5 seconds by default */
252252
#endif
253253
254254
/*
255
-** If we catch a single while writing the temporary file for the --www
255
+** If we catch a single while writing the temporary file for the --browser
256256
** diff output, then delete the temporary file and exit.
257257
*/
258258
static void diff_www_interrupt(int NotUsed){
259259
(void)NotUsed;
260260
if( diffOut ) fclose(diffOut);
@@ -270,18 +270,18 @@
270270
271271
272272
/*
273273
** Do preliminary setup and output before computing a diff.
274274
**
275
-** For --www, redirect stdout to a temporary file that will
275
+** For --browser, redirect stdout to a temporary file that will
276276
** hold the result. Make arrangements to delete that temporary
277277
** file if the diff is interrupted.
278278
**
279
-** For --www and --webpage, output the HTML header.
279
+** For --browser and --webpage, output the HTML header.
280280
*/
281281
void diff_begin(u64 diffFlags){
282
- if( (diffFlags & DIFF_WWW)!=0 ){
282
+ if( (diffFlags & DIFF_BROWSER)!=0 ){
283283
tempDiffFilename = fossil_temp_filename();
284284
tempDiffFilename = sqlite3_mprintf("%z.html", tempDiffFilename);
285285
diffOut = freopen(tempDiffFilename,"wb",stdout);
286286
if( diffOut==0 ){
287287
fossil_fatal("unable to create temporary file \"%s\"",
@@ -305,33 +305,33 @@
305305
}
306306
307307
/* Do any final output required by a diff and complete the diff
308308
** process.
309309
**
310
-** For --www and --webpage, output any javascript required by
310
+** For --browser and --webpage, output any javascript required by
311311
** the diff. (Currently JS is only needed for side-by-side diffs).
312312
**
313
-** For --www, close the connection to the temporary file, then
313
+** For --browser, close the connection to the temporary file, then
314314
** launch a web browser to view the file. After a delay
315
-** of FOSSIL_WWW_DIFF_DELAY milliseconds, delete the temp file.
315
+** of FOSSIL_BROWSER_DIFF_DELAY milliseconds, delete the temp file.
316316
*/
317317
void diff_end(u64 diffFlags, int nErr){
318318
if( (diffFlags & DIFF_WEBPAGE)!=0 ){
319319
if( diffFlags & DIFF_SIDEBYSIDE ){
320320
const unsigned char *zJs = builtin_file("sbsdiff.js", 0);
321321
fossil_print("<script>\n%s</script>\n", zJs);
322322
}
323323
fossil_print("%s", zWebpageEnd);
324324
}
325
- if( (diffFlags & DIFF_WWW)!=0 && nErr==0 ){
325
+ if( (diffFlags & DIFF_BROWSER)!=0 && nErr==0 ){
326326
char *zCmd = mprintf("%$ %$", fossil_web_browser(), tempDiffFilename);
327327
fclose(diffOut);
328328
diffOut = freopen(NULL_DEVICE, "wb", stdout);
329329
fossil_system(zCmd);
330330
fossil_free(zCmd);
331331
diffOut = 0;
332
- sqlite3_sleep(FOSSIL_WWW_DIFF_DELAY);
332
+ sqlite3_sleep(FOSSIL_BROWSER_DIFF_DELAY);
333333
file_delete(tempDiffFilename);
334334
sqlite3_free(tempDiffFilename);
335335
tempDiffFilename = 0;
336336
}
337337
}
@@ -1019,10 +1019,12 @@
10191019
** Options:
10201020
** --binary PATTERN Treat files that match the glob PATTERN
10211021
** as binary
10221022
** --branch BRANCH Show diff of all changes on BRANCH
10231023
** --brief Show filenames only
1024
+** -b|--browser Show the diff output in a web-browser
1025
+** --by Shorthand for "--browser -y"
10241026
** --checkin VERSION Show diff of all changes in VERSION
10251027
** --command PROG External diff program. Overrides "diff-command"
10261028
** -c|--context N Use N lines of context
10271029
** --diff-binary BOOL Include binary files with external commands
10281030
** --exec-abs-paths Force absolute path names on external commands
@@ -1040,11 +1042,10 @@
10401042
** --undo Diff against the "undo" buffer
10411043
** --unified Unified diff
10421044
** -v|--verbose Output complete text of added or deleted files
10431045
** --webpage Format output as a stand-alone HTML webpage
10441046
** -W|--width N Width of lines in side-by-side diff
1045
-** --www Show the diff output in a web-browser
10461047
** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
10471048
*/
10481049
void diff_cmd(void){
10491050
int isGDiff; /* True for gdiff. False for normal diff */
10501051
int isInternDiff; /* True for internal diff */
10511052
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -237,24 +237,24 @@
237 @ </body>
238 @ </html>
239 ;
240
241 /*
242 ** State variables used by the --www option for diff
243 */
244 static char *tempDiffFilename; /* File holding the diff HTML */
245 static FILE *diffOut; /* Open to write into tempDiffFilename */
246
247 /* Amount of delay (in milliseconds) between launching the
248 ** web browser and deleting the temporary file used by --www
249 */
250 #ifndef FOSSIL_WWW_DIFF_DELAY
251 # define FOSSIL_WWW_DIFF_DELAY 5000 /* 5 seconds by default */
252 #endif
253
254 /*
255 ** If we catch a single while writing the temporary file for the --www
256 ** diff output, then delete the temporary file and exit.
257 */
258 static void diff_www_interrupt(int NotUsed){
259 (void)NotUsed;
260 if( diffOut ) fclose(diffOut);
@@ -270,18 +270,18 @@
270
271
272 /*
273 ** Do preliminary setup and output before computing a diff.
274 **
275 ** For --www, redirect stdout to a temporary file that will
276 ** hold the result. Make arrangements to delete that temporary
277 ** file if the diff is interrupted.
278 **
279 ** For --www and --webpage, output the HTML header.
280 */
281 void diff_begin(u64 diffFlags){
282 if( (diffFlags & DIFF_WWW)!=0 ){
283 tempDiffFilename = fossil_temp_filename();
284 tempDiffFilename = sqlite3_mprintf("%z.html", tempDiffFilename);
285 diffOut = freopen(tempDiffFilename,"wb",stdout);
286 if( diffOut==0 ){
287 fossil_fatal("unable to create temporary file \"%s\"",
@@ -305,33 +305,33 @@
305 }
306
307 /* Do any final output required by a diff and complete the diff
308 ** process.
309 **
310 ** For --www and --webpage, output any javascript required by
311 ** the diff. (Currently JS is only needed for side-by-side diffs).
312 **
313 ** For --www, close the connection to the temporary file, then
314 ** launch a web browser to view the file. After a delay
315 ** of FOSSIL_WWW_DIFF_DELAY milliseconds, delete the temp file.
316 */
317 void diff_end(u64 diffFlags, int nErr){
318 if( (diffFlags & DIFF_WEBPAGE)!=0 ){
319 if( diffFlags & DIFF_SIDEBYSIDE ){
320 const unsigned char *zJs = builtin_file("sbsdiff.js", 0);
321 fossil_print("<script>\n%s</script>\n", zJs);
322 }
323 fossil_print("%s", zWebpageEnd);
324 }
325 if( (diffFlags & DIFF_WWW)!=0 && nErr==0 ){
326 char *zCmd = mprintf("%$ %$", fossil_web_browser(), tempDiffFilename);
327 fclose(diffOut);
328 diffOut = freopen(NULL_DEVICE, "wb", stdout);
329 fossil_system(zCmd);
330 fossil_free(zCmd);
331 diffOut = 0;
332 sqlite3_sleep(FOSSIL_WWW_DIFF_DELAY);
333 file_delete(tempDiffFilename);
334 sqlite3_free(tempDiffFilename);
335 tempDiffFilename = 0;
336 }
337 }
@@ -1019,10 +1019,12 @@
1019 ** Options:
1020 ** --binary PATTERN Treat files that match the glob PATTERN
1021 ** as binary
1022 ** --branch BRANCH Show diff of all changes on BRANCH
1023 ** --brief Show filenames only
 
 
1024 ** --checkin VERSION Show diff of all changes in VERSION
1025 ** --command PROG External diff program. Overrides "diff-command"
1026 ** -c|--context N Use N lines of context
1027 ** --diff-binary BOOL Include binary files with external commands
1028 ** --exec-abs-paths Force absolute path names on external commands
@@ -1040,11 +1042,10 @@
1040 ** --undo Diff against the "undo" buffer
1041 ** --unified Unified diff
1042 ** -v|--verbose Output complete text of added or deleted files
1043 ** --webpage Format output as a stand-alone HTML webpage
1044 ** -W|--width N Width of lines in side-by-side diff
1045 ** --www Show the diff output in a web-browser
1046 ** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
1047 */
1048 void diff_cmd(void){
1049 int isGDiff; /* True for gdiff. False for normal diff */
1050 int isInternDiff; /* True for internal diff */
1051
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -237,24 +237,24 @@
237 @ </body>
238 @ </html>
239 ;
240
241 /*
242 ** State variables used by the --browser option for diff
243 */
244 static char *tempDiffFilename; /* File holding the diff HTML */
245 static FILE *diffOut; /* Open to write into tempDiffFilename */
246
247 /* Amount of delay (in milliseconds) between launching the
248 ** web browser and deleting the temporary file used by --browser
249 */
250 #ifndef FOSSIL_BROWSER_DIFF_DELAY
251 # define FOSSIL_BROWSER_DIFF_DELAY 5000 /* 5 seconds by default */
252 #endif
253
254 /*
255 ** If we catch a single while writing the temporary file for the --browser
256 ** diff output, then delete the temporary file and exit.
257 */
258 static void diff_www_interrupt(int NotUsed){
259 (void)NotUsed;
260 if( diffOut ) fclose(diffOut);
@@ -270,18 +270,18 @@
270
271
272 /*
273 ** Do preliminary setup and output before computing a diff.
274 **
275 ** For --browser, redirect stdout to a temporary file that will
276 ** hold the result. Make arrangements to delete that temporary
277 ** file if the diff is interrupted.
278 **
279 ** For --browser and --webpage, output the HTML header.
280 */
281 void diff_begin(u64 diffFlags){
282 if( (diffFlags & DIFF_BROWSER)!=0 ){
283 tempDiffFilename = fossil_temp_filename();
284 tempDiffFilename = sqlite3_mprintf("%z.html", tempDiffFilename);
285 diffOut = freopen(tempDiffFilename,"wb",stdout);
286 if( diffOut==0 ){
287 fossil_fatal("unable to create temporary file \"%s\"",
@@ -305,33 +305,33 @@
305 }
306
307 /* Do any final output required by a diff and complete the diff
308 ** process.
309 **
310 ** For --browser and --webpage, output any javascript required by
311 ** the diff. (Currently JS is only needed for side-by-side diffs).
312 **
313 ** For --browser, close the connection to the temporary file, then
314 ** launch a web browser to view the file. After a delay
315 ** of FOSSIL_BROWSER_DIFF_DELAY milliseconds, delete the temp file.
316 */
317 void diff_end(u64 diffFlags, int nErr){
318 if( (diffFlags & DIFF_WEBPAGE)!=0 ){
319 if( diffFlags & DIFF_SIDEBYSIDE ){
320 const unsigned char *zJs = builtin_file("sbsdiff.js", 0);
321 fossil_print("<script>\n%s</script>\n", zJs);
322 }
323 fossil_print("%s", zWebpageEnd);
324 }
325 if( (diffFlags & DIFF_BROWSER)!=0 && nErr==0 ){
326 char *zCmd = mprintf("%$ %$", fossil_web_browser(), tempDiffFilename);
327 fclose(diffOut);
328 diffOut = freopen(NULL_DEVICE, "wb", stdout);
329 fossil_system(zCmd);
330 fossil_free(zCmd);
331 diffOut = 0;
332 sqlite3_sleep(FOSSIL_BROWSER_DIFF_DELAY);
333 file_delete(tempDiffFilename);
334 sqlite3_free(tempDiffFilename);
335 tempDiffFilename = 0;
336 }
337 }
@@ -1019,10 +1019,12 @@
1019 ** Options:
1020 ** --binary PATTERN Treat files that match the glob PATTERN
1021 ** as binary
1022 ** --branch BRANCH Show diff of all changes on BRANCH
1023 ** --brief Show filenames only
1024 ** -b|--browser Show the diff output in a web-browser
1025 ** --by Shorthand for "--browser -y"
1026 ** --checkin VERSION Show diff of all changes in VERSION
1027 ** --command PROG External diff program. Overrides "diff-command"
1028 ** -c|--context N Use N lines of context
1029 ** --diff-binary BOOL Include binary files with external commands
1030 ** --exec-abs-paths Force absolute path names on external commands
@@ -1040,11 +1042,10 @@
1042 ** --undo Diff against the "undo" buffer
1043 ** --unified Unified diff
1044 ** -v|--verbose Output complete text of added or deleted files
1045 ** --webpage Format output as a stand-alone HTML webpage
1046 ** -W|--width N Width of lines in side-by-side diff
 
1047 ** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
1048 */
1049 void diff_cmd(void){
1050 int isGDiff; /* True for gdiff. False for normal diff */
1051 int isInternDiff; /* True for internal diff */
1052

Keyboard Shortcuts

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