Fossil SCM
Allow for an arbitrary number of tags to be added or removed when amending a checkin.
Commit
cd31ab5a99a37f1975d76063849f7f0febe5d3c3
Parent
5c5d33a9d637881…
2 files changed
+19
-6
+34
+19
-6
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2771,13 +2771,13 @@ | ||
| 2771 | 2771 | const char *zDate; /* Current date of the check-in */ |
| 2772 | 2772 | const char *zNewDate; /* Revised check-in date */ |
| 2773 | 2773 | const char *zColor; |
| 2774 | 2774 | const char *zNewColor; |
| 2775 | 2775 | const char *zNewBrColor; |
| 2776 | - const char *zNewTag; | |
| 2777 | 2776 | const char *zNewBranch; |
| 2778 | - const char *zCancelTag; | |
| 2777 | + const char **pzNewTags = 0; | |
| 2778 | + const char **pzCancelTags = 0; | |
| 2779 | 2779 | int fClose; /* True if leaf should be closed */ |
| 2780 | 2780 | int fHide; /* True if branch should be hidden */ |
| 2781 | 2781 | int fPropagateColor; /* True if color propagates before amend */ |
| 2782 | 2782 | int fNewPropagateColor = 0; /* True if color propagates after amend */ |
| 2783 | 2783 | int fEditComment; /* True if editor to be used for comment */ |
| @@ -2784,10 +2784,12 @@ | ||
| 2784 | 2784 | const char *zChngTime; /* The change time on the control artifact */ |
| 2785 | 2785 | const char *zUuid; |
| 2786 | 2786 | Blob ctrl; |
| 2787 | 2787 | Blob comment; |
| 2788 | 2788 | char *zNow; |
| 2789 | + int nTags, nCancels; | |
| 2790 | + int i; | |
| 2789 | 2791 | |
| 2790 | 2792 | if( g.argc==3 ) usage(AMEND_USAGE_STMT); |
| 2791 | 2793 | fEditComment = find_option("edit-comment",0,0)!=0; |
| 2792 | 2794 | zNewComment = find_option("comment","m",1); |
| 2793 | 2795 | zNewBranch = find_option("branch",0,1); |
| @@ -2797,12 +2799,12 @@ | ||
| 2797 | 2799 | zNewColor = zNewBrColor; |
| 2798 | 2800 | fNewPropagateColor = 1; |
| 2799 | 2801 | } |
| 2800 | 2802 | zNewDate = find_option("date",0,1); |
| 2801 | 2803 | 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); | |
| 2804 | 2806 | fClose = find_option("close",0,0)!=0; |
| 2805 | 2807 | fHide = find_option("hide",0,0)!=0; |
| 2806 | 2808 | zChngTime = find_option("chngtime",0,1); |
| 2807 | 2809 | db_find_and_open_repository(0,0); |
| 2808 | 2810 | user_select(); |
| @@ -2855,13 +2857,24 @@ | ||
| 2855 | 2857 | add_date(zNewDate); |
| 2856 | 2858 | } |
| 2857 | 2859 | if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){ |
| 2858 | 2860 | add_user(zNewUser); |
| 2859 | 2861 | } |
| 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 | + } | |
| 2862 | 2875 | if( fHide ) hide_branch(); |
| 2863 | 2876 | if( fClose ) close_leaf(rid); |
| 2864 | 2877 | if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch); |
| 2865 | 2878 | apply_newtags(&ctrl, rid, zUuid); |
| 2866 | 2879 | show_common_info(rid, "uuid:", 1, 0); |
| 2867 | 2880 | } |
| 2868 | 2881 |
| --- 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 @@ | ||
| 876 | 876 | break; |
| 877 | 877 | } |
| 878 | 878 | } |
| 879 | 879 | return zReturn; |
| 880 | 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 | +} | |
| 881 | 915 | |
| 882 | 916 | /* |
| 883 | 917 | ** Look for a repository command-line option. If present, [re-]cache it in |
| 884 | 918 | ** the global state and return the new pointer, freeing any previous value. |
| 885 | 919 | ** If absent and there is no cached value, return NULL. |
| 886 | 920 |
| --- 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 |