Fossil SCM
Get the --tk option working for "fossil stash diff".
Commit
2ed8cdc5187acfda773ec17f01a72297848baea5
Parent
71c3b67a7973f0d…
2 files changed
+9
-5
+25
-2
+9
-5
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -617,10 +617,11 @@ | ||
| 617 | 617 | @ .t tag config add -background {#c0ffc0} |
| 618 | 618 | @ .t tag config rm -background {#ffc0c0} |
| 619 | 619 | @ proc dehtml {x} { |
| 620 | 620 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 621 | 621 | @ } |
| 622 | +@ # puts $cmd | |
| 622 | 623 | @ set in [open $cmd r] |
| 623 | 624 | @ while {![eof $in]} { |
| 624 | 625 | @ set line [gets $in] |
| 625 | 626 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 626 | 627 | @ if {[regexp {^===} $line]} { |
| @@ -652,25 +653,28 @@ | ||
| 652 | 653 | ** Steps: |
| 653 | 654 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 654 | 655 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 655 | 656 | ** (3) Delete the temp file. |
| 656 | 657 | */ |
| 657 | -static void diff_tk(void){ | |
| 658 | +void diff_tk(const char *zSubCmd, int firstArg){ | |
| 658 | 659 | int i; |
| 659 | 660 | Blob script; |
| 660 | 661 | char *zTempFile; |
| 661 | 662 | char *zCmd; |
| 662 | 663 | blob_zero(&script); |
| 663 | - blob_appendf(&script, "set cmd {| \"%/\" diff --html -y -i", g.nameOfExe); | |
| 664 | - for(i=2; i<g.argc; i++){ | |
| 665 | - blob_appendf(&script, " \"%s\"", g.argv[i]); | |
| 664 | + blob_appendf(&script, "set cmd {| \"%/\" %s --html -y -i", | |
| 665 | + g.nameOfExe, zSubCmd); | |
| 666 | + for(i=firstArg; i<g.argc; i++){ | |
| 667 | + blob_append(&script, " ", 1); | |
| 668 | + shell_escape(&script, g.argv[i]); | |
| 666 | 669 | } |
| 667 | 670 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 668 | 671 | zTempFile = write_blob_to_temp_file(&script); |
| 669 | 672 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 670 | 673 | fossil_system(zCmd); |
| 671 | 674 | file_delete(zTempFile); |
| 675 | + fossil_free(zCmd); | |
| 672 | 676 | } |
| 673 | 677 | |
| 674 | 678 | /* |
| 675 | 679 | ** Returns non-zero if files that may be binary should be used with external |
| 676 | 680 | ** diff programs. |
| @@ -757,11 +761,11 @@ | ||
| 757 | 761 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 758 | 762 | u64 diffFlags = 0; /* Flags to control the DIFF */ |
| 759 | 763 | int f; |
| 760 | 764 | |
| 761 | 765 | if( find_option("tk",0,0)!=0 ){ |
| 762 | - diff_tk(); | |
| 766 | + diff_tk("diff", 2); | |
| 763 | 767 | return; |
| 764 | 768 | } |
| 765 | 769 | isGDiff = g.argv[1][0]=='g'; |
| 766 | 770 | isInternDiff = find_option("internal","i",0)!=0; |
| 767 | 771 | zFrom = find_option("from", "r", 1); |
| 768 | 772 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -617,10 +617,11 @@ | |
| 617 | @ .t tag config add -background {#c0ffc0} |
| 618 | @ .t tag config rm -background {#ffc0c0} |
| 619 | @ proc dehtml {x} { |
| 620 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 621 | @ } |
| 622 | @ set in [open $cmd r] |
| 623 | @ while {![eof $in]} { |
| 624 | @ set line [gets $in] |
| 625 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 626 | @ if {[regexp {^===} $line]} { |
| @@ -652,25 +653,28 @@ | |
| 652 | ** Steps: |
| 653 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 654 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 655 | ** (3) Delete the temp file. |
| 656 | */ |
| 657 | static void diff_tk(void){ |
| 658 | int i; |
| 659 | Blob script; |
| 660 | char *zTempFile; |
| 661 | char *zCmd; |
| 662 | blob_zero(&script); |
| 663 | blob_appendf(&script, "set cmd {| \"%/\" diff --html -y -i", g.nameOfExe); |
| 664 | for(i=2; i<g.argc; i++){ |
| 665 | blob_appendf(&script, " \"%s\"", g.argv[i]); |
| 666 | } |
| 667 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 668 | zTempFile = write_blob_to_temp_file(&script); |
| 669 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 670 | fossil_system(zCmd); |
| 671 | file_delete(zTempFile); |
| 672 | } |
| 673 | |
| 674 | /* |
| 675 | ** Returns non-zero if files that may be binary should be used with external |
| 676 | ** diff programs. |
| @@ -757,11 +761,11 @@ | |
| 757 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 758 | u64 diffFlags = 0; /* Flags to control the DIFF */ |
| 759 | int f; |
| 760 | |
| 761 | if( find_option("tk",0,0)!=0 ){ |
| 762 | diff_tk(); |
| 763 | return; |
| 764 | } |
| 765 | isGDiff = g.argv[1][0]=='g'; |
| 766 | isInternDiff = find_option("internal","i",0)!=0; |
| 767 | zFrom = find_option("from", "r", 1); |
| 768 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -617,10 +617,11 @@ | |
| 617 | @ .t tag config add -background {#c0ffc0} |
| 618 | @ .t tag config rm -background {#ffc0c0} |
| 619 | @ proc dehtml {x} { |
| 620 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 621 | @ } |
| 622 | @ # puts $cmd |
| 623 | @ set in [open $cmd r] |
| 624 | @ while {![eof $in]} { |
| 625 | @ set line [gets $in] |
| 626 | @ if {[regexp {^<a name="chunk.*"></a>} $line]} continue |
| 627 | @ if {[regexp {^===} $line]} { |
| @@ -652,25 +653,28 @@ | |
| 653 | ** Steps: |
| 654 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 655 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 656 | ** (3) Delete the temp file. |
| 657 | */ |
| 658 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 659 | int i; |
| 660 | Blob script; |
| 661 | char *zTempFile; |
| 662 | char *zCmd; |
| 663 | blob_zero(&script); |
| 664 | blob_appendf(&script, "set cmd {| \"%/\" %s --html -y -i", |
| 665 | g.nameOfExe, zSubCmd); |
| 666 | for(i=firstArg; i<g.argc; i++){ |
| 667 | blob_append(&script, " ", 1); |
| 668 | shell_escape(&script, g.argv[i]); |
| 669 | } |
| 670 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 671 | zTempFile = write_blob_to_temp_file(&script); |
| 672 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 673 | fossil_system(zCmd); |
| 674 | file_delete(zTempFile); |
| 675 | fossil_free(zCmd); |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | ** Returns non-zero if files that may be binary should be used with external |
| 680 | ** diff programs. |
| @@ -757,11 +761,11 @@ | |
| 761 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 762 | u64 diffFlags = 0; /* Flags to control the DIFF */ |
| 763 | int f; |
| 764 | |
| 765 | if( find_option("tk",0,0)!=0 ){ |
| 766 | diff_tk("diff", 2); |
| 767 | return; |
| 768 | } |
| 769 | isGDiff = g.argv[1][0]=='g'; |
| 770 | isInternDiff = find_option("internal","i",0)!=0; |
| 771 | zFrom = find_option("from", "r", 1); |
| 772 |
+25
-2
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -426,10 +426,21 @@ | ||
| 426 | 426 | ** fossil stash diff ?STASHID? |
| 427 | 427 | ** fossil stash gdiff ?STASHID? |
| 428 | 428 | ** |
| 429 | 429 | ** Show diffs of the current working directory and what that |
| 430 | 430 | ** directory would be if STASHID were applied. |
| 431 | +** | |
| 432 | +** SUMMARY: | |
| 433 | +** fossil stash | |
| 434 | +** fossil stash save ?-m COMMENT? ?FILES...? | |
| 435 | +** fossil stash snapshot ?-m COMMENT? ?FILES...? | |
| 436 | +** fossil stash list|ls ?-l? ?--detail? | |
| 437 | +** fossil stash pop | |
| 438 | +** fossil stash apply ?STASHID? | |
| 439 | +** fossil stash goto ?STASHID? | |
| 440 | +** fossil stash rm|drop ?STASHID? ?--all? | |
| 441 | +** fossil stash [g]diff ?STASHID? ?DIFF-OPTIONS? | |
| 431 | 442 | */ |
| 432 | 443 | void stash_cmd(void){ |
| 433 | 444 | const char *zDb; |
| 434 | 445 | const char *zCmd; |
| 435 | 446 | int nCmd; |
| @@ -572,13 +583,22 @@ | ||
| 572 | 583 | "(SELECT origname FROM stashfile WHERE stashid=%d)", |
| 573 | 584 | stashid); |
| 574 | 585 | undo_finish(); |
| 575 | 586 | }else |
| 576 | 587 | if( memcmp(zCmd, "diff", nCmd)==0 ){ |
| 577 | - const char *zDiffCmd = diff_command_external(0); | |
| 588 | + const char *zDiffCmd = 0; | |
| 578 | 589 | const char *zBinGlob = 0; |
| 579 | 590 | int fIncludeBinary = 0; |
| 591 | + | |
| 592 | + if( find_option("tk",0,0)!=0 ){ | |
| 593 | + db_close(0); | |
| 594 | + diff_tk("stash diff", 3); | |
| 595 | + return; | |
| 596 | + } | |
| 597 | + if( find_option("internal","i",0)==0 ){ | |
| 598 | + zDiffCmd = diff_command_external(0); | |
| 599 | + } | |
| 580 | 600 | u64 diffFlags = diff_options(); |
| 581 | 601 | if( g.argc>4 ) usage("diff STASHID"); |
| 582 | 602 | if( zDiffCmd ){ |
| 583 | 603 | zBinGlob = diff_get_binary_glob(); |
| 584 | 604 | fIncludeBinary = diff_include_binary_files(); |
| @@ -585,13 +605,16 @@ | ||
| 585 | 605 | } |
| 586 | 606 | stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); |
| 587 | 607 | stash_diff(stashid, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags); |
| 588 | 608 | }else |
| 589 | 609 | if( memcmp(zCmd, "gdiff", nCmd)==0 ){ |
| 590 | - const char *zDiffCmd = diff_command_external(1); | |
| 610 | + const char *zDiffCmd = 0; | |
| 591 | 611 | const char *zBinGlob = 0; |
| 592 | 612 | int fIncludeBinary = 0; |
| 613 | + if( find_option("internal","i",0)==0 ){ | |
| 614 | + zDiffCmd = diff_command_external(0); | |
| 615 | + } | |
| 593 | 616 | u64 diffFlags = diff_options(); |
| 594 | 617 | if( g.argc>4 ) usage("gdiff STASHID"); |
| 595 | 618 | if( zDiffCmd ){ |
| 596 | 619 | zBinGlob = diff_get_binary_glob(); |
| 597 | 620 | fIncludeBinary = diff_include_binary_files(); |
| 598 | 621 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -426,10 +426,21 @@ | |
| 426 | ** fossil stash diff ?STASHID? |
| 427 | ** fossil stash gdiff ?STASHID? |
| 428 | ** |
| 429 | ** Show diffs of the current working directory and what that |
| 430 | ** directory would be if STASHID were applied. |
| 431 | */ |
| 432 | void stash_cmd(void){ |
| 433 | const char *zDb; |
| 434 | const char *zCmd; |
| 435 | int nCmd; |
| @@ -572,13 +583,22 @@ | |
| 572 | "(SELECT origname FROM stashfile WHERE stashid=%d)", |
| 573 | stashid); |
| 574 | undo_finish(); |
| 575 | }else |
| 576 | if( memcmp(zCmd, "diff", nCmd)==0 ){ |
| 577 | const char *zDiffCmd = diff_command_external(0); |
| 578 | const char *zBinGlob = 0; |
| 579 | int fIncludeBinary = 0; |
| 580 | u64 diffFlags = diff_options(); |
| 581 | if( g.argc>4 ) usage("diff STASHID"); |
| 582 | if( zDiffCmd ){ |
| 583 | zBinGlob = diff_get_binary_glob(); |
| 584 | fIncludeBinary = diff_include_binary_files(); |
| @@ -585,13 +605,16 @@ | |
| 585 | } |
| 586 | stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); |
| 587 | stash_diff(stashid, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags); |
| 588 | }else |
| 589 | if( memcmp(zCmd, "gdiff", nCmd)==0 ){ |
| 590 | const char *zDiffCmd = diff_command_external(1); |
| 591 | const char *zBinGlob = 0; |
| 592 | int fIncludeBinary = 0; |
| 593 | u64 diffFlags = diff_options(); |
| 594 | if( g.argc>4 ) usage("gdiff STASHID"); |
| 595 | if( zDiffCmd ){ |
| 596 | zBinGlob = diff_get_binary_glob(); |
| 597 | fIncludeBinary = diff_include_binary_files(); |
| 598 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -426,10 +426,21 @@ | |
| 426 | ** fossil stash diff ?STASHID? |
| 427 | ** fossil stash gdiff ?STASHID? |
| 428 | ** |
| 429 | ** Show diffs of the current working directory and what that |
| 430 | ** directory would be if STASHID were applied. |
| 431 | ** |
| 432 | ** SUMMARY: |
| 433 | ** fossil stash |
| 434 | ** fossil stash save ?-m COMMENT? ?FILES...? |
| 435 | ** fossil stash snapshot ?-m COMMENT? ?FILES...? |
| 436 | ** fossil stash list|ls ?-l? ?--detail? |
| 437 | ** fossil stash pop |
| 438 | ** fossil stash apply ?STASHID? |
| 439 | ** fossil stash goto ?STASHID? |
| 440 | ** fossil stash rm|drop ?STASHID? ?--all? |
| 441 | ** fossil stash [g]diff ?STASHID? ?DIFF-OPTIONS? |
| 442 | */ |
| 443 | void stash_cmd(void){ |
| 444 | const char *zDb; |
| 445 | const char *zCmd; |
| 446 | int nCmd; |
| @@ -572,13 +583,22 @@ | |
| 583 | "(SELECT origname FROM stashfile WHERE stashid=%d)", |
| 584 | stashid); |
| 585 | undo_finish(); |
| 586 | }else |
| 587 | if( memcmp(zCmd, "diff", nCmd)==0 ){ |
| 588 | const char *zDiffCmd = 0; |
| 589 | const char *zBinGlob = 0; |
| 590 | int fIncludeBinary = 0; |
| 591 | |
| 592 | if( find_option("tk",0,0)!=0 ){ |
| 593 | db_close(0); |
| 594 | diff_tk("stash diff", 3); |
| 595 | return; |
| 596 | } |
| 597 | if( find_option("internal","i",0)==0 ){ |
| 598 | zDiffCmd = diff_command_external(0); |
| 599 | } |
| 600 | u64 diffFlags = diff_options(); |
| 601 | if( g.argc>4 ) usage("diff STASHID"); |
| 602 | if( zDiffCmd ){ |
| 603 | zBinGlob = diff_get_binary_glob(); |
| 604 | fIncludeBinary = diff_include_binary_files(); |
| @@ -585,13 +605,16 @@ | |
| 605 | } |
| 606 | stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); |
| 607 | stash_diff(stashid, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags); |
| 608 | }else |
| 609 | if( memcmp(zCmd, "gdiff", nCmd)==0 ){ |
| 610 | const char *zDiffCmd = 0; |
| 611 | const char *zBinGlob = 0; |
| 612 | int fIncludeBinary = 0; |
| 613 | if( find_option("internal","i",0)==0 ){ |
| 614 | zDiffCmd = diff_command_external(0); |
| 615 | } |
| 616 | u64 diffFlags = diff_options(); |
| 617 | if( g.argc>4 ) usage("gdiff STASHID"); |
| 618 | if( zDiffCmd ){ |
| 619 | zBinGlob = diff_get_binary_glob(); |
| 620 | fIncludeBinary = diff_include_binary_files(); |
| 621 |