Check-in [c4dc635e6b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:c4dc635e6b80e237cabef4b4b6d4dc793c0a0b7e
Date: 2012-03-20 14:44:56
User: drh
Comment:Allow multiple --tag options on the "commit" commandline. Change the meaning of the --bgcolor option to only change the background color for the single commit. The new --branchcolor option changes the background color persistently, as --bgcolor used to do. <b>Command-line compatibility break</b>.
Tags And Properties
Changes

Changes to src/checkin.c

630 Blob *pComment, /* Check-in comment text */ 630 Blob *pComment, /* Check-in comment text */ 631 int vid, /* blob-id of the parent manifest */ 631 int vid, /* blob-id of the parent manifest */ 632 int verifyDate, /* Verify that child is younger */ 632 int verifyDate, /* Verify that child is younger */ 633 Blob *pCksum, /* Repository checksum. May be 0 */ 633 Blob *pCksum, /* Repository checksum. May be 0 */ 634 const char *zDateOvrd, /* Date override. If 0 then use 'now' */ 634 const char *zDateOvrd, /* Date override. If 0 then use 'now' */ 635 const char *zUserOvrd, /* User override. If 0 then use g.zLogin */ 635 const char *zUserOvrd, /* User override. If 0 then use g.zLogin */ 636 const char *zBranch, /* Branch name. May be 0 */ 636 const char *zBranch, /* Branch name. May be 0 */ 637 const char *zBgColor, /* Background color. May be 0 */ | 637 const char *zColor, /* One-time gackground color. May be 0 */ > 638 const char *zBrClr, /* Persistent branch color. May be 0 */ 638 const char *zTag, /* Tag to apply to this check-in */ | 639 const char **azTag, /* Tags to apply to this check-in */ 639 int *pnFBcard /* Number of generated B- and F-cards */ 640 int *pnFBcard /* Number of generated B- and F-cards */ 640 ){ 641 ){ 641 char *zDate; /* Date of the check-in */ 642 char *zDate; /* Date of the check-in */ 642 char *zParentUuid; /* UUID of parent check-in */ 643 char *zParentUuid; /* UUID of parent check-in */ 643 Blob filename; /* A single filename */ 644 Blob filename; /* A single filename */ 644 int nBasename; /* Size of base filename */ 645 int nBasename; /* Size of base filename */ 645 Stmt q; /* Query of files changed */ 646 Stmt q; /* Query of files changed */ 646 Stmt q2; /* Query of merge parents */ 647 Stmt q2; /* Query of merge parents */ 647 Blob mcksum; /* Manifest checksum */ 648 Blob mcksum; /* Manifest checksum */ 648 ManifestFile *pFile; /* File from the baseline */ 649 ManifestFile *pFile; /* File from the baseline */ 649 int nFBcard = 0; /* Number of B-cards and F-cards */ 650 int nFBcard = 0; /* Number of B-cards and F-cards */ > 651 int i; /* Loop counter */ 650 652 651 assert( pBaseline==0 || pBaseline->zBaseline==0 ); 653 assert( pBaseline==0 || pBaseline->zBaseline==0 ); 652 assert( pBaseline==0 || zBaselineUuid!=0 ); 654 assert( pBaseline==0 || zBaselineUuid!=0 ); 653 blob_zero(pOut); 655 blob_zero(pOut); 654 zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); 656 zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); 655 if( pBaseline ){ 657 if( pBaseline ){ 656 blob_appendf(pOut, "B %s\n", zBaselineUuid); 658 blob_appendf(pOut, "B %s\n", zBaselineUuid); ................................................................................................................................................................................ 754 db_finalize(&q2); 756 db_finalize(&q2); 755 free(zDate); 757 free(zDate); 756 758 757 blob_appendf(pOut, "\n"); 759 blob_appendf(pOut, "\n"); 758 if( pCksum ) blob_appendf(pOut, "R %b\n", pCksum); 760 if( pCksum ) blob_appendf(pOut, "R %b\n", pCksum); 759 if( zBranch && zBranch[0] ){ 761 if( zBranch && zBranch[0] ){ 760 /* Set tags for the new branch */ 762 /* Set tags for the new branch */ 761 if( zBgColor && zBgColor[0] ){ | 763 if( zBrClr && zBrClr[0] ){ > 764 zColor = 0; 762 blob_appendf(pOut, "T *bgcolor * %F\n", zBgColor); | 765 blob_appendf(pOut, "T *bgcolor * %F\n", zBrClr); 763 } 766 } 764 blob_appendf(pOut, "T *branch * %F\n", zBranch); 767 blob_appendf(pOut, "T *branch * %F\n", zBranch); 765 blob_appendf(pOut, "T *sym-%F *\n", zBranch); 768 blob_appendf(pOut, "T *sym-%F *\n", zBranch); 766 } 769 } > 770 if( zColor && zColor[0] ){ > 771 /* One-time background color */ > 772 blob_appendf(pOut, "T +bgcolor * %F\n", zColor); > 773 } 767 if( g.markPrivate ){ 774 if( g.markPrivate ){ 768 /* If this manifest is private, mark it as such */ 775 /* If this manifest is private, mark it as such */ 769 blob_appendf(pOut, "T +private *\n"); 776 blob_appendf(pOut, "T +private *\n"); 770 } 777 } 771 if( zTag && zTag[0] ){ | 778 if( azTag ){ > 779 for(i=0; azTag[i]; i++){ 772 /* Add a symbolic tag to this check-in */ | 780 /* Add a symbolic tag to this check-in. The tag names have already > 781 ** been sorted and converted using the %F format */ 773 blob_appendf(pOut, "T +sym-%F *\n", zTag); | 782 blob_appendf(pOut, "T +sym-%s *\n", azTag[i]); > 783 } 774 } 784 } 775 if( zBranch && zBranch[0] ){ 785 if( zBranch && zBranch[0] ){ 776 /* For a new branch, cancel all prior propagating tags */ 786 /* For a new branch, cancel all prior propagating tags */ 777 Stmt q; 787 Stmt q; 778 db_prepare(&q, 788 db_prepare(&q, 779 "SELECT tagname FROM tagxref, tag" 789 "SELECT tagname FROM tagxref, tag" 780 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" 790 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" 781 " AND tagtype==2 AND tagname GLOB 'sym-*'" 791 " AND tagtype==2 AND tagname GLOB 'sym-*'" 782 " AND tagname!='sym-'||%Q" 792 " AND tagname!='sym-'||%Q" 783 " ORDER BY tagname", 793 " ORDER BY tagname", 784 vid, zBranch); 794 vid, zBranch); 785 while( db_step(&q)==SQLITE_ROW ){ 795 while( db_step(&q)==SQLITE_ROW ){ 786 const char *zTag = db_column_text(&q, 0); | 796 const char *zBrTag = db_column_text(&q, 0); 787 blob_appendf(pOut, "T -%F *\n", zTag); | 797 blob_appendf(pOut, "T -%F *\n", zBrTag); 788 } 798 } 789 db_finalize(&q); 799 db_finalize(&q); 790 } 800 } 791 blob_appendf(pOut, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); 801 blob_appendf(pOut, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); 792 md5sum_blob(pOut, &mcksum); 802 md5sum_blob(pOut, &mcksum); 793 blob_appendf(pOut, "Z %b\n", &mcksum); 803 blob_appendf(pOut, "Z %b\n", &mcksum); 794 if( pnFBcard ) *pnFBcard = nFBcard; 804 if( pnFBcard ) *pnFBcard = nFBcard; ................................................................................................................................................................................ 842 fossil_fatal("Abandoning commit due to CR+NL line endings in %s", 852 fossil_fatal("Abandoning commit due to CR+NL line endings in %s", 843 blob_str(&fname)); 853 blob_str(&fname)); 844 } 854 } 845 blob_reset(&ans); 855 blob_reset(&ans); 846 blob_reset(&fname); 856 blob_reset(&fname); 847 } 857 } 848 } 858 } > 859 > 860 /* > 861 ** qsort() comparison routine for an array of pointers to strings. > 862 */ > 863 static int tagCmp(const void *a, const void *b){ > 864 char **pA = (char**)a; > 865 char **pB = (char**)b; > 866 return fossil_strcmp(pA[0], pB[0]); > 867 } 849 868 850 /* 869 /* 851 ** COMMAND: ci* 870 ** COMMAND: ci* 852 ** COMMAND: commit 871 ** COMMAND: commit 853 ** 872 ** 854 ** Usage: %fossil commit ?OPTIONS? ?FILE...? 873 ** Usage: %fossil commit ?OPTIONS? ?FILE...? 855 ** 874 ** ................................................................................................................................................................................ 875 ** The --private option creates a private check-in that is never synced. 894 ** The --private option creates a private check-in that is never synced. 876 ** Children of private check-ins are automatically private. 895 ** Children of private check-ins are automatically private. 877 ** 896 ** 878 ** the --tag option applies the symbolic tag name to the check-in. 897 ** the --tag option applies the symbolic tag name to the check-in. 879 ** 898 ** 880 ** Options: 899 ** Options: 881 ** --baseline use a baseline manifest in the commit process 900 ** --baseline use a baseline manifest in the commit process 882 ** --bgcolor COLOR apply given COLOR to the branch | 901 ** --bgcolor COLOR apply COLOR to this one check-in only 883 ** --branch NEW-BRANCH-NAME check in to this new branch 902 ** --branch NEW-BRANCH-NAME check in to this new branch > 903 ** --branchcolor COLOR apply given COLOR to the branch 884 ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment 904 ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment 885 ** --delta use a delta manifest in the commit process 905 ** --delta use a delta manifest in the commit process 886 ** --force|-f allow forking with this commit 906 ** --force|-f allow forking with this commit 887 ** --message-file|-M FILE read the commit comment from given file 907 ** --message-file|-M FILE read the commit comment from given file 888 ** --nosign do not attempt to sign this commit with gpg 908 ** --nosign do not attempt to sign this commit with gpg 889 ** --private do not sync changes and their descendants 909 ** --private do not sync changes and their descendants 890 ** --tag TAG-NAME assign given tag TAG-NAME to the checkin 910 ** --tag TAG-NAME assign given tag TAG-NAME to the checkin ................................................................................................................................................................................ 906 int forceDelta = 0; /* Force a delta-manifest */ 926 int forceDelta = 0; /* Force a delta-manifest */ 907 int forceBaseline = 0; /* Force a baseline-manifest */ 927 int forceBaseline = 0; /* Force a baseline-manifest */ 908 char *zManifestFile; /* Name of the manifest file */ 928 char *zManifestFile; /* Name of the manifest file */ 909 int useCksum; /* True if checksums should be computed and verified */ 929 int useCksum; /* True if checksums should be computed and verified */ 910 int outputManifest; /* True to output "manifest" and "manifest.uuid" */ 930 int outputManifest; /* True to output "manifest" and "manifest.uuid" */ 911 int testRun; /* True for a test run. Debugging only */ 931 int testRun; /* True for a test run. Debugging only */ 912 const char *zBranch; /* Create a new branch with this name */ 932 const char *zBranch; /* Create a new branch with this name */ 913 const char *zBgColor; /* Set background color when branching */ | 933 const char *zBrClr; /* Set background color when branching */ > 934 const char *zColor; /* One-time check-in color */ 914 const char *zDateOvrd; /* Override date string */ 935 const char *zDateOvrd; /* Override date string */ 915 const char *zUserOvrd; /* Override user name */ 936 const char *zUserOvrd; /* Override user name */ 916 const char *zComFile; /* Read commit message from this file */ 937 const char *zComFile; /* Read commit message from this file */ > 938 int nTag = 0; /* Number of --tag arguments */ 917 const char *zTag; /* Symbolic tag to apply to this check-in */ | 939 const char *zTag; /* A single --tag argument */ > 940 const char **azTag = 0;/* Array of all --tag arguments */ 918 Blob manifest; /* Manifest in baseline form */ 941 Blob manifest; /* Manifest in baseline form */ 919 Blob muuid; /* Manifest uuid */ 942 Blob muuid; /* Manifest uuid */ 920 Blob cksum1, cksum2; /* Before and after commit checksums */ 943 Blob cksum1, cksum2; /* Before and after commit checksums */ 921 Blob cksum1b; /* Checksum recorded in the manifest */ 944 Blob cksum1b; /* Checksum recorded in the manifest */ 922 int szD; /* Size of the delta manifest */ 945 int szD; /* Size of the delta manifest */ 923 int szB; /* Size of the baseline manifest */ 946 int szB; /* Size of the baseline manifest */ 924 947 ................................................................................................................................................................................ 929 if( forceDelta && forceBaseline ){ 952 if( forceDelta && forceBaseline ){ 930 fossil_fatal("cannot use --delta and --baseline together"); 953 fossil_fatal("cannot use --delta and --baseline together"); 931 } 954 } 932 testRun = find_option("test",0,0)!=0; 955 testRun = find_option("test",0,0)!=0; 933 zComment = find_option("comment","m",1); 956 zComment = find_option("comment","m",1); 934 forceFlag = find_option("force", "f", 0)!=0; 957 forceFlag = find_option("force", "f", 0)!=0; 935 zBranch = find_option("branch","b",1); 958 zBranch = find_option("branch","b",1); 936 zBgColor = find_option("bgcolor",0,1); | 959 zColor = find_option("bgcolor",0,1); > 960 zBrClr = find_option("branchcolor",0,1); 937 zTag = find_option("tag",0,1); | 961 while( (zTag = find_option("tag",0,1))!=0 ){ > 962 if( zTag[0]==0 ) continue; > 963 azTag = fossil_realloc(azTag, sizeof(char*)*(nTag+2)); > 964 azTag[nTag++] = zTag; > 965 azTag[nTag] = 0; > 966 } 938 zComFile = find_option("message-file", "M", 1); 967 zComFile = find_option("message-file", "M", 1); 939 if( find_option("private",0,0) ){ 968 if( find_option("private",0,0) ){ 940 g.markPrivate = 1; 969 g.markPrivate = 1; 941 if( zBranch==0 ) zBranch = "private"; 970 if( zBranch==0 ) zBranch = "private"; 942 if( zBgColor==0 ) zBgColor = "#fec084"; /* Orange */ | 971 if( zBrClr==0 && zColor==0 ) zBrClr = "#fec084"; /* Orange */ 943 } 972 } 944 zDateOvrd = find_option("date-override",0,1); 973 zDateOvrd = find_option("date-override",0,1); 945 zUserOvrd = find_option("user-override",0,1); 974 zUserOvrd = find_option("user-override",0,1); 946 db_must_be_within_tree(); 975 db_must_be_within_tree(); 947 noSign = db_get_boolean("omitsign", 0)|noSign; 976 noSign = db_get_boolean("omitsign", 0)|noSign; 948 if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } 977 if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } 949 useCksum = db_get_boolean("repo-cksum", 1); 978 useCksum = db_get_boolean("repo-cksum", 1); 950 outputManifest = db_get_boolean("manifest", 0); 979 outputManifest = db_get_boolean("manifest", 0); 951 verify_all_options(); 980 verify_all_options(); > 981 > 982 /* Escape special characters in tags and put all tags in sorted order */ > 983 if( nTag ){ > 984 int i; > 985 for(i=0; i<nTag; i++) azTag[i] = mprintf("%F", azTag[i]); > 986 qsort((void*)azTag, nTag, sizeof(azTag[0]), tagCmp); > 987 } 952 988 953 /* So that older versions of Fossil (that do not understand delta- 989 /* So that older versions of Fossil (that do not understand delta- 954 ** manifest) can continue to use this repository, do not create a new 990 ** manifest) can continue to use this repository, do not create a new 955 ** delta-manifest unless this repository already contains one or more 991 ** delta-manifest unless this repository already contains one or more 956 ** delta-manifets, or unless the delta-manifest is explicitly requested 992 ** delta-manifets, or unless the delta-manifest is explicitly requested 957 ** by the --delta option. 993 ** by the --delta option. 958 */ 994 */ ................................................................................................................................................................................ 1124 blob_append(&comment, "(no comment)", -1); 1160 blob_append(&comment, "(no comment)", -1); 1125 } 1161 } 1126 if( forceDelta ){ 1162 if( forceDelta ){ 1127 blob_zero(&manifest); 1163 blob_zero(&manifest); 1128 }else{ 1164 }else{ 1129 create_manifest(&manifest, 0, 0, &comment, vid, 1165 create_manifest(&manifest, 0, 0, &comment, vid, 1130 !forceFlag, useCksum ? &cksum1 : 0, 1166 !forceFlag, useCksum ? &cksum1 : 0, 1131 zDateOvrd, zUserOvrd, zBranch, zBgColor, zTag, &szB); | 1167 zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr, > 1168 azTag, &szB); 1132 } 1169 } 1133 1170 1134 /* See if a delta-manifest would be more appropriate */ 1171 /* See if a delta-manifest would be more appropriate */ 1135 if( !forceBaseline ){ 1172 if( !forceBaseline ){ 1136 const char *zBaselineUuid; 1173 const char *zBaselineUuid; 1137 Manifest *pParent; 1174 Manifest *pParent; 1138 Manifest *pBaseline; 1175 Manifest *pBaseline; ................................................................................................................................................................................ 1144 zBaselineUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); 1181 zBaselineUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); 1145 pBaseline = pParent; 1182 pBaseline = pParent; 1146 } 1183 } 1147 if( pBaseline ){ 1184 if( pBaseline ){ 1148 Blob delta; 1185 Blob delta; 1149 create_manifest(&delta, zBaselineUuid, pBaseline, &comment, vid, 1186 create_manifest(&delta, zBaselineUuid, pBaseline, &comment, vid, 1150 !forceFlag, useCksum ? &cksum1 : 0, 1187 !forceFlag, useCksum ? &cksum1 : 0, 1151 zDateOvrd, zUserOvrd, zBranch, zBgColor, zTag, &szD); | 1188 zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr, > 1189 azTag, &szD); 1152 /* 1190 /* 1153 ** At this point, two manifests have been constructed, either of 1191 ** At this point, two manifests have been constructed, either of 1154 ** which would work for this checkin. The first manifest (held 1192 ** which would work for this checkin. The first manifest (held 1155 ** in the "manifest" variable) is a baseline manifest and the second 1193 ** in the "manifest" variable) is a baseline manifest and the second 1156 ** (held in variable named "delta") is a delta manifest. The 1194 ** (held in variable named "delta") is a delta manifest. The 1157 ** question now is: which manifest should we use? 1195 ** question now is: which manifest should we use? 1158 ** 1196 **