Fossil SCM

Fix compiler warning. Coding style adjustments. Rename new link to 'branch diff' for now. Still needs tests.

mistachkin 2015-02-10 03:05 viric_pbranch
Commit 1982a8ce0720b19ea921b780ff8c0d891048d333
2 files changed +1 -1 +43 -38
+1 -1
--- src/info.c
+++ src/info.c
@@ -675,11 +675,11 @@
675675
@ %z(href("%R/tree?ci=%S",zUuid))files</a>
676676
@ | %z(href("%R/fileage?name=%S",zUuid))file ages</a>
677677
@ | %z(href("%R/tree?nofiles&type=tree&ci=%S",zUuid))folders</a>
678678
@ | %z(href("%R/artifact/%S",zUuid))manifest</a>
679679
@ | %z(href("%R/vdiff?from=pbranch:%S&to=%S",zUuid,zUuid))
680
- @ branch changes</a>
680
+ @ branch diff</a>
681681
if( g.perm.Write ){
682682
@ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a>
683683
}
684684
@ </td>
685685
@ </tr>
686686
--- 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 @@
182182
" ORDER BY mtime DESC LIMIT 1",
183183
&zTag[4], zType);
184184
return rid;
185185
}
186186
187
- /* "parent:", as for parent branch. It returns the checkin of
187
+ /* "pbranch:", as for parent branch. It returns the checkin of
188188
the last checkin of the parent branch that has been merged in. */
189189
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);
193193
return rid;
194194
}
195195
196196
/* "tag:" + symbolic-name */
197197
if( memcmp(zTag, "tag:", 4)==0 ){
@@ -1068,31 +1068,31 @@
10681068
void test_phatoms_cmd(void){
10691069
db_find_and_open_repository(0,0);
10701070
describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
10711071
}
10721072
1073
-
1074
-
10751073
/*
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.
10781075
*/
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
+){
10801079
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 */
10831082
int rid;
10841083
10851084
/* Get the name of the current branch */
10861085
branchName = db_text(0,
10871086
"SELECT value FROM tagxref"
10881087
" WHERE tagid=%d"
10891088
" AND tagxref.tagtype>0"
10901089
" AND rid=%d",
1091
- TAG_BRANCH, ridRequested);
1090
+ TAG_BRANCH, branchRid
1091
+ );
10921092
1093
- if ( !branchName )
1093
+ if( !branchName )
10941094
return 0;
10951095
10961096
/* Find the name of the branch this was forked from */
10971097
db_prepare(&s,
10981098
"SELECT pid, tagxref.value FROM plink JOIN tagxref"
@@ -1099,25 +1099,25 @@
10991099
" WHERE cid=:rid"
11001100
" AND isprim=1"
11011101
" AND tagxref.tagid=%d"
11021102
" AND tagxref.tagtype>0"
11031103
" 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 ){
11081108
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 */
11101111
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 ){
11131114
rid = 0;
11141115
break;
11151116
}
1116
-
1117
- if ( fossil_strcmp(parentBranchName, branchName) ) {
1118
- parentBranchName = fossil_strdup(parentBranchName);
1117
+ if( fossil_strcmp(zValue,branchName) ){
1118
+ parentBranchName = fossil_strdup(zValue);
11191119
break;
11201120
}
11211121
}else{
11221122
rid = 0;
11231123
break;
@@ -1124,46 +1124,51 @@
11241124
}
11251125
db_reset(&s);
11261126
}
11271127
db_finalize(&s);
11281128
1129
- if (rid == 0)
1130
- return 0;
1129
+ if( rid==0 ){
1130
+ fossil_free(branchName);
1131
+ fossil_free(parentBranchName);
1132
+ return 0;
1133
+ }
11311134
11321135
/* Find the last checkin coming from the parent branch */
11331136
db_prepare(&s,
11341137
"SELECT pid, tagxref.value FROM plink JOIN tagxref"
11351138
" WHERE cid=:rid"
11361139
" AND tagxref.tagid=%d"
11371140
" AND tagxref.tagtype>0"
11381141
" 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 ){
11431146
db_bind_int(&s, ":rid", rid);
11441147
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++;
11491151
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 ){
11521154
break;
11531155
}
1154
- if ( fossil_strcmp(parentBranchName, branchNamePid)==0 ) {
1156
+ if( fossil_strcmp(parentBranchName,zValue)==0 ){
11551157
/* Found the last merge from the parent branch */
11561158
db_finalize(&s);
1159
+ fossil_free(branchName);
1160
+ fossil_free(parentBranchName);
11571161
return rid;
11581162
}
11591163
}
1160
-
1161
- if (found == 0) {
1164
+ if( found==0 ){
11621165
break;
11631166
}
11641167
db_reset(&s);
11651168
}
11661169
db_finalize(&s);
11671170
1171
+ fossil_free(branchName);
1172
+ fossil_free(parentBranchName);
11681173
return 0;
11691174
}
11701175
--- 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

Keyboard Shortcuts

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