Fossil SCM

Add an option to "fossil diff" to show the changes made by a specific checkin UUID.

andybradford 2016-09-30 03:49 UTC trunk
Commit 4556962ded6f6497c51cc0a091daff1503e76c60
1 file changed +23 -4
+23 -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 "--changes VERSION" option appears, it shows the changes made by
780
+** check-in VERSION.
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".
@@ -803,10 +806,11 @@
803806
** --internal|-i Use internal diff logic
804807
** --side-by-side|-y Side-by-side diff
805808
** --strip-trailing-cr Strip trailing CR
806809
** --tk Launch a Tcl/Tk GUI for display
807810
** --to VERSION Select VERSION as target for the diff
811
+** --changes VERSION Show diff of all changes in VERSION
808812
** --undo Diff against the "undo" buffer
809813
** --unified Unified diff
810814
** -v|--verbose Output complete text of added or deleted files
811815
** -w|--ignore-all-space Ignore white space when comparing lines
812816
** -W|--width <num> Width of lines in side-by-side 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 *zChanges; /* 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
+ zChanges = find_option("changes", 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 || zChanges!=0 || zBranch!=0) ){
852
+ fossil_fatal("cannot use --undo together with --from, --to, --changes,"
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 || zChanges ){
857
+ fossil_fatal("cannot use --from, --to, or --changes with --branch");
851858
}
852859
zTo = zBranch;
853860
zFrom = mprintf("root:%s", zBranch);
854861
}
862
+ if( zChanges!=0 && ( zFrom!=0 || zTo!=0 ) ){
863
+ fossil_fatal("cannot use --changes 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,19 @@
881891
}
882892
pFileDir[i-2].nName = blob_size(&fname);
883893
pFileDir[i-2].nUsed = 0;
884894
blob_reset(&fname);
885895
}
896
+ }
897
+ if ( zChanges!=0 ){
898
+ zTo = zChanges;
899
+ compute_direct_ancestors(name_to_rid(zChanges));
900
+ zFrom = db_text(0, "SELECT uuid FROM blob AS b JOIN ancestor AS a"
901
+ " ON b.rid=a.rid WHERE generation = 2");
902
+ if( zFrom==0 ) {
903
+ fossil_fatal("No immediate ancestor found for %s", zChanges);
904
+ }
886905
}
887906
if( againstUndo ){
888907
if( db_lget_int("undo_available",0)==0 ){
889908
fossil_print("No undo or redo is available\n");
890909
return;
891910
--- 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".
@@ -803,10 +806,11 @@
803 ** --internal|-i Use internal diff logic
804 ** --side-by-side|-y Side-by-side diff
805 ** --strip-trailing-cr Strip trailing CR
806 ** --tk Launch a Tcl/Tk GUI for display
807 ** --to VERSION Select VERSION as target for the diff
 
808 ** --undo Diff against the "undo" buffer
809 ** --unified Unified diff
810 ** -v|--verbose Output complete text of added or deleted files
811 ** -w|--ignore-all-space Ignore white space when comparing lines
812 ** -W|--width <num> Width of lines in side-by-side 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,19 @@
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 "--changes VERSION" option appears, it shows the changes made by
780 ** check-in VERSION.
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".
@@ -803,10 +806,11 @@
806 ** --internal|-i Use internal diff logic
807 ** --side-by-side|-y Side-by-side diff
808 ** --strip-trailing-cr Strip trailing CR
809 ** --tk Launch a Tcl/Tk GUI for display
810 ** --to VERSION Select VERSION as target for the diff
811 ** --changes VERSION Show diff of all changes in VERSION
812 ** --undo Diff against the "undo" buffer
813 ** --unified Unified diff
814 ** -v|--verbose Output complete text of added or deleted files
815 ** -w|--ignore-all-space Ignore white space when comparing lines
816 ** -W|--width <num> Width of lines in side-by-side 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 *zChanges; /* 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 zChanges = find_option("changes", 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 || zChanges!=0 || zBranch!=0) ){
852 fossil_fatal("cannot use --undo together with --from, --to, --changes,"
853 " or --branch");
854 }
855 if( zBranch ){
856 if( zTo || zFrom || zChanges ){
857 fossil_fatal("cannot use --from, --to, or --changes with --branch");
858 }
859 zTo = zBranch;
860 zFrom = mprintf("root:%s", zBranch);
861 }
862 if( zChanges!=0 && ( zFrom!=0 || zTo!=0 ) ){
863 fossil_fatal("cannot use --changes 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,19 @@
891 }
892 pFileDir[i-2].nName = blob_size(&fname);
893 pFileDir[i-2].nUsed = 0;
894 blob_reset(&fname);
895 }
896 }
897 if ( zChanges!=0 ){
898 zTo = zChanges;
899 compute_direct_ancestors(name_to_rid(zChanges));
900 zFrom = db_text(0, "SELECT uuid FROM blob AS b JOIN ancestor AS a"
901 " ON b.rid=a.rid WHERE generation = 2");
902 if( zFrom==0 ) {
903 fossil_fatal("No immediate ancestor found for %s", zChanges);
904 }
905 }
906 if( againstUndo ){
907 if( db_lget_int("undo_available",0)==0 ){
908 fossil_print("No undo or redo is available\n");
909 return;
910

Keyboard Shortcuts

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