|
1
|
/* |
|
2
|
** Copyright (c) 2014 D. Richard Hipp |
|
3
|
** |
|
4
|
** This program is free software; you can redistribute it and/or |
|
5
|
** modify it under the terms of the Simplified BSD License (also |
|
6
|
** known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
|
|
8
|
** This program is distributed in the hope that it will be useful, |
|
9
|
** but without any warranty; without even the implied warranty of |
|
10
|
** merchantability or fitness for a particular purpose. |
|
11
|
** |
|
12
|
** Author contact information: |
|
13
|
** [email protected] |
|
14
|
** http://www.hwaci.com/drh/ |
|
15
|
** |
|
16
|
******************************************************************************* |
|
17
|
** |
|
18
|
** This file contains code used to implement the "publish" and |
|
19
|
** "unpublished" commands. |
|
20
|
*/ |
|
21
|
#include "config.h" |
|
22
|
#include "publish.h" |
|
23
|
#include <assert.h> |
|
24
|
|
|
25
|
/* |
|
26
|
** COMMAND: unpublished* |
|
27
|
** |
|
28
|
** Usage: %fossil unpublished ?OPTIONS? |
|
29
|
** |
|
30
|
** Show a list of unpublished or "private" artifacts. Unpublished artifacts |
|
31
|
** will never push and hence will not be shared with collaborators. |
|
32
|
** |
|
33
|
** By default, this command only shows unpublished check-ins. To show |
|
34
|
** all unpublished artifacts, use the --all command-line option. |
|
35
|
** |
|
36
|
** Options: |
|
37
|
** --all Show all artifacts, not just check-ins |
|
38
|
*/ |
|
39
|
void unpublished_cmd(void){ |
|
40
|
int bAll = find_option("all",0,0)!=0; |
|
41
|
|
|
42
|
db_find_and_open_repository(0,0); |
|
43
|
verify_all_options(); |
|
44
|
if( bAll ){ |
|
45
|
describe_artifacts_to_stdout("IN private", 0); |
|
46
|
}else{ |
|
47
|
describe_artifacts_to_stdout( |
|
48
|
"IN (SELECT rid FROM private CROSS JOIN event" |
|
49
|
" WHERE private.rid=event.objid" |
|
50
|
" AND event.type='ci')", 0); |
|
51
|
} |
|
52
|
} |
|
53
|
|
|
54
|
/* |
|
55
|
** COMMAND: publish* |
|
56
|
** |
|
57
|
** Usage: %fossil publish ?--only? TAGS... |
|
58
|
** |
|
59
|
** Cause artifacts identified by TAGS... to be published (made non-private). |
|
60
|
** This can be used (for example) to convert a private branch into a public |
|
61
|
** branch, or to publish a bundle that was imported privately. |
|
62
|
** |
|
63
|
** If any of TAGS names a branch, then all check-ins on the most recent |
|
64
|
** instance of that branch are included, not just the most recent check-in. |
|
65
|
** |
|
66
|
** If any of TAGS name check-ins then all files and tags associated with |
|
67
|
** those check-ins are also published automatically. Except if the --only |
|
68
|
** option is used, then only the specific artifacts identified by TAGS |
|
69
|
** are published. |
|
70
|
** |
|
71
|
** If a TAG is already public, this command is a harmless no-op. |
|
72
|
*/ |
|
73
|
void publish_cmd(void){ |
|
74
|
int bOnly = find_option("only",0,0)!=0; |
|
75
|
int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */ |
|
76
|
int bExclusive = find_option("exclusive",0,0)!=0; /* undocumented */ |
|
77
|
int i; |
|
78
|
|
|
79
|
db_find_and_open_repository(0,0); |
|
80
|
verify_all_options(); |
|
81
|
if( g.argc<3 ) usage("?--only? TAGS..."); |
|
82
|
db_begin_transaction(); |
|
83
|
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"); |
|
84
|
for(i=2; i<g.argc; i++){ |
|
85
|
int rid = name_to_rid(g.argv[i]); |
|
86
|
if( db_exists("SELECT 1 FROM tagxref" |
|
87
|
" WHERE rid=%d AND tagid=%d" |
|
88
|
" AND tagtype>0 AND value=%Q", |
|
89
|
rid,TAG_BRANCH,g.argv[i]) ){ |
|
90
|
rid = start_of_branch(rid, 1); |
|
91
|
compute_descendants(rid, 1000000000); |
|
92
|
}else{ |
|
93
|
db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", rid); |
|
94
|
} |
|
95
|
} |
|
96
|
if( !bOnly ){ |
|
97
|
find_checkin_associates("ok", bExclusive); |
|
98
|
} |
|
99
|
if( bTest ){ |
|
100
|
/* If the --test option is used, then do not actually publish any |
|
101
|
** artifacts. Instead, just list the artifact information on standard |
|
102
|
** output. The --test option is useful for verifying correct operation |
|
103
|
** of the logic that figures out which artifacts to publish, such as |
|
104
|
** the find_checkin_associates() routine |
|
105
|
*/ |
|
106
|
describe_artifacts_to_stdout("IN ok", 0); |
|
107
|
}else{ |
|
108
|
/* Standard behavior is simply to remove the published documents from |
|
109
|
** the PRIVATE table */ |
|
110
|
db_multi_exec( |
|
111
|
"DELETE FROM ok WHERE rid NOT IN private;" |
|
112
|
"DELETE FROM private WHERE rid IN ok;" |
|
113
|
"INSERT OR IGNORE INTO unsent SELECT rid FROM ok;" |
|
114
|
"INSERT OR IGNORE INTO unclustered SELECT rid FROM ok;" |
|
115
|
); |
|
116
|
} |
|
117
|
db_end_transaction(0); |
|
118
|
} |
|
119
|
|