Fossil SCM
Avoid parsing manifests if a parent exists. Now the only case left using deleteall is when no parent exists.
Commit
bc8d368b66053450c7f323b4e479fb5b4a878684
Parent
433a3c9a7826e55…
1 file changed
+38
-23
+38
-23
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -139,20 +139,17 @@ | ||
| 139 | 139 | " WHERE type='ci'" |
| 140 | 140 | " ORDER BY mtime ASC", |
| 141 | 141 | TAG_BRANCH |
| 142 | 142 | ); |
| 143 | 143 | while( db_step(&q)==SQLITE_ROW ){ |
| 144 | + Stmt q2; | |
| 144 | 145 | const char *zSecondsSince1970 = db_column_text(&q, 0); |
| 145 | 146 | int ckinId = db_column_int(&q, 1); |
| 146 | 147 | const char *zComment = db_column_text(&q, 2); |
| 147 | 148 | const char *zUser = db_column_text(&q, 3); |
| 148 | 149 | const char *zBranch = db_column_text(&q, 4); |
| 149 | 150 | char *zBr; |
| 150 | - Manifest *p; | |
| 151 | - ManifestFile *pFile; | |
| 152 | - const char *zFromType; | |
| 153 | - int parent; | |
| 154 | 151 | |
| 155 | 152 | bag_insert(&vers, ckinId); |
| 156 | 153 | if( zBranch==0 ) zBranch = "trunk"; |
| 157 | 154 | zBr = mprintf("%s", zBranch); |
| 158 | 155 | for(i=0; zBr[i]; i++){ |
| @@ -163,21 +160,24 @@ | ||
| 163 | 160 | printf("committer"); |
| 164 | 161 | print_person(zUser); |
| 165 | 162 | printf(" %s +0000\n", zSecondsSince1970); |
| 166 | 163 | if( zComment==0 ) zComment = "null comment"; |
| 167 | 164 | printf("data %d\n%s\n", (int)strlen(zComment), zComment); |
| 168 | - p = manifest_get(ckinId, CFTYPE_ANY); | |
| 169 | - zFromType = "from"; | |
| 170 | - parent = 0; | |
| 171 | - for(i=0; i<p->nParent; i++){ | |
| 172 | - int pid = fast_uuid_to_rid(p->azParent[i]); | |
| 173 | - if( pid==0 || !bag_find(&vers, pid) ) continue; | |
| 174 | - if( i==0) parent = pid; | |
| 175 | - printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); | |
| 176 | - zFromType = "merge"; | |
| 177 | - } | |
| 178 | - if( parent==0 ) { | |
| 165 | + db_prepare(&q2, "SELECT pid FROM plink WHERE cid=%d AND isprim", ckinId); | |
| 166 | + if( db_step(&q2) != SQLITE_ROW ){ | |
| 167 | + const char *zFromType; | |
| 168 | + Manifest *p; | |
| 169 | + ManifestFile *pFile; | |
| 170 | + | |
| 171 | + zFromType = "from"; | |
| 172 | + p = manifest_get(ckinId, CFTYPE_ANY); | |
| 173 | + for(i=0; i<p->nParent; i++){ | |
| 174 | + int pid = fast_uuid_to_rid(p->azParent[i]); | |
| 175 | + if( pid==0 || !bag_find(&vers, pid) ) continue; | |
| 176 | + printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); | |
| 177 | + zFromType = "merge"; | |
| 178 | + } | |
| 179 | 179 | printf("deleteall\n"); |
| 180 | 180 | manifest_file_rewind(p); |
| 181 | 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| 182 | 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | 183 | const char *zPerm = "100644"; |
| @@ -184,30 +184,45 @@ | ||
| 184 | 184 | if( fid==0 ) continue; |
| 185 | 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | 187 | printf("M %s :%d %s\n", zPerm, fid, pFile->zName); |
| 188 | 188 | } |
| 189 | + manifest_cache_insert(p); | |
| 189 | 190 | }else{ |
| 190 | - Stmt q2; | |
| 191 | - db_prepare(&q2, | |
| 191 | + Stmt q3; | |
| 192 | + int parent; | |
| 193 | + | |
| 194 | + parent = db_column_int(&q2, 0); | |
| 195 | + printf("from :%d\n", parent+firstCkin); | |
| 196 | + db_prepare(&q3, | |
| 197 | + "SELECT pid FROM plink" | |
| 198 | + " WHERE cid=%d AND NOT isprim" | |
| 199 | + " ORDER BY pid", | |
| 200 | + ckinId); | |
| 201 | + while( db_step(&q3)==SQLITE_ROW ){ | |
| 202 | + printf("merge :%d\n", db_column_int(&q3,0)+firstCkin); | |
| 203 | + } | |
| 204 | + db_finalize(&q3); | |
| 205 | + | |
| 206 | + db_prepare(&q3, | |
| 192 | 207 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| 193 | 208 | " JOIN filename ON filename.fnid=mlink.fnid" |
| 194 | 209 | " WHERE mlink.mid=%d", |
| 195 | 210 | parent |
| 196 | 211 | ); |
| 197 | - while( db_step(&q2)==SQLITE_ROW ){ | |
| 198 | - const char *zName = db_column_text(&q2,0); | |
| 199 | - int zNew = db_column_int(&q2,1); | |
| 200 | - int mPerm = db_column_int(&q2,2); | |
| 212 | + while( db_step(&q3)==SQLITE_ROW ){ | |
| 213 | + const char *zName = db_column_text(&q3,0); | |
| 214 | + int zNew = db_column_int(&q3,1); | |
| 215 | + int mPerm = db_column_int(&q3,2); | |
| 201 | 216 | if( zNew==0) |
| 202 | 217 | printf("D %s\n", zName); |
| 203 | 218 | else |
| 204 | 219 | printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName); |
| 205 | 220 | } |
| 206 | - db_finalize(&q2); | |
| 221 | + db_finalize(&q3); | |
| 207 | 222 | } |
| 208 | - manifest_cache_insert(p); | |
| 223 | + db_finalize(&q2); | |
| 209 | 224 | printf("\n"); |
| 210 | 225 | } |
| 211 | 226 | db_finalize(&q); |
| 212 | 227 | bag_clear(&blobs); |
| 213 | 228 | manifest_cache_clear(); |
| 214 | 229 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -139,20 +139,17 @@ | |
| 139 | " WHERE type='ci'" |
| 140 | " ORDER BY mtime ASC", |
| 141 | TAG_BRANCH |
| 142 | ); |
| 143 | while( db_step(&q)==SQLITE_ROW ){ |
| 144 | const char *zSecondsSince1970 = db_column_text(&q, 0); |
| 145 | int ckinId = db_column_int(&q, 1); |
| 146 | const char *zComment = db_column_text(&q, 2); |
| 147 | const char *zUser = db_column_text(&q, 3); |
| 148 | const char *zBranch = db_column_text(&q, 4); |
| 149 | char *zBr; |
| 150 | Manifest *p; |
| 151 | ManifestFile *pFile; |
| 152 | const char *zFromType; |
| 153 | int parent; |
| 154 | |
| 155 | bag_insert(&vers, ckinId); |
| 156 | if( zBranch==0 ) zBranch = "trunk"; |
| 157 | zBr = mprintf("%s", zBranch); |
| 158 | for(i=0; zBr[i]; i++){ |
| @@ -163,21 +160,24 @@ | |
| 163 | printf("committer"); |
| 164 | print_person(zUser); |
| 165 | printf(" %s +0000\n", zSecondsSince1970); |
| 166 | if( zComment==0 ) zComment = "null comment"; |
| 167 | printf("data %d\n%s\n", (int)strlen(zComment), zComment); |
| 168 | p = manifest_get(ckinId, CFTYPE_ANY); |
| 169 | zFromType = "from"; |
| 170 | parent = 0; |
| 171 | for(i=0; i<p->nParent; i++){ |
| 172 | int pid = fast_uuid_to_rid(p->azParent[i]); |
| 173 | if( pid==0 || !bag_find(&vers, pid) ) continue; |
| 174 | if( i==0) parent = pid; |
| 175 | printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); |
| 176 | zFromType = "merge"; |
| 177 | } |
| 178 | if( parent==0 ) { |
| 179 | printf("deleteall\n"); |
| 180 | manifest_file_rewind(p); |
| 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | const char *zPerm = "100644"; |
| @@ -184,30 +184,45 @@ | |
| 184 | if( fid==0 ) continue; |
| 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | printf("M %s :%d %s\n", zPerm, fid, pFile->zName); |
| 188 | } |
| 189 | }else{ |
| 190 | Stmt q2; |
| 191 | db_prepare(&q2, |
| 192 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| 193 | " JOIN filename ON filename.fnid=mlink.fnid" |
| 194 | " WHERE mlink.mid=%d", |
| 195 | parent |
| 196 | ); |
| 197 | while( db_step(&q2)==SQLITE_ROW ){ |
| 198 | const char *zName = db_column_text(&q2,0); |
| 199 | int zNew = db_column_int(&q2,1); |
| 200 | int mPerm = db_column_int(&q2,2); |
| 201 | if( zNew==0) |
| 202 | printf("D %s\n", zName); |
| 203 | else |
| 204 | printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName); |
| 205 | } |
| 206 | db_finalize(&q2); |
| 207 | } |
| 208 | manifest_cache_insert(p); |
| 209 | printf("\n"); |
| 210 | } |
| 211 | db_finalize(&q); |
| 212 | bag_clear(&blobs); |
| 213 | manifest_cache_clear(); |
| 214 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -139,20 +139,17 @@ | |
| 139 | " WHERE type='ci'" |
| 140 | " ORDER BY mtime ASC", |
| 141 | TAG_BRANCH |
| 142 | ); |
| 143 | while( db_step(&q)==SQLITE_ROW ){ |
| 144 | Stmt q2; |
| 145 | const char *zSecondsSince1970 = db_column_text(&q, 0); |
| 146 | int ckinId = db_column_int(&q, 1); |
| 147 | const char *zComment = db_column_text(&q, 2); |
| 148 | const char *zUser = db_column_text(&q, 3); |
| 149 | const char *zBranch = db_column_text(&q, 4); |
| 150 | char *zBr; |
| 151 | |
| 152 | bag_insert(&vers, ckinId); |
| 153 | if( zBranch==0 ) zBranch = "trunk"; |
| 154 | zBr = mprintf("%s", zBranch); |
| 155 | for(i=0; zBr[i]; i++){ |
| @@ -163,21 +160,24 @@ | |
| 160 | printf("committer"); |
| 161 | print_person(zUser); |
| 162 | printf(" %s +0000\n", zSecondsSince1970); |
| 163 | if( zComment==0 ) zComment = "null comment"; |
| 164 | printf("data %d\n%s\n", (int)strlen(zComment), zComment); |
| 165 | db_prepare(&q2, "SELECT pid FROM plink WHERE cid=%d AND isprim", ckinId); |
| 166 | if( db_step(&q2) != SQLITE_ROW ){ |
| 167 | const char *zFromType; |
| 168 | Manifest *p; |
| 169 | ManifestFile *pFile; |
| 170 | |
| 171 | zFromType = "from"; |
| 172 | p = manifest_get(ckinId, CFTYPE_ANY); |
| 173 | for(i=0; i<p->nParent; i++){ |
| 174 | int pid = fast_uuid_to_rid(p->azParent[i]); |
| 175 | if( pid==0 || !bag_find(&vers, pid) ) continue; |
| 176 | printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); |
| 177 | zFromType = "merge"; |
| 178 | } |
| 179 | printf("deleteall\n"); |
| 180 | manifest_file_rewind(p); |
| 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | const char *zPerm = "100644"; |
| @@ -184,30 +184,45 @@ | |
| 184 | if( fid==0 ) continue; |
| 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | printf("M %s :%d %s\n", zPerm, fid, pFile->zName); |
| 188 | } |
| 189 | manifest_cache_insert(p); |
| 190 | }else{ |
| 191 | Stmt q3; |
| 192 | int parent; |
| 193 | |
| 194 | parent = db_column_int(&q2, 0); |
| 195 | printf("from :%d\n", parent+firstCkin); |
| 196 | db_prepare(&q3, |
| 197 | "SELECT pid FROM plink" |
| 198 | " WHERE cid=%d AND NOT isprim" |
| 199 | " ORDER BY pid", |
| 200 | ckinId); |
| 201 | while( db_step(&q3)==SQLITE_ROW ){ |
| 202 | printf("merge :%d\n", db_column_int(&q3,0)+firstCkin); |
| 203 | } |
| 204 | db_finalize(&q3); |
| 205 | |
| 206 | db_prepare(&q3, |
| 207 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| 208 | " JOIN filename ON filename.fnid=mlink.fnid" |
| 209 | " WHERE mlink.mid=%d", |
| 210 | parent |
| 211 | ); |
| 212 | while( db_step(&q3)==SQLITE_ROW ){ |
| 213 | const char *zName = db_column_text(&q3,0); |
| 214 | int zNew = db_column_int(&q3,1); |
| 215 | int mPerm = db_column_int(&q3,2); |
| 216 | if( zNew==0) |
| 217 | printf("D %s\n", zName); |
| 218 | else |
| 219 | printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName); |
| 220 | } |
| 221 | db_finalize(&q3); |
| 222 | } |
| 223 | db_finalize(&q2); |
| 224 | printf("\n"); |
| 225 | } |
| 226 | db_finalize(&q); |
| 227 | bag_clear(&blobs); |
| 228 | manifest_cache_clear(); |
| 229 |