Fossil SCM

Allow for an arbitrary number of tags to be added or removed when amending a checkin.

andybradford 2015-07-24 05:22 pending-review
Commit cd31ab5a99a37f1975d76063849f7f0febe5d3c3
2 files changed +19 -6 +34
+19 -6
--- src/info.c
+++ src/info.c
@@ -2771,13 +2771,13 @@
27712771
const char *zDate; /* Current date of the check-in */
27722772
const char *zNewDate; /* Revised check-in date */
27732773
const char *zColor;
27742774
const char *zNewColor;
27752775
const char *zNewBrColor;
2776
- const char *zNewTag;
27772776
const char *zNewBranch;
2778
- const char *zCancelTag;
2777
+ const char **pzNewTags = 0;
2778
+ const char **pzCancelTags = 0;
27792779
int fClose; /* True if leaf should be closed */
27802780
int fHide; /* True if branch should be hidden */
27812781
int fPropagateColor; /* True if color propagates before amend */
27822782
int fNewPropagateColor = 0; /* True if color propagates after amend */
27832783
int fEditComment; /* True if editor to be used for comment */
@@ -2784,10 +2784,12 @@
27842784
const char *zChngTime; /* The change time on the control artifact */
27852785
const char *zUuid;
27862786
Blob ctrl;
27872787
Blob comment;
27882788
char *zNow;
2789
+ int nTags, nCancels;
2790
+ int i;
27892791
27902792
if( g.argc==3 ) usage(AMEND_USAGE_STMT);
27912793
fEditComment = find_option("edit-comment",0,0)!=0;
27922794
zNewComment = find_option("comment","m",1);
27932795
zNewBranch = find_option("branch",0,1);
@@ -2797,12 +2799,12 @@
27972799
zNewColor = zNewBrColor;
27982800
fNewPropagateColor = 1;
27992801
}
28002802
zNewDate = find_option("date",0,1);
28012803
zNewUser = find_option("author",0,1);
2802
- zNewTag = find_option("tag",0,1);
2803
- zCancelTag = find_option("cancel",0,1);
2804
+ pzNewTags = find_repeatable_option("tag",0,&nTags);
2805
+ pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
28042806
fClose = find_option("close",0,0)!=0;
28052807
fHide = find_option("hide",0,0)!=0;
28062808
zChngTime = find_option("chngtime",0,1);
28072809
db_find_and_open_repository(0,0);
28082810
user_select();
@@ -2855,13 +2857,24 @@
28552857
add_date(zNewDate);
28562858
}
28572859
if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
28582860
add_user(zNewUser);
28592861
}
2860
- if( zNewTag && zNewTag[0] ) add_tag(zNewTag);
2861
- if( zCancelTag && zCancelTag[0] ) cancel_tag(rid,zCancelTag);
2862
+ if( pzNewTags!=0 ){
2863
+ for(i=0; i<nTags; i++){
2864
+ if( pzNewTags[i] && pzNewTags[i][0] ) add_tag(pzNewTags[i]);
2865
+ }
2866
+ fossil_free(pzNewTags);
2867
+ }
2868
+ if( pzCancelTags!=0 ){
2869
+ for(i=0; i<nCancels; i++){
2870
+ if( pzCancelTags[i] && pzCancelTags[i][0] )
2871
+ cancel_tag(rid,pzCancelTags[i]);
2872
+ }
2873
+ fossil_free(pzCancelTags);
2874
+ }
28622875
if( fHide ) hide_branch();
28632876
if( fClose ) close_leaf(rid);
28642877
if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch);
28652878
apply_newtags(&ctrl, rid, zUuid);
28662879
show_common_info(rid, "uuid:", 1, 0);
28672880
}
28682881
--- src/info.c
+++ src/info.c
@@ -2771,13 +2771,13 @@
2771 const char *zDate; /* Current date of the check-in */
2772 const char *zNewDate; /* Revised check-in date */
2773 const char *zColor;
2774 const char *zNewColor;
2775 const char *zNewBrColor;
2776 const char *zNewTag;
2777 const char *zNewBranch;
2778 const char *zCancelTag;
 
