Fossil SCM
Use the describe_artifacts utility in the implementation of "fossil unpublished" and "fossil publish".
Commit
09f67d5cbde349209f68c9e3b7c5f4920c242b64
Parent
79ce83dc90ffcdd…
1 file changed
+10
-33
+10
-33
| --- src/publish.c | ||
| +++ src/publish.c | ||
| @@ -33,42 +33,26 @@ | ||
| 33 | 33 | ** By default, this command only shows unpublished checkins. To show |
| 34 | 34 | ** all unpublished artifacts, use the --all command-line option. |
| 35 | 35 | ** |
| 36 | 36 | ** OPTIONS: |
| 37 | 37 | ** --all Show all artifacts, not just checkins |
| 38 | -** --brief Show just the SHA1 hashes, not details | |
| 39 | 38 | */ |
| 40 | 39 | void unpublished_cmd(void){ |
| 41 | 40 | int bAll = find_option("all",0,0)!=0; |
| 42 | - int bBrief = find_option("brief",0,0)!=0; | |
| 43 | 41 | const char *zCols; |
| 44 | 42 | int n = 0; |
| 45 | - Stmt q; | |
| 46 | 43 | |
| 47 | 44 | db_find_and_open_repository(0,0); |
| 48 | 45 | 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" | |
| 58 | 51 | " 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 | + } | |
| 70 | 54 | } |
| 71 | 55 | |
| 72 | 56 | /* |
| 73 | 57 | ** COMMAND: publish |
| 74 | 58 | ** |
| @@ -117,20 +101,13 @@ | ||
| 117 | 101 | if( bTest ){ |
| 118 | 102 | /* If the --test option is used, then do not actually publish any |
| 119 | 103 | ** artifacts. Instead, just list the artifact information on standard |
| 120 | 104 | ** output. The --test option is useful for verifying correct operation |
| 121 | 105 | ** 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); | |
| 132 | 109 | }else{ |
| 133 | 110 | /* Standard behavior is simply to remove the published documents from |
| 134 | 111 | ** the PRIVATE table */ |
| 135 | 112 | db_multi_exec( |
| 136 | 113 | "DELETE FROM ok WHERE rid NOT IN private;" |
| 137 | 114 |
| --- 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 |