Fossil SCM
Allow unified diff for the --tk diff option.
Commit
5be507df71828bfa19ef3111e684197a97586e24
Parent
84f1b5b37f15cc3…
2 files changed
+2
+4
-1
+2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -1538,17 +1538,19 @@ | ||
| 1538 | 1538 | ** --html Format for HTML DIFF_HTML |
| 1539 | 1539 | ** --invert Invert the diff DIFF_INVERT |
| 1540 | 1540 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1541 | 1541 | ** --noopt Disable optimization DIFF_NOOPT |
| 1542 | 1542 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1543 | +** --unified Unified diff. ~DIFF_SIDEBYSIDE | |
| 1543 | 1544 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1544 | 1545 | */ |
| 1545 | 1546 | int diff_options(void){ |
| 1546 | 1547 | u64 diffFlags = 0; |
| 1547 | 1548 | const char *z; |
| 1548 | 1549 | int f; |
| 1549 | 1550 | if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE; |
| 1551 | + if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE; | |
| 1550 | 1552 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>0 ){ |
| 1551 | 1553 | if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK; |
| 1552 | 1554 | diffFlags |= f; |
| 1553 | 1555 | } |
| 1554 | 1556 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 1555 | 1557 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1538,17 +1538,19 @@ | |
| 1538 | ** --html Format for HTML DIFF_HTML |
| 1539 | ** --invert Invert the diff DIFF_INVERT |
| 1540 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1541 | ** --noopt Disable optimization DIFF_NOOPT |
| 1542 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1543 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1544 | */ |
| 1545 | int diff_options(void){ |
| 1546 | u64 diffFlags = 0; |
| 1547 | const char *z; |
| 1548 | int f; |
| 1549 | if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE; |
| 1550 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>0 ){ |
| 1551 | if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK; |
| 1552 | diffFlags |= f; |
| 1553 | } |
| 1554 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 1555 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1538,17 +1538,19 @@ | |
| 1538 | ** --html Format for HTML DIFF_HTML |
| 1539 | ** --invert Invert the diff DIFF_INVERT |
| 1540 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1541 | ** --noopt Disable optimization DIFF_NOOPT |
| 1542 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1543 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1544 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1545 | */ |
| 1546 | int diff_options(void){ |
| 1547 | u64 diffFlags = 0; |
| 1548 | const char *z; |
| 1549 | int f; |
| 1550 | if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE; |
| 1551 | if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE; |
| 1552 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>0 ){ |
| 1553 | if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK; |
| 1554 | diffFlags |= f; |
| 1555 | } |
| 1556 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 1557 |
+4
-1
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -490,11 +490,13 @@ | ||
| 490 | 490 | @ if {$tcl_platform(platform)=="windows"} {.t config -font {courier 9}} |
| 491 | 491 | @ .t tag config ln -foreground gray |
| 492 | 492 | @ .t tag config chng -background {#d0d0ff} |
| 493 | 493 | @ .t tag config add -background {#c0ffc0} |
| 494 | 494 | @ .t tag config rm -background {#ffc0c0} |
| 495 | -@ proc dehtml {x} {return [string map {& & < < > >} $x]} | |
| 495 | +@ proc dehtml {x} { | |
| 496 | +@ return [string map {& & < < > > ' ' " \"} $x] | |
| 497 | +@ } | |
| 496 | 498 | @ set in [open $cmd r] |
| 497 | 499 | @ while {![eof $in]} { |
| 498 | 500 | @ set line [gets $in] |
| 499 | 501 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 500 | 502 | @ if {[regexp {^===} $line]} { |
| @@ -581,10 +583,11 @@ | ||
| 581 | 583 | ** -i use internal diff logic |
| 582 | 584 | ** --new-file|-N output complete text of added or deleted files |
| 583 | 585 | ** --tk Launch a Tcl/Tk GUI for display |
| 584 | 586 | ** --to VERSION select VERSION as target for the diff |
| 585 | 587 | ** --side-by-side|-y side-by-side diff |
| 588 | +** --unified unified diff | |
| 586 | 589 | ** --width|-W N Width of lines in side-by-side diff |
| 587 | 590 | */ |
| 588 | 591 | void diff_cmd(void){ |
| 589 | 592 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 590 | 593 | int isInternDiff; /* True for internal diff */ |
| 591 | 594 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -490,11 +490,13 @@ | |
| 490 | @ if {$tcl_platform(platform)=="windows"} {.t config -font {courier 9}} |
| 491 | @ .t tag config ln -foreground gray |
| 492 | @ .t tag config chng -background {#d0d0ff} |
| 493 | @ .t tag config add -background {#c0ffc0} |
| 494 | @ .t tag config rm -background {#ffc0c0} |
| 495 | @ proc dehtml {x} {return [string map {& & < < > >} $x]} |
| 496 | @ set in [open $cmd r] |
| 497 | @ while {![eof $in]} { |
| 498 | @ set line [gets $in] |
| 499 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 500 | @ if {[regexp {^===} $line]} { |
| @@ -581,10 +583,11 @@ | |
| 581 | ** -i use internal diff logic |
| 582 | ** --new-file|-N output complete text of added or deleted files |
| 583 | ** --tk Launch a Tcl/Tk GUI for display |
| 584 | ** --to VERSION select VERSION as target for the diff |
| 585 | ** --side-by-side|-y side-by-side diff |
| 586 | ** --width|-W N Width of lines in side-by-side diff |
| 587 | */ |
| 588 | void diff_cmd(void){ |
| 589 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 590 | int isInternDiff; /* True for internal diff */ |
| 591 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -490,11 +490,13 @@ | |
| 490 | @ if {$tcl_platform(platform)=="windows"} {.t config -font {courier 9}} |
| 491 | @ .t tag config ln -foreground gray |
| 492 | @ .t tag config chng -background {#d0d0ff} |
| 493 | @ .t tag config add -background {#c0ffc0} |
| 494 | @ .t tag config rm -background {#ffc0c0} |
| 495 | @ proc dehtml {x} { |
| 496 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 497 | @ } |
| 498 | @ set in [open $cmd r] |
| 499 | @ while {![eof $in]} { |
| 500 | @ set line [gets $in] |
| 501 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 502 | @ if {[regexp {^===} $line]} { |
| @@ -581,10 +583,11 @@ | |
| 583 | ** -i use internal diff logic |
| 584 | ** --new-file|-N output complete text of added or deleted files |
| 585 | ** --tk Launch a Tcl/Tk GUI for display |
| 586 | ** --to VERSION select VERSION as target for the diff |
| 587 | ** --side-by-side|-y side-by-side diff |
| 588 | ** --unified unified diff |
| 589 | ** --width|-W N Width of lines in side-by-side diff |
| 590 | */ |
| 591 | void diff_cmd(void){ |
| 592 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 593 | int isInternDiff; /* True for internal diff */ |
| 594 |