2779 int fClose; /* True if leaf should be closed */
2780 int fHide; /* True if branch should be hidden */
2781 int fPropagateColor; /* True if color propagates before amend */
2782 int fNewPropagateColor = 0; /* True if color propagates after amend */
2783 int fEditComment; /* True if editor to be used for comment */
@@ -2784,10 +2784,12 @@
2784 const char *zChngTime; /* The change time on the control artifact */
2785 const char *zUuid;
2786 Blob ctrl;
2787 Blob comment;
2788 char *zNow;
 
 
2789
2790 if( g.argc==3 ) usage(AMEND_USAGE_STMT);
2791 fEditComment = find_option("edit-comment",0,0)!=0;
2792 zNewComment = find_option("comment","m",1);
2793 zNewBranch = find_option("branch",0,1);
@@ -2797,12 +2799,12 @@
2797 zNewColor = zNewBrColor;
2798 fNewPropagateColor = 1;
2799 }
2800 zNewDate = find_option("date",0,1);
2801 zNewUser = find_option("author",0,1);
2802 zNewTag = find_option("tag",0,1);
2803 zCancelTag = find_option("cancel",0,1);
2804 fClose = find_option("close",0,0)!=0;
2805 fHide = find_option("hide",0,0)!=0;
2806 zChngTime = find_option("chngtime",0,1);
2807 db_find_and_open_repository(0,0);
2808 user_select();
@@ -2855,13 +2857,24 @@
2855 add_date(zNewDate);
2856 }
2857 if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
2858 add_user(zNewUser);
2859 }
2860 if( zNewTag && zNewTag[0] ) add_tag(zNewTag);
2861 if( zCancelTag && zCancelTag[0] ) cancel_tag(rid,zCancelTag);
 
 
 
 
 
 
 
 
 
 
 
2862 if( fHide ) hide_branch();
2863 if( fClose ) close_leaf(rid);
2864 if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch);
2865 apply_newtags(&ctrl, rid, zUuid);
2866 show_common_info(rid, "uuid:", 1, 0);
2867 }
2868
--- src/info.c
+++ src/info.c
@@ -2771,13 +2771,13 @@
2771 const char *zDate; /* Current date of the check-in */
2772 const char *zNewDate; /* Revised check-in date */
2773 const char *zColor;
2774 const char *zNewColor;
2775 const char *zNewBrColor;
 
