Fossil SCM
Fix compiler warning. Coding style adjustments. Rename new link to 'branch diff' for now. Still needs tests.
Commit
1982a8ce0720b19ea921b780ff8c0d891048d333
Parent
48027b23b96faed…
2 files changed
+1
-1
+43
-38
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -675,11 +675,11 @@ | ||
| 675 | 675 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 676 | 676 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 677 | 677 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a> |
| 678 | 678 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 679 | 679 | @ | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid)) |
| 680 | - @ branch changes</a> | |
| 680 | + @ branch diff</a> | |
| 681 | 681 | if( g.perm.Write ){ |
| 682 | 682 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 683 | 683 | } |
| 684 | 684 | @ </td> |
| 685 | 685 | @ </tr> |
| 686 | 686 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -675,11 +675,11 @@ | |
| 675 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 676 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 677 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a> |
| 678 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 679 | @ | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid)) |
| 680 | @ branch changes</a> |
| 681 | if( g.perm.Write ){ |
| 682 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 683 | } |
| 684 | @ </td> |
| 685 | @ </tr> |
| 686 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -675,11 +675,11 @@ | |
| 675 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 676 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 677 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a> |
| 678 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 679 | @ | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid)) |
| 680 | @ branch diff</a> |
| 681 | if( g.perm.Write ){ |
| 682 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 683 | } |
| 684 | @ </td> |
| 685 | @ </tr> |
| 686 |
+43
-38
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -182,16 +182,16 @@ | ||
| 182 | 182 | " ORDER BY mtime DESC LIMIT 1", |
| 183 | 183 | &zTag[4], zType); |
| 184 | 184 | return rid; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - /* "parent:", as for parent branch. It returns the checkin of | |
| 187 | + /* "pbranch:", as for parent branch. It returns the checkin of | |
| 188 | 188 | the last checkin of the parent branch that has been merged in. */ |
| 189 | 189 | if( memcmp(zTag, "pbranch:", 8)==0 ){ |
| 190 | - int branchRid = symbolic_name_to_rid(&zTag[8], zType); | |
| 191 | - if (branchRid == 0) return 0; | |
| 192 | - rid = get_parent_branch_rid(branchRid); | |
| 190 | + rid = symbolic_name_to_rid(&zTag[8], zType); | |
| 191 | + if( rid==0 ) return 0; /* TODO: Negative rid allowed here? */ | |
| 192 | + rid = get_parent_branch_rid(rid); | |
| 193 | 193 | return rid; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /* "tag:" + symbolic-name */ |
| 197 | 197 | if( memcmp(zTag, "tag:", 4)==0 ){ |
| @@ -1068,31 +1068,31 @@ | ||
| 1068 | 1068 | void test_phatoms_cmd(void){ |
| 1069 | 1069 | db_find_and_open_repository(0,0); |
| 1070 | 1070 | describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - | |
| 1074 | - | |
| 1075 | 1073 | /* |
| 1076 | -** It returns the checkin of the last checkin of the parent branch that has | |
| 1077 | -** been merged in. | |
| 1074 | +** Returns the rid for the last checkin where the parent branch was merged. | |
| 1078 | 1075 | */ |
| 1079 | -int get_parent_branch_rid(int ridRequested){ | |
| 1076 | +int get_parent_branch_rid( | |
| 1077 | + int branchRid /* The rid to find parent branch for. */ | |
| 1078 | +){ | |
| 1080 | 1079 | Stmt s; |
| 1081 | - const char *branchName; /* Name of the branch requested at rid */ | |
| 1082 | - const char *parentBranchName; /* Name of the parent branch */ | |
| 1080 | + char *branchName = 0; /* Name of the branch at rid */ | |
| 1081 | + char *parentBranchName = 0; /* Name of the parent branch */ | |
| 1083 | 1082 | int rid; |
| 1084 | 1083 | |
| 1085 | 1084 | /* Get the name of the current branch */ |
| 1086 | 1085 | branchName = db_text(0, |
| 1087 | 1086 | "SELECT value FROM tagxref" |
| 1088 | 1087 | " WHERE tagid=%d" |
| 1089 | 1088 | " AND tagxref.tagtype>0" |
| 1090 | 1089 | " AND rid=%d", |
| 1091 | - TAG_BRANCH, ridRequested); | |
| 1090 | + TAG_BRANCH, branchRid | |
| 1091 | + ); | |
| 1092 | 1092 | |
| 1093 | - if ( !branchName ) | |
| 1093 | + if( !branchName ) | |
| 1094 | 1094 | return 0; |
| 1095 | 1095 | |
| 1096 | 1096 | /* Find the name of the branch this was forked from */ |
| 1097 | 1097 | db_prepare(&s, |
| 1098 | 1098 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| @@ -1099,25 +1099,25 @@ | ||
| 1099 | 1099 | " WHERE cid=:rid" |
| 1100 | 1100 | " AND isprim=1" |
| 1101 | 1101 | " AND tagxref.tagid=%d" |
| 1102 | 1102 | " AND tagxref.tagtype>0" |
| 1103 | 1103 | " AND tagxref.rid=pid", |
| 1104 | - TAG_BRANCH); | |
| 1105 | - | |
| 1106 | - rid = ridRequested; | |
| 1107 | - while( rid > 0 ) { | |
| 1104 | + TAG_BRANCH | |
| 1105 | + ); | |
| 1106 | + rid = branchRid; | |
| 1107 | + while( rid>0 ){ | |
| 1108 | 1108 | db_bind_int(&s, ":rid", rid); |
| 1109 | - if ( db_step(&s) == SQLITE_ROW ) { | |
| 1109 | + if( db_step(&s)==SQLITE_ROW ){ | |
| 1110 | + const char *zValue; /* Branch name of the pid */ | |
| 1110 | 1111 | rid = db_column_int(&s, 0); |
| 1111 | - parentBranchName = db_column_text(&s, 1); | |
| 1112 | - if ( !parentBranchName ) { | |
| 1112 | + zValue = db_column_text(&s, 1); | |
| 1113 | + if( !zValue ){ | |
| 1113 | 1114 | rid = 0; |
| 1114 | 1115 | break; |
| 1115 | 1116 | } |
| 1116 | - | |
| 1117 | - if ( fossil_strcmp(parentBranchName, branchName) ) { | |
| 1118 | - parentBranchName = fossil_strdup(parentBranchName); | |
| 1117 | + if( fossil_strcmp(zValue,branchName) ){ | |
| 1118 | + parentBranchName = fossil_strdup(zValue); | |
| 1119 | 1119 | break; |
| 1120 | 1120 | } |
| 1121 | 1121 | }else{ |
| 1122 | 1122 | rid = 0; |
| 1123 | 1123 | break; |
| @@ -1124,46 +1124,51 @@ | ||
| 1124 | 1124 | } |
| 1125 | 1125 | db_reset(&s); |
| 1126 | 1126 | } |
| 1127 | 1127 | db_finalize(&s); |
| 1128 | 1128 | |
| 1129 | - if (rid == 0) | |
| 1130 | - return 0; | |
| 1129 | + if( rid==0 ){ | |
| 1130 | + fossil_free(branchName); | |
| 1131 | + fossil_free(parentBranchName); | |
| 1132 | + return 0; | |
| 1133 | + } | |
| 1131 | 1134 | |
| 1132 | 1135 | /* Find the last checkin coming from the parent branch */ |
| 1133 | 1136 | db_prepare(&s, |
| 1134 | 1137 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| 1135 | 1138 | " WHERE cid=:rid" |
| 1136 | 1139 | " AND tagxref.tagid=%d" |
| 1137 | 1140 | " AND tagxref.tagtype>0" |
| 1138 | 1141 | " AND tagxref.rid=pid ORDER BY isprim ASC", |
| 1139 | - TAG_BRANCH); | |
| 1140 | - | |
| 1141 | - rid = ridRequested; | |
| 1142 | - while( rid > 0 ) { | |
| 1142 | + TAG_BRANCH | |
| 1143 | + ); | |
| 1144 | + rid = branchRid; | |
| 1145 | + while( rid>0 ){ | |
| 1143 | 1146 | db_bind_int(&s, ":rid", rid); |
| 1144 | 1147 | int found = 0; |
| 1145 | - while ( db_step(&s) == SQLITE_ROW ) { | |
| 1146 | - const char *branchNamePid; /* Branch name of the pid */ | |
| 1147 | - | |
| 1148 | - ++found; | |
| 1148 | + while( db_step(&s)==SQLITE_ROW ){ | |
| 1149 | + const char *zValue; /* Branch name of the pid */ | |
| 1150 | + found++; | |
| 1149 | 1151 | rid = db_column_int(&s, 0); |
| 1150 | - branchNamePid = db_column_text(&s, 1); | |
| 1151 | - if ( !branchNamePid ) { | |
| 1152 | + zValue = db_column_text(&s, 1); | |
| 1153 | + if( !zValue ){ | |
| 1152 | 1154 | break; |
| 1153 | 1155 | } |
| 1154 | - if ( fossil_strcmp(parentBranchName, branchNamePid)==0 ) { | |
| 1156 | + if( fossil_strcmp(parentBranchName,zValue)==0 ){ | |
| 1155 | 1157 | /* Found the last merge from the parent branch */ |
| 1156 | 1158 | db_finalize(&s); |
| 1159 | + fossil_free(branchName); | |
| 1160 | + fossil_free(parentBranchName); | |
| 1157 | 1161 | return rid; |
| 1158 | 1162 | } |
| 1159 | 1163 | } |
| 1160 | - | |
| 1161 | - if (found == 0) { | |
| 1164 | + if( found==0 ){ | |
| 1162 | 1165 | break; |
| 1163 | 1166 | } |
| 1164 | 1167 | db_reset(&s); |
| 1165 | 1168 | } |
| 1166 | 1169 | db_finalize(&s); |
| 1167 | 1170 | |
| 1171 | + fossil_free(branchName); | |
| 1172 | + fossil_free(parentBranchName); | |
| 1168 | 1173 | return 0; |
| 1169 | 1174 | } |
| 1170 | 1175 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -182,16 +182,16 @@ | |
| 182 | " ORDER BY mtime DESC LIMIT 1", |
| 183 | &zTag[4], zType); |
| 184 | return rid; |
| 185 | } |
| 186 | |
| 187 | /* "parent:", as for parent branch. It returns the checkin of |
| 188 | the last checkin of the parent branch that has been merged in. */ |
| 189 | if( memcmp(zTag, "pbranch:", 8)==0 ){ |
| 190 | int branchRid = symbolic_name_to_rid(&zTag[8], zType); |
| 191 | if (branchRid == 0) return 0; |
| 192 | rid = get_parent_branch_rid(branchRid); |
| 193 | return rid; |
| 194 | } |
| 195 | |
| 196 | /* "tag:" + symbolic-name */ |
| 197 | if( memcmp(zTag, "tag:", 4)==0 ){ |
| @@ -1068,31 +1068,31 @@ | |
| 1068 | void test_phatoms_cmd(void){ |
| 1069 | db_find_and_open_repository(0,0); |
| 1070 | describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); |
| 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | /* |
| 1076 | ** It returns the checkin of the last checkin of the parent branch that has |
| 1077 | ** been merged in. |
| 1078 | */ |
| 1079 | int get_parent_branch_rid(int ridRequested){ |
| 1080 | Stmt s; |
| 1081 | const char *branchName; /* Name of the branch requested at rid */ |
| 1082 | const char *parentBranchName; /* Name of the parent branch */ |
| 1083 | int rid; |
| 1084 | |
| 1085 | /* Get the name of the current branch */ |
| 1086 | branchName = db_text(0, |
| 1087 | "SELECT value FROM tagxref" |
| 1088 | " WHERE tagid=%d" |
| 1089 | " AND tagxref.tagtype>0" |
| 1090 | " AND rid=%d", |
| 1091 | TAG_BRANCH, ridRequested); |
| 1092 | |
| 1093 | if ( !branchName ) |
| 1094 | return 0; |
| 1095 | |
| 1096 | /* Find the name of the branch this was forked from */ |
| 1097 | db_prepare(&s, |
| 1098 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| @@ -1099,25 +1099,25 @@ | |
| 1099 | " WHERE cid=:rid" |
| 1100 | " AND isprim=1" |
| 1101 | " AND tagxref.tagid=%d" |
| 1102 | " AND tagxref.tagtype>0" |
| 1103 | " AND tagxref.rid=pid", |
| 1104 | TAG_BRANCH); |
| 1105 | |
| 1106 | rid = ridRequested; |
| 1107 | while( rid > 0 ) { |
| 1108 | db_bind_int(&s, ":rid", rid); |
| 1109 | if ( db_step(&s) == SQLITE_ROW ) { |
| 1110 | rid = db_column_int(&s, 0); |
| 1111 | parentBranchName = db_column_text(&s, 1); |
| 1112 | if ( !parentBranchName ) { |
| 1113 | rid = 0; |
| 1114 | break; |
| 1115 | } |
| 1116 | |
| 1117 | if ( fossil_strcmp(parentBranchName, branchName) ) { |
| 1118 | parentBranchName = fossil_strdup(parentBranchName); |
| 1119 | break; |
| 1120 | } |
| 1121 | }else{ |
| 1122 | rid = 0; |
| 1123 | break; |
| @@ -1124,46 +1124,51 @@ | |
| 1124 | } |
| 1125 | db_reset(&s); |
| 1126 | } |
| 1127 | db_finalize(&s); |
| 1128 | |
| 1129 | if (rid == 0) |
| 1130 | return 0; |
| 1131 | |
| 1132 | /* Find the last checkin coming from the parent branch */ |
| 1133 | db_prepare(&s, |
| 1134 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| 1135 | " WHERE cid=:rid" |
| 1136 | " AND tagxref.tagid=%d" |
| 1137 | " AND tagxref.tagtype>0" |
| 1138 | " AND tagxref.rid=pid ORDER BY isprim ASC", |
| 1139 | TAG_BRANCH); |
| 1140 | |
| 1141 | rid = ridRequested; |
| 1142 | while( rid > 0 ) { |
| 1143 | db_bind_int(&s, ":rid", rid); |
| 1144 | int found = 0; |
| 1145 | while ( db_step(&s) == SQLITE_ROW ) { |
| 1146 | const char *branchNamePid; /* Branch name of the pid */ |
| 1147 | |
| 1148 | ++found; |
| 1149 | rid = db_column_int(&s, 0); |
| 1150 | branchNamePid = db_column_text(&s, 1); |
| 1151 | if ( !branchNamePid ) { |
| 1152 | break; |
| 1153 | } |
| 1154 | if ( fossil_strcmp(parentBranchName, branchNamePid)==0 ) { |
| 1155 | /* Found the last merge from the parent branch */ |
| 1156 | db_finalize(&s); |
| 1157 | return rid; |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | if (found == 0) { |
| 1162 | break; |
| 1163 | } |
| 1164 | db_reset(&s); |
| 1165 | } |
| 1166 | db_finalize(&s); |
| 1167 | |
| 1168 | return 0; |
| 1169 | } |
| 1170 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -182,16 +182,16 @@ | |
| 182 | " ORDER BY mtime DESC LIMIT 1", |
| 183 | &zTag[4], zType); |
| 184 | return rid; |
| 185 | } |
| 186 | |
| 187 | /* "pbranch:", as for parent branch. It returns the checkin of |
| 188 | the last checkin of the parent branch that has been merged in. */ |
| 189 | if( memcmp(zTag, "pbranch:", 8)==0 ){ |
| 190 | rid = symbolic_name_to_rid(&zTag[8], zType); |
| 191 | if( rid==0 ) return 0; /* TODO: Negative rid allowed here? */ |
| 192 | rid = get_parent_branch_rid(rid); |
| 193 | return rid; |
| 194 | } |
| 195 | |
| 196 | /* "tag:" + symbolic-name */ |
| 197 | if( memcmp(zTag, "tag:", 4)==0 ){ |
| @@ -1068,31 +1068,31 @@ | |
| 1068 | void test_phatoms_cmd(void){ |
| 1069 | db_find_and_open_repository(0,0); |
| 1070 | describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); |
| 1071 | } |
| 1072 | |
| 1073 | /* |
| 1074 | ** Returns the rid for the last checkin where the parent branch was merged. |
| 1075 | */ |
| 1076 | int get_parent_branch_rid( |
| 1077 | int branchRid /* The rid to find parent branch for. */ |
| 1078 | ){ |
| 1079 | Stmt s; |
| 1080 | char *branchName = 0; /* Name of the branch at rid */ |
| 1081 | char *parentBranchName = 0; /* Name of the parent branch */ |
| 1082 | int rid; |
| 1083 | |
| 1084 | /* Get the name of the current branch */ |
| 1085 | branchName = db_text(0, |
| 1086 | "SELECT value FROM tagxref" |
| 1087 | " WHERE tagid=%d" |
| 1088 | " AND tagxref.tagtype>0" |
| 1089 | " AND rid=%d", |
| 1090 | TAG_BRANCH, branchRid |
| 1091 | ); |
| 1092 | |
| 1093 | if( !branchName ) |
| 1094 | return 0; |
| 1095 | |
| 1096 | /* Find the name of the branch this was forked from */ |
| 1097 | db_prepare(&s, |
| 1098 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| @@ -1099,25 +1099,25 @@ | |
| 1099 | " WHERE cid=:rid" |
| 1100 | " AND isprim=1" |
| 1101 | " AND tagxref.tagid=%d" |
| 1102 | " AND tagxref.tagtype>0" |
| 1103 | " AND tagxref.rid=pid", |
| 1104 | TAG_BRANCH |
| 1105 | ); |
| 1106 | rid = branchRid; |
| 1107 | while( rid>0 ){ |
| 1108 | db_bind_int(&s, ":rid", rid); |
| 1109 | if( db_step(&s)==SQLITE_ROW ){ |
| 1110 | const char *zValue; /* Branch name of the pid */ |
| 1111 | rid = db_column_int(&s, 0); |
| 1112 | zValue = db_column_text(&s, 1); |
| 1113 | if( !zValue ){ |
| 1114 | rid = 0; |
| 1115 | break; |
| 1116 | } |
| 1117 | if( fossil_strcmp(zValue,branchName) ){ |
| 1118 | parentBranchName = fossil_strdup(zValue); |
| 1119 | break; |
| 1120 | } |
| 1121 | }else{ |
| 1122 | rid = 0; |
| 1123 | break; |
| @@ -1124,46 +1124,51 @@ | |
| 1124 | } |
| 1125 | db_reset(&s); |
| 1126 | } |
| 1127 | db_finalize(&s); |
| 1128 | |
| 1129 | if( rid==0 ){ |
| 1130 | fossil_free(branchName); |
| 1131 | fossil_free(parentBranchName); |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
| 1135 | /* Find the last checkin coming from the parent branch */ |
| 1136 | db_prepare(&s, |
| 1137 | "SELECT pid, tagxref.value FROM plink JOIN tagxref" |
| 1138 | " WHERE cid=:rid" |
| 1139 | " AND tagxref.tagid=%d" |
| 1140 | " AND tagxref.tagtype>0" |
| 1141 | " AND tagxref.rid=pid ORDER BY isprim ASC", |
| 1142 | TAG_BRANCH |
| 1143 | ); |
| 1144 | rid = branchRid; |
| 1145 | while( rid>0 ){ |
| 1146 | db_bind_int(&s, ":rid", rid); |
| 1147 | int found = 0; |
| 1148 | while( db_step(&s)==SQLITE_ROW ){ |
| 1149 | const char *zValue; /* Branch name of the pid */ |
| 1150 | found++; |
| 1151 | rid = db_column_int(&s, 0); |
| 1152 | zValue = db_column_text(&s, 1); |
| 1153 | if( !zValue ){ |
| 1154 | break; |
| 1155 | } |
| 1156 | if( fossil_strcmp(parentBranchName,zValue)==0 ){ |
| 1157 | /* Found the last merge from the parent branch */ |
| 1158 | db_finalize(&s); |
| 1159 | fossil_free(branchName); |
| 1160 | fossil_free(parentBranchName); |
| 1161 | return rid; |
| 1162 | } |
| 1163 | } |
| 1164 | if( found==0 ){ |
| 1165 | break; |
| 1166 | } |
| 1167 | db_reset(&s); |
| 1168 | } |
| 1169 | db_finalize(&s); |
| 1170 | |
| 1171 | fossil_free(branchName); |
| 1172 | fossil_free(parentBranchName); |
| 1173 | return 0; |
| 1174 | } |
| 1175 |