Fossil SCM

Begin making use of the new describe_artifacts() utility, for example in the --explain output of "bundle export" and "purge".

drh 2014-11-28 23:18 UTC DBP-workflow
Commit e957dc662bc549f13eebbade1276a6057b05b00d
3 files changed +7 -15 +17 -11 +1 -7
+7 -15
--- src/bundle.c
+++ src/bundle.c
@@ -214,31 +214,23 @@
214214
** Options:
215215
** --branch BRANCH Include only checkins on BRANCH
216216
** --from TAG Start the subtree at TAG
217217
** --to TAG End the subtree at TAG
218218
** --checkin TAG The subtree is the single checkin TAG
219
+** --all Include FILE and TAG artifacts
220
+** --exclusive Include FILES exclusively on checkins
219221
*/
220222
void test_subtree_cmd(void){
221
- Stmt q;
223
+ int bAll = find_option("all",0,0)!=0;
224
+ int bExcl = find_option("exclusive",0,0)!=0;
222225
db_find_and_open_repository(0,0);
223226
db_begin_transaction();
224227
db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
225228
subtree_from_arguments("tobundle");
226
- db_prepare(&q,
227
- "SELECT "
228
- " (SELECT substr(uuid,1,10) FROM blob WHERE rid=tobundle.rid),"
229
- " (SELECT substr(comment,1,30) FROM event WHERE objid=tobundle.rid),"
230
- " tobundle.rid"
231
- " FROM tobundle;"
232
- );
233
- while( db_step(&q)==SQLITE_ROW ){
234
- fossil_print("%5d %s %s\n",
235
- db_column_int(&q, 2),
236
- db_column_text(&q, 0),
237
- db_column_text(&q, 1));
238
- }
239
- db_finalize(&q);
229
+ verify_all_options();
230
+ if( bAll ) find_checkin_associates("tobundle",bExcl);
231
+ describe_artifacts_to_stdout("IN tobundle");
240232
db_end_transaction(1);
241233
}
242234
243235
/* fossil bundle export BUNDLE ?OPTIONS?
244236
**
245237
--- src/bundle.c
+++ src/bundle.c
@@ -214,31 +214,23 @@
214 ** Options:
215 ** --branch BRANCH Include only checkins on BRANCH
216 ** --from TAG Start the subtree at TAG
217 ** --to TAG End the subtree at TAG
218 ** --checkin TAG The subtree is the single checkin TAG
 
 
219 */
220 void test_subtree_cmd(void){
221 Stmt q;
 
222 db_find_and_open_repository(0,0);
223 db_begin_transaction();
224 db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
225 subtree_from_arguments("tobundle");
226 db_prepare(&q,
227 "SELECT "
228 " (SELECT substr(uuid,1,10) FROM blob WHERE rid=tobundle.rid),"
229 " (SELECT substr(comment,1,30) FROM event WHERE objid=tobundle.rid),"
230 " tobundle.rid"
231 " FROM tobundle;"
232 );
233 while( db_step(&q)==SQLITE_ROW ){
234 fossil_print("%5d %s %s\n",
235 db_column_int(&q, 2),
236 db_column_text(&q, 0),
237 db_column_text(&q, 1));
238 }
239 db_finalize(&q);
240 db_end_transaction(1);
241 }
242
243 /* fossil bundle export BUNDLE ?OPTIONS?
244 **
245
--- src/bundle.c
+++ src/bundle.c
@@ -214,31 +214,23 @@
214 ** Options:
215 ** --branch BRANCH Include only checkins on BRANCH
216 ** --from TAG Start the subtree at TAG
217 ** --to TAG End the subtree at TAG
218 ** --checkin TAG The subtree is the single checkin TAG
219 ** --all Include FILE and TAG artifacts
220 ** --exclusive Include FILES exclusively on checkins
221 */
222 void test_subtree_cmd(void){
223 int bAll = find_option("all",0,0)!=0;
224 int bExcl = find_option("exclusive",0,0)!=0;
225 db_find_and_open_repository(0,0);
226 db_begin_transaction();
227 db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
228 subtree_from_arguments("tobundle");
229 verify_all_options();
230 if( bAll ) find_checkin_associates("tobundle",bExcl);
231 describe_artifacts_to_stdout("IN tobundle");
 
 
 
 
 
 
 
 
 
 
 
232 db_end_transaction(1);
233 }
234
235 /* fossil bundle export BUNDLE ?OPTIONS?
236 **
237
+17 -11
--- src/name.c
+++ src/name.c
@@ -908,20 +908,15 @@
908908
zWhere /*safe-for-%s*/
909909
);
910910
}
911911
912912
/*
913
-** COMMAND: test-describe-artifacts
914
-**
915
-** Usage: %fossil test-describe-artifacts
916
-**
917
-** Display a one-line description of every artifact.
913
+** Print the content of the description table on stdout
918914
*/
919
-void test_describe_artifacts_cmd(void){
915
+void describe_artifacts_to_stdout(const char *zWhere){
920916
Stmt q;
921
- db_find_and_open_repository(0,0);
922
- describe_artifacts("IN (SELECT rid FROM blob)");
917
+ describe_artifacts(zWhere);
923918
db_prepare(&q,
924919
"SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
925920
" FROM description\n"
926921
" ORDER BY rid;"
927922
);
@@ -931,15 +926,26 @@
931926
db_column_text(&q,1), db_column_text(&q,3));
932927
if( db_column_bytes(&q,4)>0 ){
933928
fossil_print(" %s", db_column_text(&q,4));
934929
}
935930
if( db_column_bytes(&q,2)>0
936
- && fossil_strcmp(zType,"file")!=0
937
- && fossil_strcmp(zType,"ticket")!=0
938
- && fossil_strcmp(zType,"event")!=0
931
+ && fossil_strcmp(zType,"checkin")==0
939932
){
940933
fossil_print(" %s", db_column_text(&q,2));
941934
}
942935
fossil_print("\n");
943936
}
944937
db_finalize(&q);
938
+
939
+}
940
+
941
+/*
942
+** COMMAND: test-describe-artifacts
943
+**
944
+** Usage: %fossil test-describe-artifacts
945
+**
946
+** Display a one-line description of every artifact.
947
+*/
948
+void test_describe_artifacts_cmd(void){
949
+ db_find_and_open_repository(0,0);
950
+ describe_artifacts_to_stdout("IN (SELECT rid FROM blob)");
945951
}
946952
--- src/name.c
+++ src/name.c
@@ -908,20 +908,15 @@
908 zWhere /*safe-for-%s*/
909 );
910 }
911
912 /*
913 ** COMMAND: test-describe-artifacts
914 **
915 ** Usage: %fossil test-describe-artifacts
916 **
917 ** Display a one-line description of every artifact.
918 */
919 void test_describe_artifacts_cmd(void){
920 Stmt q;
921 db_find_and_open_repository(0,0);
922 describe_artifacts("IN (SELECT rid FROM blob)");
923 db_prepare(&q,
924 "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
925 " FROM description\n"
926 " ORDER BY rid;"
927 );
@@ -931,15 +926,26 @@
931 db_column_text(&q,1), db_column_text(&q,3));
932 if( db_column_bytes(&q,4)>0 ){
933 fossil_print(" %s", db_column_text(&q,4));
934 }
935 if( db_column_bytes(&q,2)>0
936 && fossil_strcmp(zType,"file")!=0
937 && fossil_strcmp(zType,"ticket")!=0
938 && fossil_strcmp(zType,"event")!=0
939 ){
940 fossil_print(" %s", db_column_text(&q,2));
941 }
942 fossil_print("\n");
943 }
944 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
 
 
 
