Fossil SCM

Use the describe_artifacts utility in the implementation of "fossil unpublished" and "fossil publish".

drh 2014-11-29 00:41 UTC DBP-workflow
Commit 09f67d5cbde349209f68c9e3b7c5f4920c242b64
1 file changed +10 -33
+10 -33
--- src/publish.c
+++ src/publish.c
@@ -33,42 +33,26 @@
3333
** By default, this command only shows unpublished checkins. To show
3434
** all unpublished artifacts, use the --all command-line option.
3535
**
3636
** OPTIONS:
3737
** --all Show all artifacts, not just checkins
38
-** --brief Show just the SHA1 hashes, not details
3938
*/
4039
void unpublished_cmd(void){
4140
int bAll = find_option("all",0,0)!=0;
42
- int bBrief = find_option("brief",0,0)!=0;
4341
const char *zCols;
4442
int n = 0;
45
- Stmt q;
4643
4744
db_find_and_open_repository(0,0);
4845
verify_all_options();
49
- if( bBrief ){
50
- zCols = "(SELECT uuid FROM blob WHERE rid=private.rid)";
51
- }else{
52
- zCols = "private.rid";
53
- }
54
- if( bAll ){
55
- db_prepare(&q, "SELECT %s FROM private", zCols/*safe-for-%s*/);
56
- }else{
57
- db_prepare(&q, "SELECT %s FROM private, event"
46
+ if( bAll ){
47
+ describe_artifacts_to_stdout("IN private", 0);
48
+ }else{
49
+ describe_artifacts_to_stdout(
50
+ "IN (SELECT rid FROM private CROSS JOIN event"
5851
" WHERE private.rid=event.objid"
59
- " AND event.type='ci';", zCols/*safe-for-%s*/);
60
- }
61
- while( db_step(&q)==SQLITE_ROW ){
62
- if( bBrief ){
63
- fossil_print("%s\n", db_column_text(&q,0));
64
- }else{
65
- if( n++ > 0 ) fossil_print("%.78c\n",'-');
66
- whatis_rid(db_column_int(&q,0),0);
67
- }
68
- }
69
- db_finalize(&q);
52
+ " AND event.type='ci')", 0);
53
+ }
7054
}
7155
7256
/*
7357
** COMMAND: publish
7458
**
@@ -117,20 +101,13 @@
117101
if( bTest ){
118102
/* If the --test option is used, then do not actually publish any
119103
** artifacts. Instead, just list the artifact information on standard
120104
** output. The --test option is useful for verifying correct operation
121105
** of the logic that figures out which artifacts to publish, such as
122
- ** the find_checkin_associates() routine */
123
- Stmt q;
124
- int i = 0;
125
- db_prepare(&q, "SELECT rid FROM ok");
126
- while( db_step(&q)==SQLITE_ROW ){
127
- int rid = db_column_int(&q,0);
128
- if( i++ > 0 ) fossil_print("%.78c\n", '-');
129
- whatis_rid(rid, 0);
130
- }
131
- db_finalize(&q);
106
+ ** the find_checkin_associates() routine
107
+ */
108
+ describe_artifacts_to_stdout("IN ok", 0);
132109
}else{
133110
/* Standard behavior is simply to remove the published documents from
134111
** the PRIVATE table */
135112
db_multi_exec(
136113
"DELETE FROM ok WHERE rid NOT IN private;"
137114
--- src/publish.c
+++ src/publish.c
@@ -33,42 +33,26 @@
33 ** By default, this command only shows unpublished checkins. To show
34 ** all unpublished artifacts, use the --all command-line option.
35 **
36 ** OPTIONS:
37 ** --all Show all artifacts, not just checkins
38 ** --brief Show just the SHA1 hashes, not details
39 */
40 void unpublished_cmd(void){
41 int bAll = find_option("all",0,0)!=0;
42 int bBrief = find_option("brief",0,0)!=0;
43 const char *zCols;
44 int n = 0;
45 Stmt q;
46
47 db_find_and_open_repository(0,0);
48 verify_all_options();
49 if( bBrief ){
50 zCols = "(SELECT uuid FROM blob WHERE rid=private.rid)";
51 }else{
52 zCols = "private.rid";
53 }
54 if( bAll ){
55 db_prepare(&q, "SELECT %s FROM private", zCols/*safe-for-%s*/);
56 }else{
57 db_prepare(&q, "SELECT %s FROM private, event"
58 " WHERE private.rid=event.objid"
59 " AND event.type='ci';", zCols/*safe-for-%s*/);
60 }
61 while( db_step(&q)==SQLITE_ROW ){
62 if( bBrief ){
63 fossil_print("%s\n", db_column_text(&q,0));
64 }else{
65 if( n++ > 0 ) fossil_print("%.78c\n",'-');
66 whatis_rid(db_column_int(&q,0),0);
67 }
68 }
69 db_finalize(&q);
70 }
71
72 /*
73 ** COMMAND: publish
74 **
@@ -117,20 +101,13 @@
117 if( bTest ){
118 /* If the --test option is used, then do not actually publish any
119 ** artifacts. Instead, just list the artifact information on standard
120 ** output. The --test option is useful for verifying correct operation
121 ** of the logic that figures out which artifacts to publish, such as
122 ** the find_checkin_associates() routine */
123 Stmt q;
124 int i = 0;
125 db_prepare(&q, "SELECT rid FROM ok");
126 while( db_step(&q)==SQLITE_ROW ){
127 int rid = db_column_int(&q,0);
128 if( i++ > 0 ) fossil_print("%.78c\n", '-');
129 whatis_rid(rid, 0);
130 }
131 db_finalize(&q);
132 }else{
133 /* Standard behavior is simply to remove the published documents from
134 ** the PRIVATE table */
135 db_multi_exec(
136 "DELETE FROM ok WHERE rid NOT IN private;"
137
--- src/publish.c
+++ src/publish.c
@@ -33,42 +33,26 @@
33 ** By default, this command only shows unpublished checkins. To show
34 ** all unpublished artifacts, use the --all command-line option.
35 **
36 ** OPTIONS:
37 ** --all Show all artifacts, not just checkins
 
38 */
39 void unpublished_cmd(void){
40 int bAll = find_option("all",0,0)!=0;
 
41 const char *zCols;
42 int n = 0;
 
43
44 db_find_and_open_repository(0,0);
45 verify_all_options();
46 if( bAll ){
47 describe_artifacts_to_stdout("IN private", 0);
48 }else{
49 describe_artifacts_to_stdout(
50 "IN (SELECT rid FROM private CROSS JOIN event"
 
 
 
 
51 " WHERE private.rid=event.objid"
52 " AND event.type='ci')", 0);
53 }
 
 
 
 
 
 
 
 
 
54 }
55
56 /*
57 ** COMMAND: publish
58 **
@@ -117,20 +101,13 @@
101 if( bTest ){
102 /* If the --test option is used, then do not actually publish any
103 ** artifacts. Instead, just list the artifact information on standard
104 ** output. The --test option is useful for verifying correct operation
105 ** of the logic that figures out which artifacts to publish, such as
106 ** the find_checkin_associates() routine
107 */
108 describe_artifacts_to_stdout("IN ok", 0);
 
 
 
 
 
 
 
109 }else{
110 /* Standard behavior is simply to remove the published documents from
111 ** the PRIVATE table */
112 db_multi_exec(
113 "DELETE FROM ok WHERE rid NOT IN private;"
114

Keyboard Shortcuts

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