Fossil SCM

Convert /fdiff and (partially) /vdiff to use checkboxes

andygoth 2017-09-23 21:52 UTC andygoth-annotation-enhancements
Commit 19e896543a1346e7c248925a49ed9bfa3a0a9677596d1dba84e3741305131343
1 file changed +17 -45
+17 -45
--- src/info.c
+++ src/info.c
@@ -1071,20 +1071,20 @@
10711071
** branch=TAG Show all changes on a particular branch
10721072
** v=BOOLEAN Default true. If false, only list files that have changed
10731073
** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
10741074
** glob=STRING only diff files matching this glob
10751075
** dc=N show N lines of context around each diff
1076
-** w ignore whitespace when computing diffs
1076
+** w=BOOLEAN ignore whitespace when computing diffs
10771077
** nohdr omit the description at the top of the page
10781078
**
10791079
**
10801080
** Show all differences between two check-ins.
10811081
*/
10821082
void vdiff_page(void){
10831083
int ridFrom, ridTo;
1084
- int verboseFlag = 0;
1085
- int sideBySide = 0;
1084
+ int verboseFlag;
1085
+ int sideBySide;
10861086
u64 diffFlags = 0;
10871087
Manifest *pFrom, *pTo;
10881088
ManifestFile *pFileFrom, *pFileTo;
10891089
const char *zBranch;
10901090
const char *zFrom;
@@ -1154,21 +1154,11 @@
11541154
sideBySide, (verboseFlag && !sideBySide)?"&v":"", zW);
11551155
}else{
11561156
style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, zW);
11571157
}
11581158
if( sideBySide || verboseFlag ){
1159
- if( *zW ){
1160
- style_submenu_element("Show Whitespace Differences",
1161
- "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T", zFrom, zTo,
1162
- sideBySide, (verboseFlag && !sideBySide)?"&v":"",
1163
- zGlob ? "&glob=" : "", zGlob ? zGlob : "");
1164
- }else{
1165
- style_submenu_element("Ignore Whitespace",
1166
- "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T&w", zFrom, zTo,
1167
- sideBySide, (verboseFlag && !sideBySide)?"&v":"",
1168
- zGlob ? "&glob=" : "", zGlob ? zGlob : "");
1169
- }
1159
+ style_submenu_checkbox("w", "Ignore Whitespace", 0);
11701160
}
11711161
style_header("Check-in Differences");
11721162
if( P("nohdr")==0 ){
11731163
@ <h2>Difference From:</h2><blockquote>
11741164
checkin_description(ridFrom);
@@ -1546,25 +1536,25 @@
15461536
** "ci" parameter is omitted, then the most recent check-in ("tip") is
15471537
** used.
15481538
**
15491539
** Additional parameters:
15501540
**
1551
-** dc=N Show N lines of context around each diff
1552
-** patch Use the patch diff format
1553
-** regex=REGEX Only show differences that match REGEX
1554
-** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
1555
-** verbose Show more detail when describing artifacts
1556
-** w Ignore whitespace
1541
+** dc=N Show N lines of context around each diff
1542
+** patch Use the patch diff format
1543
+** regex=REGEX Only show differences that match REGEX
1544
+** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
1545
+** verbose=BOOLEAN Show more detail when describing artifacts
1546
+** w=BOOLEAN Ignore whitespace
15571547
*/
15581548
void diff_page(void){
15591549
int v1, v2;
1560
- int isPatch;
1561
- int sideBySide;
1550
+ int isPatch = P("patch")!=0;
1551
+ int sideBySide = PB("sbs");
1552
+ int verbose = PB("verbose");
15621553
char *zV1;
15631554
char *zV2;
15641555
const char *zRe;
1565
- const char *zW; /* URL param for ignoring whitespace */
15661556
ReCompiled *pRe = 0;
15671557
u64 diffFlags;
15681558
u32 objdescFlags = 0;
15691559
15701560
login_check_credentials();
@@ -1577,12 +1567,11 @@
15771567
v2 = name_to_rid_www("v2");
15781568
}
15791569
if( v1==0 || v2==0 ) fossil_redirect_home();
15801570
zRe = P("regex");
15811571
if( zRe ) re_compile(&pRe, zRe, 0);
1582
- if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1583
- isPatch = P("patch")!=0;
1572
+ if( verbose ) objdescFlags |= OBJDESC_DETAIL;
15841573
if( isPatch ){
15851574
Blob c1, c2, *pOut;
15861575
pOut = cgi_output_blob();
15871576
cgi_set_content_type("text/plain");
15881577
diffFlags = 4;
@@ -1592,37 +1581,20 @@
15921581
blob_reset(&c1);
15931582
blob_reset(&c2);
15941583
return;
15951584
}
15961585
1597
- sideBySide = !is_false(PD("sbs","1"));
15981586
zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
15991587
zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
16001588
diffFlags = construct_diff_flags(1, sideBySide) | DIFF_HTML;
16011589
16021590
style_header("Diff");
1603
- zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1604
- if( *zW ){
1605
- style_submenu_element("Show Whitespace Changes",
1606
- "%s/fdiff?v1=%T&v2=%T&sbs=%d",
1607
- g.zTop, P("v1"), P("v2"), sideBySide);
1608
- }else{
1609
- style_submenu_element("Ignore Whitespace",
1610
- "%s/fdiff?v1=%T&v2=%T&sbs=%d&w",
1611
- g.zTop, P("v1"), P("v2"), sideBySide);
1612
- }
1591
+ style_submenu_checkbox("w", "Ignore Whitespace", 0);
1592
+ style_submenu_checkbox("sbs", "Side-by-Side Diff", 0);
1593
+ style_submenu_checkbox("verbose", "Verbose", 0);
16131594
style_submenu_element("Patch", "%s/fdiff?v1=%T&v2=%T&patch",
16141595
g.zTop, P("v1"), P("v2"));
1615
- if( !sideBySide ){
1616
- style_submenu_element("Side-by-Side Diff",
1617
- "%s/fdiff?v1=%T&v2=%T&sbs=1%s",
1618
- g.zTop, P("v1"), P("v2"), zW);
1619
- }else{
1620
- style_submenu_element("Unified Diff",
1621
- "%s/fdiff?v1=%T&v2=%T&sbs=0%s",
1622
- g.zTop, P("v1"), P("v2"), zW);
1623
- }
16241596
16251597
if( P("smhdr")!=0 ){
16261598
@ <h2>Differences From Artifact
16271599
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
16281600
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
16291601
--- src/info.c
+++ src/info.c
@@ -1071,20 +1071,20 @@
1071 ** branch=TAG Show all changes on a particular branch
1072 ** v=BOOLEAN Default true. If false, only list files that have changed
1073 ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
1074 ** glob=STRING only diff files matching this glob
1075 ** dc=N show N lines of context around each diff
1076 ** w ignore whitespace when computing diffs
1077 ** nohdr omit the description at the top of the page
1078 **
1079 **
1080 ** Show all differences between two check-ins.
1081 */
1082 void vdiff_page(void){
1083 int ridFrom, ridTo;
1084 int verboseFlag = 0;
1085 int sideBySide = 0;
1086 u64 diffFlags = 0;
1087 Manifest *pFrom, *pTo;
1088 ManifestFile *pFileFrom, *pFileTo;
1089 const char *zBranch;
1090 const char *zFrom;
@@ -1154,21 +1154,11 @@
1154 sideBySide, (verboseFlag && !sideBySide)?"&v":"", zW);
1155 }else{
1156 style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, zW);
1157 }
1158 if( sideBySide || verboseFlag ){
1159 if( *zW ){
1160 style_submenu_element("Show Whitespace Differences",
1161 "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T", zFrom, zTo,
1162 sideBySide, (verboseFlag && !sideBySide)?"&v":"",
1163 zGlob ? "&glob=" : "", zGlob ? zGlob : "");
1164 }else{
1165 style_submenu_element("Ignore Whitespace",
1166 "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T&w", zFrom, zTo,
1167 sideBySide, (verboseFlag && !sideBySide)?"&v":"",
1168 zGlob ? "&glob=" : "", zGlob ? zGlob : "");
1169 }
1170 }
1171 style_header("Check-in Differences");
1172 if( P("nohdr")==0 ){
1173 @ <h2>Difference From:</h2><blockquote>
1174 checkin_description(ridFrom);
@@ -1546,25 +1536,25 @@
1546 ** "ci" parameter is omitted, then the most recent check-in ("tip") is
1547 ** used.
1548 **
1549 ** Additional parameters:
1550 **
1551 ** dc=N Show N lines of context around each diff
1552 ** patch Use the patch diff format
1553 ** regex=REGEX Only show differences that match REGEX
1554 ** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
1555 ** verbose Show more detail when describing artifacts
1556 ** w Ignore whitespace
1557 */
1558 void diff_page(void){
1559 int v1, v2;
1560 int isPatch;
1561 int sideBySide;
 
1562 char *zV1;
1563 char *zV2;
1564 const char *zRe;
1565 const char *zW; /* URL param for ignoring whitespace */
1566 ReCompiled *pRe = 0;
1567 u64 diffFlags;
1568 u32 objdescFlags = 0;
1569
1570 login_check_credentials();
@@ -1577,12 +1567,11 @@
1577 v2 = name_to_rid_www("v2");
1578 }
1579 if( v1==0 || v2==0 ) fossil_redirect_home();
1580 zRe = P("regex");
1581 if( zRe ) re_compile(&pRe, zRe, 0);
1582 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1583 isPatch = P("patch")!=0;
1584 if( isPatch ){
1585 Blob c1, c2, *pOut;
1586 pOut = cgi_output_blob();
1587 cgi_set_content_type("text/plain");
1588 diffFlags = 4;
@@ -1592,37 +1581,20 @@
1592 blob_reset(&c1);
1593 blob_reset(&c2);
1594 return;
1595 }
1596
1597 sideBySide = !is_false(PD("sbs","1"));
1598 zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
1599 zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
1600 diffFlags = construct_diff_flags(1, sideBySide) | DIFF_HTML;
1601
1602 style_header("Diff");
1603 zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1604 if( *zW ){
1605 style_submenu_element("Show Whitespace Changes",
1606 "%s/fdiff?v1=%T&v2=%T&sbs=%d",
1607 g.zTop, P("v1"), P("v2"), sideBySide);
1608 }else{
1609 style_submenu_element("Ignore Whitespace",
1610 "%s/fdiff?v1=%T&v2=%T&sbs=%d&w",
1611 g.zTop, P("v1"), P("v2"), sideBySide);
1612 }
1613 style_submenu_element("Patch", "%s/fdiff?v1=%T&v2=%T&patch",
1614 g.zTop, P("v1"), P("v2"));
1615 if( !sideBySide ){
1616 style_submenu_element("Side-by-Side Diff",
1617 "%s/fdiff?v1=%T&v2=%T&sbs=1%s",
1618 g.zTop, P("v1"), P("v2"), zW);
1619 }else{
1620 style_submenu_element("Unified Diff",
1621 "%s/fdiff?v1=%T&v2=%T&sbs=0%s",
1622 g.zTop, P("v1"), P("v2"), zW);
1623 }
1624
1625 if( P("smhdr")!=0 ){
1626 @ <h2>Differences From Artifact
1627 @ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
1628 @ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
1629
--- src/info.c
+++ src/info.c
@@ -1071,20 +1071,20 @@
1071 ** branch=TAG Show all changes on a particular branch
1072 ** v=BOOLEAN Default true. If false, only list files that have changed
1073 ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
1074 ** glob=STRING only diff files matching this glob
1075 ** dc=N show N lines of context around each diff
1076 ** w=BOOLEAN ignore whitespace when computing diffs
1077 ** nohdr omit the description at the top of the page
1078 **
1079 **
1080 ** Show all differences between two check-ins.
1081 */
1082 void vdiff_page(void){
1083 int ridFrom, ridTo;
1084 int verboseFlag;
1085 int sideBySide;
1086 u64 diffFlags = 0;
1087 Manifest *pFrom, *pTo;
1088 ManifestFile *pFileFrom, *pFileTo;
1089 const char *zBranch;
1090 const char *zFrom;
@@ -1154,21 +1154,11 @@
1154 sideBySide, (verboseFlag && !sideBySide)?"&v":"", zW);
1155 }else{
1156 style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, zW);
1157 }
1158 if( sideBySide || verboseFlag ){
1159 style_submenu_checkbox("w", "Ignore Whitespace", 0);
 
 
 
 
 
 
 
 
 
 
1160 }
1161 style_header("Check-in Differences");
1162 if( P("nohdr")==0 ){
1163 @ <h2>Difference From:</h2><blockquote>
1164 checkin_description(ridFrom);
@@ -1546,25 +1536,25 @@
1536 ** "ci" parameter is omitted, then the most recent check-in ("tip") is
1537 ** used.
1538 **
1539 ** Additional parameters:
1540 **
1541 ** dc=N Show N lines of context around each diff
1542 ** patch Use the patch diff format
1543 ** regex=REGEX Only show differences that match REGEX
1544 ** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
1545 ** verbose=BOOLEAN Show more detail when describing artifacts
1546 ** w=BOOLEAN Ignore whitespace
1547 */
1548 void diff_page(void){
1549 int v1, v2;
1550 int isPatch = P("patch")!=0;
1551 int sideBySide = PB("sbs");
1552 int verbose = PB("verbose");
1553 char *zV1;
1554 char *zV2;
1555 const char *zRe;
 
1556 ReCompiled *pRe = 0;
1557 u64 diffFlags;
1558 u32 objdescFlags = 0;
1559
1560 login_check_credentials();
@@ -1577,12 +1567,11 @@
1567 v2 = name_to_rid_www("v2");
1568 }
1569 if( v1==0 || v2==0 ) fossil_redirect_home();
1570 zRe = P("regex");
1571 if( zRe ) re_compile(&pRe, zRe, 0);
1572 if( verbose ) objdescFlags |= OBJDESC_DETAIL;
 
1573 if( isPatch ){
1574 Blob c1, c2, *pOut;
1575 pOut = cgi_output_blob();
1576 cgi_set_content_type("text/plain");
1577 diffFlags = 4;
@@ -1592,37 +1581,20 @@
1581 blob_reset(&c1);
1582 blob_reset(&c2);
1583 return;
1584 }
1585
 
1586 zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
1587 zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
1588 diffFlags = construct_diff_flags(1, sideBySide) | DIFF_HTML;
1589
1590 style_header("Diff");
1591 style_submenu_checkbox("w", "Ignore Whitespace", 0);
1592 style_submenu_checkbox("sbs", "Side-by-Side Diff", 0);
1593 style_submenu_checkbox("verbose", "Verbose", 0);
 
 
 
 
 
 
 
1594 style_submenu_element("Patch", "%s/fdiff?v1=%T&v2=%T&patch",
1595 g.zTop, P("v1"), P("v2"));
 
 
 
 
 
 
 
 
 
1596
1597 if( P("smhdr")!=0 ){
1598 @ <h2>Differences From Artifact
1599 @ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
1600 @ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
1601

Keyboard Shortcuts

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