945 }
946
--- src/name.c
+++ src/name.c
@@ -908,20 +908,15 @@
908 zWhere /*safe-for-%s*/
909 );
910 }
911
912 /*
913 ** Print the content of the description table on stdout
 
 
 
 
914 */
915 void describe_artifacts_to_stdout(const char *zWhere){
916 Stmt q;
917 describe_artifacts(zWhere);
 
918 db_prepare(&q,
919 "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
920 " FROM description\n"
921 " ORDER BY rid;"
922 );
@@ -931,15 +926,26 @@
926 db_column_text(&q,1), db_column_text(&q,3));
927 if( db_column_bytes(&q,4)>0 ){
928 fossil_print(" %s", db_column_text(&q,4));
929 }
930 if( db_column_bytes(&q,2)>0
931 && fossil_strcmp(zType,"checkin")==0
 
 
932 ){
933 fossil_print(" %s", db_column_text(&q,2));
934 }
935 fossil_print("\n");
936 }
937 db_finalize(&q);
938
939 }
940
941 /*
942 ** COMMAND: test-describe-artifacts
943 **
944 ** Usage: %fossil test-describe-artifacts
945 **
946 ** Display a one-line description of every artifact.
947 */
948 void test_describe_artifacts_cmd(void){
949 db_find_and_open_repository(0,0);
950 describe_artifacts_to_stdout("IN (SELECT rid FROM blob)");
951 }
952
+1 -7
--- src/purge.c
+++ src/purge.c
@@ -567,17 +567,11 @@
567567
}
568568
nCkin = db_int(0, "SELECT count(*) FROM ok");
569569
find_checkin_associates("ok", 1);
570570
nArtifact = db_int(0, "SELECT count(*) FROM ok");
571571
if( explainOnly ){
572
- i = 0;
573
- db_prepare(&q, "SELECT rid FROM ok");
574
- while( db_step(&q)==SQLITE_ROW ){
575
- if( i++ > 0 ) fossil_print("%.78c\n",'-');
576
- whatis_rid(db_column_int(&q,0), 0);
577
- }
578
- db_finalize(&q);
572
+ describe_artifacts_to_stdout("IN ok");
579573
}else{
580574
int peid = purge_artifact_list("ok","",1);
581575
fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
582576
fossil_print("undoable using \"%s purge undo %d\".\n",
583577
g.nameOfExe, peid);
584578
--- src/purge.c
+++ src/purge.c
@@ -567,17 +567,11 @@
567 }
568 nCkin = db_int(0, "SELECT count(*) FROM ok");
569 find_checkin_associates("ok", 1);
570 nArtifact = db_int(0, "SELECT count(*) FROM ok");
571 if( explainOnly ){
572 i = 0;
573 db_prepare(&q, "SELECT rid FROM ok");
574 while( db_step(&q)==SQLITE_ROW ){
575 if( i++ > 0 ) fossil_print("%.78c\n",'-');
576 whatis_rid(db_column_int(&q,0), 0);
577 }
578 db_finalize(&q);
579 }else{
580 int peid = purge_artifact_list("ok","",1);
581 fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
582 fossil_print("undoable using \"%s purge undo %d\".\n",
583 g.nameOfExe, peid);
584
--- src/purge.c
+++ src/purge.c
@@ -567,17 +567,11 @@
567 }
568 nCkin = db_int(0, "SELECT count(*) FROM ok");
569 find_checkin_associates("ok", 1);
570 nArtifact = db_int(0, "SELECT count(*) FROM ok");
571 if( explainOnly ){
572 describe_artifacts_to_stdout("IN ok");
 
 
 
 
 
 
573 }else{
574 int peid = purge_artifact_list("ok","",1);
575 fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
576 fossil_print("undoable using \"%s purge undo %d\".\n",
577 g.nameOfExe, peid);
578

Keyboard Shortcuts

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