Fossil SCM

Add the --checkin option to the "fossil diff" command.

drh 2016-09-30 15:24 trunk merge
Commit e7c2454da9fc386b70403d59e3cacb65a5358e01
1 file changed +25 -4
+25 -4
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -773,10 +773,13 @@
773773
**
774774
** If the "--to VERSION" option appears, it specifies the check-in from
775775
** which the second version of the file or files is taken. If there is
776776
** no "--to" option then the (possibly edited) files in the current check-out
777777
** are used.
778
+**
779
+** If the "--checkin VERSION" option shows the changes made by
780
+** check-in VERSION relative to its primary parent
778781
**
779782
** The "-i" command-line option forces the use of the internal diff logic
780783
** rather than any external diff program that might be configured using
781784
** the "setting" command. If no external diff program is configured, then
782785
** the "-i" option is a no-op. The "-i" option converts "gdiff" into "diff".
@@ -793,10 +796,11 @@
793796
**
794797
** Options:
795798
** --binary PATTERN Treat files that match the glob PATTERN as binary
796799
** --branch BRANCH Show diff of all changes on BRANCH
797800
** --brief Show filenames only
801
+** --checkin VERSION Show diff of all changes in VERSION
798802
** --context|-c N Use N lines of context
799803
** --diff-binary BOOL Include binary files when using external commands
800804
** --exec-abs-paths Force absolute path names with external commands.
801805
** --exec-rel-paths Force relative path names with external commands.
802806
** --from|-r VERSION Select VERSION as source for the diff
@@ -816,10 +820,11 @@
816820
int isGDiff; /* True for gdiff. False for normal diff */
817821
int isInternDiff; /* True for internal diff */
818822
int verboseFlag; /* True if -v or --verbose flag is used */
819823
const char *zFrom; /* Source version number */
820824
const char *zTo; /* Target version number */
825
+ const char *zCheckin; /* Check-in version number */
821826
const char *zBranch; /* Branch to diff */
822827
const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
823828
const char *zBinGlob = 0; /* Treat file names matching this as binary */
824829
int fIncludeBinary = 0; /* Include binary files for external diff */
825830
int againstUndo = 0; /* Diff against files in the undo buffer */
@@ -832,28 +837,33 @@
832837
}
833838
isGDiff = g.argv[1][0]=='g';
834839
isInternDiff = find_option("internal","i",0)!=0;
835840
zFrom = find_option("from", "r", 1);
836841
zTo = find_option("to", 0, 1);
842
+ zCheckin = find_option("checkin", 0, 1);
837843
zBranch = find_option("branch", 0, 1);
838844
againstUndo = find_option("undo",0,0)!=0;
839845
diffFlags = diff_options();
840846
verboseFlag = find_option("verbose","v",0)!=0;
841847
if( !verboseFlag ){
842848
verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
843849
}
844850
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");
847854
}
848855
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");
851858
}
852859
zTo = zBranch;
853860
zFrom = mprintf("root:%s", zBranch);
854861
}
862
+ if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
863
+ fossil_fatal("cannot use --checkin together with --from or --to");
864
+ }
855865
if( zTo==0 || againstUndo ){
856866
db_must_be_within_tree();
857867
}else if( zFrom==0 ){
858868
fossil_fatal("must use --from if --to is present");
859869
}else{
@@ -881,10 +891,21 @@
881891
}
882892
pFileDir[i-2].nName = blob_size(&fname);
883893
pFileDir[i-2].nUsed = 0;
884894
blob_reset(&fname);
885895
}
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
+ }
886907
}
887908
if( againstUndo ){
888909
if( db_lget_int("undo_available",0)==0 ){
889910
fossil_print("No undo or redo is available\n");
890911
return;
891912
--- 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

Keyboard Shortcuts

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