27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# include <io.h>
# include <fcntl.h>
# undef popen
# define popen _popen
# undef pclose
# define pclose _pclose
#endif
/*
** Try to compute the name of the computer on which this process
** is running.
*/
char *fossil_hostname(void){
FILE *in;
char zBuf[200];
in = popen("hostname","r");
if( in ){
size_t n = fread(zBuf, 1, sizeof(zBuf)-1, in);
while( n>0 && fossil_isspace(zBuf[n-1]) ){ n--; }
if( n<0 ) n = 0;
zBuf[n] = 0;
pclose(in);
return fossil_strdup(zBuf);
}
return 0;
}
/*
** Flags passed from the main patch_cmd() routine into subfunctions used
** to implement the various subcommands.
*/
#define PATCH_DRYRUN 0x0001
#define PATCH_VERBOSE 0x0002
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
+
|
/*
** Generate a binary patch file and store it into the file
** named zOut.
*/
void patch_create(const char *zOut, FILE *out){
int vid;
char *z;
if( zOut && file_isdir(zOut, ExtFILE)!=0 ){
fossil_fatal("patch file already exists: %s", zOut);
}
add_content_sql_commands(g.db);
deltafunc_init(g.db);
sqlite3_create_function(g.db, "read_co_file", 1, SQLITE_UTF8, 0,
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
"CREATE TABLE patch.cfg(\n"
" key TEXT,\n"
" value ANY\n"
");"
);
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, CKSIG_ENOTFILE);
user_select();
db_multi_exec(
"INSERT INTO patch.cfg(key,value)"
"SELECT 'baseline',uuid FROM blob WHERE rid=%d", vid);
"SELECT 'baseline',uuid FROM blob WHERE rid=%d "
"UNION ALL"
" SELECT 'ckout',rtrim(%Q,'/')"
"UNION ALL"
" SELECT 'repo',%Q "
"UNION ALL"
" SELECT 'user',%Q "
"UNION ALL"
" SELECT 'date',julianday('now')"
"UNION ALL"
" SELECT 'project-code',value FROM repository.config"
" WHERE name='project-code' "
"UNION ALL"
" SELECT 'fossil-date',julianday('" MANIFEST_DATE "')"
";", vid, g.zLocalRoot, g.zRepositoryName, g.zLogin);
z = fossil_hostname();
if( z ){
db_multi_exec(
"INSERT INTO patch.cfg(key,value)VALUES('hostname',%Q)", z);
fossil_free(z);
}
/* New files */
db_multi_exec(
"INSERT INTO patch.chng(pathname,hash,isexe,islink,delta)"
" SELECT pathname, NULL, isexe, islink,"
" compress(read_co_file(%Q||pathname))"
" FROM vfile WHERE rid==0;",
|