Fossil SCM
Add the --checkin option to the "fossil diff" command.
Commit
e7c2454da9fc386b70403d59e3cacb65a5358e01
Parent
c468769dbca5199…
1 file changed
+25
-4
+25
-4
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -773,10 +773,13 @@ | ||
| 773 | 773 | ** |
| 774 | 774 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 775 | 775 | ** which the second version of the file or files is taken. If there is |
| 776 | 776 | ** no "--to" option then the (possibly edited) files in the current check-out |
| 777 | 777 | ** are used. |
| 778 | +** | |
| 779 | +** If the "--checkin VERSION" option shows the changes made by | |
| 780 | +** check-in VERSION relative to its primary parent | |
| 778 | 781 | ** |
| 779 | 782 | ** The "-i" command-line option forces the use of the internal diff logic |
| 780 | 783 | ** rather than any external diff program that might be configured using |
| 781 | 784 | ** the "setting" command. If no external diff program is configured, then |
| 782 | 785 | ** the "-i" option is a no-op. The "-i" option converts "gdiff" into "diff". |
| @@ -793,10 +796,11 @@ | ||
| 793 | 796 | ** |
| 794 | 797 | ** Options: |
| 795 | 798 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 796 | 799 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 797 | 800 | ** --brief Show filenames only |
| 801 | +** --checkin VERSION Show diff of all changes in VERSION | |
| 798 | 802 | ** --context|-c N Use N lines of context |
| 799 | 803 | ** --diff-binary BOOL Include binary files when using external commands |
| 800 | 804 | ** --exec-abs-paths Force absolute path names with external commands. |
| 801 | 805 | ** --exec-rel-paths Force relative path names with external commands. |
| 802 | 806 | ** --from|-r VERSION Select VERSION as source for the diff |
| @@ -816,10 +820,11 @@ | ||
| 816 | 820 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 817 | 821 | int isInternDiff; /* True for internal diff */ |
| 818 | 822 | int verboseFlag; /* True if -v or --verbose flag is used */ |
| 819 | 823 | const char *zFrom; /* Source version number */ |
| 820 | 824 | const char *zTo; /* Target version number */ |
| 825 | + const char *zCheckin; /* Check-in version number */ | |
| 821 | 826 | const char *zBranch; /* Branch to diff */ |
| 822 | 827 | const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */ |
| 823 | 828 | const char *zBinGlob = 0; /* Treat file names matching this as binary */ |
| 824 | 829 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 825 | 830 | int againstUndo = 0; /* Diff against files in the undo buffer */ |
| @@ -832,28 +837,33 @@ | ||
| 832 | 837 | } |
| 833 | 838 | isGDiff = g.argv[1][0]=='g'; |
| 834 | 839 | isInternDiff = find_option("internal","i",0)!=0; |
| 835 | 840 | zFrom = find_option("from", "r", 1); |
| 836 | 841 | zTo = find_option("to", 0, 1); |
| 842 | + zCheckin = find_option("checkin", 0, 1); | |
| 837 | 843 | zBranch = find_option("branch", 0, 1); |
| 838 | 844 | againstUndo = find_option("undo",0,0)!=0; |
| 839 | 845 | diffFlags = diff_options(); |
| 840 | 846 | verboseFlag = find_option("verbose","v",0)!=0; |
| 841 | 847 | if( !verboseFlag ){ |
| 842 | 848 | verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */ |
| 843 | 849 | } |
| 844 | 850 | if( verboseFlag ) diffFlags |= DIFF_VERBOSE; |
| 845 | - if( againstUndo && (zFrom!=0 || zTo!=0 || zBranch!=0) ){ | |
| 846 | - fossil_fatal("cannot use --undo together with --from or --to or --branch"); | |
| 851 | + if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){ | |
| 852 | + fossil_fatal("cannot use --undo together with --from, --to, --checkin," | |
| 853 | + " or --branch"); | |
| 847 | 854 | } |
| 848 | 855 | if( zBranch ){ |
| 849 | - if( zTo || zFrom ){ | |
| 850 | - fossil_fatal("cannot use --from or --to with --branch"); | |
| 856 | + if( zTo || zFrom || zCheckin ){ | |
| 857 | + fossil_fatal("cannot use --from, --to, or --checkin with --branch"); | |
| 851 | 858 | } |
| 852 | 859 | zTo = zBranch; |
| 853 | 860 | zFrom = mprintf("root:%s", zBranch); |
| 854 | 861 | } |
| 862 | + if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){ | |
| 863 | + fossil_fatal("cannot use --checkin together with --from or --to"); | |
| 864 | + } | |
| 855 | 865 | if( zTo==0 || againstUndo ){ |
| 856 | 866 | db_must_be_within_tree(); |
| 857 | 867 | }else if( zFrom==0 ){ |
| 858 | 868 | fossil_fatal("must use --from if --to is present"); |
| 859 | 869 | }else{ |
| @@ -881,10 +891,21 @@ | ||
| 881 | 891 | } |
| 882 | 892 | pFileDir[i-2].nName = blob_size(&fname); |
| 883 | 893 | pFileDir[i-2].nUsed = 0; |
| 884 | 894 | blob_reset(&fname); |
| 885 | 895 | } |
| 896 | + } | |
| 897 | + if ( zCheckin!=0 ){ | |
| 898 | + int ridTo = name_to_typed_rid(zCheckin, "ci"); | |
| 899 | + zTo = zCheckin; | |
| 900 | + zFrom = db_text(0, | |
| 901 | + "SELECT uuid FROM blob, plink" | |
| 902 | + " WHERE plink.cid=%d AND plink.isprim AND plink.pid=blob.rid", | |
| 903 | + ridTo); | |
| 904 | + if( zFrom==0 ){ | |
| 905 | + fossil_fatal("check-in %s has no parent", zTo); | |
| 906 | + } | |
| 886 | 907 | } |
| 887 | 908 | if( againstUndo ){ |
| 888 | 909 | if( db_lget_int("undo_available",0)==0 ){ |
| 889 | 910 | fossil_print("No undo or redo is available\n"); |
| 890 | 911 | return; |
| 891 | 912 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -773,10 +773,13 @@ | |
| 773 | ** |
| 774 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 775 | ** which the second version of the file or files is taken. If there is |
| 776 | ** no "--to" option then the (possibly edited) files in the current check-out |
| 777 | ** are used. |
| 778 | ** |
| 779 | ** The "-i" command-line option forces the use of the internal diff logic |
| 780 | ** rather than any external diff program that might be configured using |
| 781 | ** the "setting" command. If no external diff program is configured, then |
| 782 | ** the "-i" option is a no-op. The "-i" option converts "gdiff" into "diff". |
| @@ -793,10 +796,11 @@ | |
| 793 | ** |
| 794 | ** Options: |
| 795 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 796 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 797 | ** --brief Show filenames only |
| 798 | ** --context|-c N Use N lines of context |
| 799 | ** --diff-binary BOOL Include binary files when using external commands |
| 800 | ** --exec-abs-paths Force absolute path names with external commands. |
| 801 | ** --exec-rel-paths Force relative path names with external commands. |
| 802 | ** --from|-r VERSION Select VERSION as source for the diff |
| @@ -816,10 +820,11 @@ | |
| 816 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 817 | int isInternDiff; /* True for internal diff */ |
| 818 | int verboseFlag; /* True if -v or --verbose flag is used */ |
| 819 | const char *zFrom; /* Source version number */ |
| 820 | const char *zTo; /* Target version number */ |
| 821 | const char *zBranch; /* Branch to diff */ |
| 822 | const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */ |
| 823 | const char *zBinGlob = 0; /* Treat file names matching this as binary */ |
| 824 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 825 | int againstUndo = 0; /* Diff against files in the undo buffer */ |
| @@ -832,28 +837,33 @@ | |
| 832 | } |
| 833 | isGDiff = g.argv[1][0]=='g'; |
| 834 | isInternDiff = find_option("internal","i",0)!=0; |
| 835 | zFrom = find_option("from", "r", 1); |
| 836 | zTo = find_option("to", 0, 1); |
| 837 | zBranch = find_option("branch", 0, 1); |
| 838 | againstUndo = find_option("undo",0,0)!=0; |
| 839 | diffFlags = diff_options(); |
| 840 | verboseFlag = find_option("verbose","v",0)!=0; |
| 841 | if( !verboseFlag ){ |
| 842 | verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */ |
| 843 | } |
| 844 | if( verboseFlag ) diffFlags |= DIFF_VERBOSE; |
| 845 | if( againstUndo && (zFrom!=0 || zTo!=0 || zBranch!=0) ){ |
| 846 | fossil_fatal("cannot use --undo together with --from or --to or --branch"); |
| 847 | } |
| 848 | if( zBranch ){ |
| 849 | if( zTo || zFrom ){ |
| 850 | fossil_fatal("cannot use --from or --to with --branch"); |
| 851 | } |
| 852 | zTo = zBranch; |
| 853 | zFrom = mprintf("root:%s", zBranch); |
| 854 | } |
| 855 | if( zTo==0 || againstUndo ){ |
| 856 | db_must_be_within_tree(); |
| 857 | }else if( zFrom==0 ){ |
| 858 | fossil_fatal("must use --from if --to is present"); |
| 859 | }else{ |
| @@ -881,10 +891,21 @@ | |
| 881 | } |
| 882 | pFileDir[i-2].nName = blob_size(&fname); |
| 883 | pFileDir[i-2].nUsed = 0; |
| 884 | blob_reset(&fname); |
| 885 | } |
| 886 | } |
| 887 | if( againstUndo ){ |
| 888 | if( db_lget_int("undo_available",0)==0 ){ |
| 889 | fossil_print("No undo or redo is available\n"); |
| 890 | return; |
| 891 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -773,10 +773,13 @@ | |
| 773 | ** |
| 774 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 775 | ** which the second version of the file or files is taken. If there is |
| 776 | ** no "--to" option then the (possibly edited) files in the current check-out |
| 777 | ** are used. |
| 778 | ** |
| 779 | ** If the "--checkin VERSION" option shows the changes made by |
| 780 | ** check-in VERSION relative to its primary parent |
| 781 | ** |
| 782 | ** The "-i" command-line option forces the use of the internal diff logic |
| 783 | ** rather than any external diff program that might be configured using |
| 784 | ** the "setting" command. If no external diff program is configured, then |
| 785 | ** the "-i" option is a no-op. The "-i" option converts "gdiff" into "diff". |
| @@ -793,10 +796,11 @@ | |
| 796 | ** |
| 797 | ** Options: |
| 798 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 799 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 800 | ** --brief Show filenames only |
| 801 | ** --checkin VERSION Show diff of all changes in VERSION |
| 802 | ** --context|-c N Use N lines of context |
| 803 | ** --diff-binary BOOL Include binary files when using external commands |
| 804 | ** --exec-abs-paths Force absolute path names with external commands. |
| 805 | ** --exec-rel-paths Force relative path names with external commands. |
| 806 | ** --from|-r VERSION Select VERSION as source for the diff |
| @@ -816,10 +820,11 @@ | |
| 820 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 821 | int isInternDiff; /* True for internal diff */ |
| 822 | int verboseFlag; /* True if -v or --verbose flag is used */ |
| 823 | const char *zFrom; /* Source version number */ |
| 824 | const char *zTo; /* Target version number */ |
| 825 | const char *zCheckin; /* Check-in version number */ |
| 826 | const char *zBranch; /* Branch to diff */ |
| 827 | const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */ |
| 828 | const char *zBinGlob = 0; /* Treat file names matching this as binary */ |
| 829 | int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 830 | int againstUndo = 0; /* Diff against files in the undo buffer */ |
| @@ -832,28 +837,33 @@ | |
| 837 | } |
| 838 | isGDiff = g.argv[1][0]=='g'; |
| 839 | isInternDiff = find_option("internal","i",0)!=0; |
| 840 | zFrom = find_option("from", "r", 1); |
| 841 | zTo = find_option("to", 0, 1); |
| 842 | zCheckin = find_option("checkin", 0, 1); |
| 843 | zBranch = find_option("branch", 0, 1); |
| 844 | againstUndo = find_option("undo",0,0)!=0; |
| 845 | diffFlags = diff_options(); |
| 846 | verboseFlag = find_option("verbose","v",0)!=0; |
| 847 | if( !verboseFlag ){ |
| 848 | verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */ |
| 849 | } |
| 850 | if( verboseFlag ) diffFlags |= DIFF_VERBOSE; |
| 851 | if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){ |
| 852 | fossil_fatal("cannot use --undo together with --from, --to, --checkin," |
| 853 | " or --branch"); |
| 854 | } |
| 855 | if( zBranch ){ |
| 856 | if( zTo || zFrom || zCheckin ){ |
| 857 | fossil_fatal("cannot use --from, --to, or --checkin with --branch"); |
| 858 | } |
| 859 | zTo = zBranch; |
| 860 | zFrom = mprintf("root:%s", zBranch); |
| 861 | } |
| 862 | if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){ |
| 863 | fossil_fatal("cannot use --checkin together with --from or --to"); |
| 864 | } |
| 865 | if( zTo==0 || againstUndo ){ |
| 866 | db_must_be_within_tree(); |
| 867 | }else if( zFrom==0 ){ |
| 868 | fossil_fatal("must use --from if --to is present"); |
| 869 | }else{ |
| @@ -881,10 +891,21 @@ | |
| 891 | } |
| 892 | pFileDir[i-2].nName = blob_size(&fname); |
| 893 | pFileDir[i-2].nUsed = 0; |
| 894 | blob_reset(&fname); |
| 895 | } |
| 896 | } |
| 897 | if ( zCheckin!=0 ){ |
| 898 | int ridTo = name_to_typed_rid(zCheckin, "ci"); |
| 899 | zTo = zCheckin; |
| 900 | zFrom = db_text(0, |
| 901 | "SELECT uuid FROM blob, plink" |
| 902 | " WHERE plink.cid=%d AND plink.isprim AND plink.pid=blob.rid", |
| 903 | ridTo); |
| 904 | if( zFrom==0 ){ |
| 905 | fossil_fatal("check-in %s has no parent", zTo); |
| 906 | } |
| 907 | } |
| 908 | if( againstUndo ){ |
| 909 | if( db_lget_int("undo_available",0)==0 ){ |
| 910 | fossil_print("No undo or redo is available\n"); |
| 911 | return; |
| 912 |