2776 const char *zNewBranch;
2777 const char **pzNewTags = 0;
2778 const char **pzCancelTags = 0;
2779 int fClose; /* True if leaf should be closed */
2780 int fHide; /* True if branch should be hidden */
2781 int fPropagateColor; /* True if color propagates before amend */
2782 int fNewPropagateColor = 0; /* True if color propagates after amend */
2783 int fEditComment; /* True if editor to be used for comment */
@@ -2784,10 +2784,12 @@
2784 const char *zChngTime; /* The change time on the control artifact */
2785 const char *zUuid;
2786 Blob ctrl;
2787 Blob comment;
2788 char *zNow;
2789 int nTags, nCancels;
2790 int i;
2791
2792 if( g.argc==3 ) usage(AMEND_USAGE_STMT);
2793 fEditComment = find_option("edit-comment",0,0)!=0;
2794 zNewComment = find_option("comment","m",1);
2795 zNewBranch = find_option("branch",0,1);
@@ -2797,12 +2799,12 @@
2799 zNewColor = zNewBrColor;
2800 fNewPropagateColor = 1;
2801 }
2802 zNewDate = find_option("date",0,1);
2803 zNewUser = find_option("author",0,1);
2804 pzNewTags = find_repeatable_option("tag",0,&nTags);
2805 pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
2806 fClose = find_option("close",0,0)!=0;
2807 fHide = find_option("hide",0,0)!=0;
2808 zChngTime = find_option("chngtime",0,1);
2809 db_find_and_open_repository(0,0);
2810 user_select();
@@ -2855,13 +2857,24 @@
2857 add_date(zNewDate);
2858 }
2859 if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
2860 add_user(zNewUser);
2861 }
2862 if( pzNewTags!=0 ){
2863 for(i=0; i<nTags; i++){
2864 if( pzNewTags[i] && pzNewTags[i][0] ) add_tag(pzNewTags[i]);
2865 }
2866 fossil_free(pzNewTags);
2867 }
2868 if( pzCancelTags!=0 ){
2869 for(i=0; i<nCancels; i++){
2870 if( pzCancelTags[i] && pzCancelTags[i][0] )
2871 cancel_tag(rid,pzCancelTags[i]);
2872 }
2873 fossil_free(pzCancelTags);
2874 }
2875 if( fHide ) hide_branch();
2876 if( fClose ) close_leaf(rid);
2877 if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch);
2878 apply_newtags(&ctrl, rid, zUuid);
2879 show_common_info(rid, "uuid:", 1, 0);
2880 }
2881
+34
--- src/main.c
+++ src/main.c
@@ -876,10 +876,44 @@
876876
break;
877877
}
878878
}
879879
return zReturn;
880880
}
881
+
882
+/*
883
+** Look for a multiple occurrences of a command-line option with the
884
+** corresponding argument.
885
+**
886
+** Return a malloc allocated array of pointers to the arguments.
887
+**
888
+** pnUsedArgs is used to store the number of matched arguments.
889
+**
890
+** Caller is responsible to free allocated memory.
891
+*/
892
+const char **find_repeatable_option(
893
+ const char *zLong,
894
+ const char *zShort,
895
+ int *pnUsedArgs
896
+){
897
+ const char *zOption;
898
+ const char **pzArgs = 0;
899
+ int nAllocArgs = 0;
900
+ int nUsedArgs = 0;
901
+
902
+ while( zOption = find_option(zLong, zShort, 1) ){
903
+ if( pzArgs==0 && nAllocArgs==0 ){
904
+ nAllocArgs = 1;
905
+ pzArgs = fossil_malloc( nAllocArgs*sizeof(pzArgs[0]) );
906
+ }else if( nAllocArgs<=nUsedArgs ){
907
+ nAllocArgs = nAllocArgs*2;
908
+ pzArgs = fossil_realloc( pzArgs, nAllocArgs*sizeof(pzArgs[0]) );
909
+ }
910
+ pzArgs[nUsedArgs++] = zOption;
911
+ }
912
+ *pnUsedArgs = nUsedArgs;
913
+ return pzArgs;
914
+}
881915
882916
/*
883917
** Look for a repository command-line option. If present, [re-]cache it in
884918
** the global state and return the new pointer, freeing any previous value.
885919
** If absent and there is no cached value, return NULL.
886920
--- src/main.c
+++ src/main.c
@@ -876,10 +876,44 @@
876 break;
877 }
878 }
879 return zReturn;
880 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
881
882 /*
883 ** Look for a repository command-line option. If present, [re-]cache it in
884 ** the global state and return the new pointer, freeing any previous value.
885 ** If absent and there is no cached value, return NULL.
886
--- src/main.c
+++ src/main.c
@@ -876,10 +876,44 @@
876 break;
877 }
878 }
879 return zReturn;
880 }
881
882 /*
883 ** Look for a multiple occurrences of a command-line option with the
884 ** corresponding argument.
885 **
886 ** Return a malloc allocated array of pointers to the arguments.
887 **
888 ** pnUsedArgs is used to store the number of matched arguments.
889 **
890 ** Caller is responsible to free allocated memory.
891 */
892 const char **find_repeatable_option(
893 const char *zLong,
894 const char *zShort,
895 int *pnUsedArgs
896 ){
897 const char *zOption;
898 const char **pzArgs = 0;
899 int nAllocArgs = 0;
900 int nUsedArgs = 0;
901
902 while( zOption = find_option(zLong, zShort, 1) ){
903 if( pzArgs==0 && nAllocArgs==0 ){
904 nAllocArgs = 1;
905 pzArgs = fossil_malloc( nAllocArgs*sizeof(pzArgs[0]) );
906 }else if( nAllocArgs<=nUsedArgs ){
907 nAllocArgs = nAllocArgs*2;
908 pzArgs = fossil_realloc( pzArgs, nAllocArgs*sizeof(pzArgs[0]) );
909 }
910 pzArgs[nUsedArgs++] = zOption;
911 }
912 *pnUsedArgs = nUsedArgs;
913 return pzArgs;
914 }
915
916 /*
917 ** Look for a repository command-line option. If present, [re-]cache it in
918 ** the global state and return the new pointer, freeing any previous value.
919 ** If absent and there is no cached value, return NULL.
920

Keyboard Shortcuts

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