Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch windows-i18n Excluding Merge-Ins
This is equivalent to a diff from 5267731a85 to a742d12e8f
2011-05-20
| ||
11:32 | Merge the windows-i18n branch into the trunk. check-in: d8ec765fac user: drh tags: trunk | |
11:24 | Merge all the latest trunk changes into the windows-i18n branch. Closed-Leaf check-in: a742d12e8f user: drh tags: windows-i18n | |
11:22 | Convert some fopen() calls to fossil_fopen(). Missed them previously. check-in: f626fcaab6 user: drh tags: windows-i18n | |
2011-05-19
| ||
11:48 | Change the small logo to 72x72 pixels. check-in: 5267731a85 user: drh tags: trunk | |
2011-05-18
| ||
15:01 | Update the built-in SQLite to the latest 3.7.7 alpha version. This adds no new capabilities - it is merely a beta-test of the SQLite version 3.7.7. check-in: dcfa88bd46 user: drh tags: trunk | |
Changes to src/add.c.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 ... 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 ... 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); db_multi_exec( "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" "VALUES(%d,0,0,0,%Q,%d)", vid, zPath, file_isexe(zFullname)); fossil_free(zFullname); } printf("ADDED %s\n", zPath); return 1; } /* ** Add all files in the sfile temp table. ** ** Automatically exclude the repository file. ................................................................................ file_canonical_name(g.argv[i], &fullName); zName = blob_str(&fullName); isDir = file_isdir(zName); if( isDir==1 ){ vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); }else if( isDir==0 ){ fossil_fatal("not found: %s", zName); }else if( access(zName, R_OK) ){ fossil_fatal("cannot open %s", zName); }else{ char *zTreeName = &zName[nRoot]; db_multi_exec( "INSERT OR IGNORE INTO sfile(x)" " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", zTreeName, zTreeName ................................................................................ zTreeName, zTreeName, zTreeName ); blob_reset(&treeName); } db_prepare(&loop, "SELECT x FROM sfile"); while( db_step(&loop)==SQLITE_ROW ){ printf("DELETED %s\n", db_column_text(&loop, 0)); } db_finalize(&loop); db_multi_exec( "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" "DELETE FROM vfile WHERE rid=0 AND deleted;" ); db_end_transaction(0); ................................................................................ zFile = db_column_text(&q, 0); zPath = db_column_text(&q, 1); if( !file_isfile(zPath) ){ if( !isTest ){ db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); } printf("DELETED %s\n", zFile); nDelete++; } } db_finalize(&q); /* show cmmand summary */ printf("added %d files, deleted %d files\n", nAdd, nDelete); db_end_transaction(isTest); } /* ** Rename a single file. ** ** The original name of the file is zOrig. The new filename is zNew. */ static void mv_one_file(int vid, const char *zOrig, const char *zNew){ printf("RENAME %s %s\n", zOrig, zNew); db_multi_exec( "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", zNew, zOrig, vid ); } /* |
| | | | | | |
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 ... 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 ... 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); db_multi_exec( "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" "VALUES(%d,0,0,0,%Q,%d)", vid, zPath, file_isexe(zFullname)); fossil_free(zFullname); } fossil_print("ADDED %s\n", zPath); return 1; } /* ** Add all files in the sfile temp table. ** ** Automatically exclude the repository file. ................................................................................ file_canonical_name(g.argv[i], &fullName); zName = blob_str(&fullName); isDir = file_isdir(zName); if( isDir==1 ){ vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); }else if( isDir==0 ){ fossil_fatal("not found: %s", zName); }else if( file_access(zName, R_OK) ){ fossil_fatal("cannot open %s", zName); }else{ char *zTreeName = &zName[nRoot]; db_multi_exec( "INSERT OR IGNORE INTO sfile(x)" " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", zTreeName, zTreeName ................................................................................ zTreeName, zTreeName, zTreeName ); blob_reset(&treeName); } db_prepare(&loop, "SELECT x FROM sfile"); while( db_step(&loop)==SQLITE_ROW ){ fossil_print("DELETED %s\n", db_column_text(&loop, 0)); } db_finalize(&loop); db_multi_exec( "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" "DELETE FROM vfile WHERE rid=0 AND deleted;" ); db_end_transaction(0); ................................................................................ zFile = db_column_text(&q, 0); zPath = db_column_text(&q, 1); if( !file_isfile(zPath) ){ if( !isTest ){ db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); } fossil_print("DELETED %s\n", zFile); nDelete++; } } db_finalize(&q); /* show cmmand summary */ fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); db_end_transaction(isTest); } /* ** Rename a single file. ** ** The original name of the file is zOrig. The new filename is zNew. */ static void mv_one_file(int vid, const char *zOrig, const char *zNew){ fossil_print("RENAME %s %s\n", zOrig, zNew); db_multi_exec( "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", zNew, zOrig, vid ); } /* |
Changes to src/allrepo.c.
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
db_prepare(&q, "SELECT DISTINCT substr(name, 6) COLLATE nocase" " FROM global_config" " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1" ); while( db_step(&q)==SQLITE_ROW ){ const char *zFilename = db_column_text(&q, 0); if( access(zFilename, 0) ){ nMissing++; continue; } if( !file_is_canonical(zFilename) ) nMissing++; if( zCmd[0]=='l' ){ printf("%s\n", zFilename); continue; } zQFilename = quoteFilename(zFilename); zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); printf("%s\n", zSyscmd); fflush(stdout); rc = fossil_system(zSyscmd); free(zSyscmd); free(zQFilename); if( stopOnError && rc ){ nMissing = 0; break; ................................................................................ ** be found, remove those names from the ~/.fossil file. */ if( nMissing ){ db_begin_transaction(); db_reset(&q); while( db_step(&q)==SQLITE_ROW ){ const char *zFilename = db_column_text(&q, 0); if( access(zFilename, 0) ){ char *zRepo = mprintf("repo:%s", zFilename); db_unset(zRepo, 1); free(zRepo); }else if( !file_is_canonical(zFilename) ){ Blob cname; char *zRepo = mprintf("repo:%s", zFilename); db_unset(zRepo, 1); |
|
|
|
|
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
db_prepare(&q, "SELECT DISTINCT substr(name, 6) COLLATE nocase" " FROM global_config" " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1" ); while( db_step(&q)==SQLITE_ROW ){ const char *zFilename = db_column_text(&q, 0); if( file_access(zFilename, 0) ){ nMissing++; continue; } if( !file_is_canonical(zFilename) ) nMissing++; if( zCmd[0]=='l' ){ fossil_print("%s\n", zFilename); continue; } zQFilename = quoteFilename(zFilename); zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); fossil_print("%s\n", zSyscmd); fflush(stdout); rc = fossil_system(zSyscmd); free(zSyscmd); free(zQFilename); if( stopOnError && rc ){ nMissing = 0; break; ................................................................................ ** be found, remove those names from the ~/.fossil file. */ if( nMissing ){ db_begin_transaction(); db_reset(&q); while( db_step(&q)==SQLITE_ROW ){ const char *zFilename = db_column_text(&q, 0); if( file_access(zFilename, 0) ){ char *zRepo = mprintf("repo:%s", zFilename); db_unset(zRepo, 1); free(zRepo); }else if( !file_is_canonical(zFilename) ){ Blob cname; char *zRepo = mprintf("repo:%s", zFilename); db_unset(zRepo, 1); |
Changes to src/bisect.c.
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
...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
g.fNoSync = 1; update_cmd(); }else if( memcmp(zCmd, "options", n)==0 ){ if( g.argc==3 ){ unsigned int i; for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); printf(" %-15s %-6s ", aBisectOption[i].zName, db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); comment_print(aBisectOption[i].zDesc, 27, 79); } }else if( g.argc==4 || g.argc==5 ){ unsigned int i; n = strlen(g.argv[3]); for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); if( g.argc==5 ){ db_lset(z, g.argv[4]); } printf("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); break; } } if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){ fossil_fatal("no such bisect option: %s", g.argv[3]); } ................................................................................ " AND event.type='ci'"); nStep = path_length(); for(p=path_last(), n=0; p; p=p->pFrom, n++){ const char *z; db_bind_int(&s, ":rid", p->rid); if( db_step(&s)==SQLITE_ROW ){ z = db_column_text(&s, 0); printf("%s", z); if( p->rid==bisect.good ) printf(" GOOD"); if( p->rid==bisect.bad ) printf(" BAD"); if( p->rid==vid ) printf(" CURRENT"); if( nStep>1 && n==nStep/2 ) printf(" NEXT"); printf("\n"); } db_reset(&s); } db_finalize(&s); }else{ usage("bad|good|next|reset|vlist ..."); } } |
|
|
|
|
|
|
|
|
|
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
...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
g.fNoSync = 1; update_cmd(); }else if( memcmp(zCmd, "options", n)==0 ){ if( g.argc==3 ){ unsigned int i; for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); fossil_print(" %-15s %-6s ", aBisectOption[i].zName, db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); comment_print(aBisectOption[i].zDesc, 27, 79); } }else if( g.argc==4 || g.argc==5 ){ unsigned int i; n = strlen(g.argv[3]); for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){ char *z = mprintf("bisect-%s", aBisectOption[i].zName); if( g.argc==5 ){ db_lset(z, g.argv[4]); } fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault)); fossil_free(z); break; } } if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){ fossil_fatal("no such bisect option: %s", g.argv[3]); } ................................................................................ " AND event.type='ci'"); nStep = path_length(); for(p=path_last(), n=0; p; p=p->pFrom, n++){ const char *z; db_bind_int(&s, ":rid", p->rid); if( db_step(&s)==SQLITE_ROW ){ z = db_column_text(&s, 0); fossil_print("%s", z); if( p->rid==bisect.good ) fossil_print(" GOOD"); if( p->rid==bisect.bad ) fossil_print(" BAD"); if( p->rid==vid ) fossil_print(" CURRENT"); if( nStep>1 && n==nStep/2 ) fossil_print(" NEXT"); fossil_print("\n"); } db_reset(&s); } db_finalize(&s); }else{ usage("bad|good|next|reset|vlist ..."); } } |
Changes to src/blob.c.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 ... 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 ... 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 ... 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
if( i==' ' || i=='\n' || i=='\t' || i=='\v' || i=='\f' || i=='\r' ){ assert( fossil_isspace((char)i) ); }else{ assert( !fossil_isspace((char)i) ); } } printf("All 256 characters OK\n"); } /* ** This routine is called if a blob operation fails because we ** have run out of memory. */ static void blob_panic(void){ ................................................................................ if( size<0 ){ fossil_fatal("no such file: %s", zFilename); } if( size==0 ){ return 0; } blob_resize(pBlob, size); in = fopen(zFilename, "rb"); if( in==0 ){ fossil_panic("cannot open %s for reading", zFilename); } got = fread(blob_buffer(pBlob), 1, size, in); fclose(in); if( got<size ){ blob_resize(pBlob, got); ................................................................................ } #if defined(_WIN32) } #endif zName[i] = '/'; } } out = fopen(zName, "wb"); if( out==0 ){ fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); return 0; } needToClose = 1; if( zName!=zBuf ) free(zName); } blob_is_init(pBlob); wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); if( needToClose ) fclose(out); if( wrote!=blob_size(pBlob) ){ fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, blob_size(pBlob), zFilename); } return wrote; } /* ................................................................................ if( blob_compare(&b1, &b3) ){ fossil_panic("compress/uncompress cycle failed for %s", g.argv[i]); } blob_reset(&b1); blob_reset(&b2); blob_reset(&b3); } printf("ok\n"); } #if defined(_WIN32) /* ** Convert every \n character in the given blob into \r\n. */ void blob_add_cr(Blob *p){ |
| | | | | |
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 ... 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 ... 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 ... 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
if( i==' ' || i=='\n' || i=='\t' || i=='\v' || i=='\f' || i=='\r' ){ assert( fossil_isspace((char)i) ); }else{ assert( !fossil_isspace((char)i) ); } } fossil_print("All 256 characters OK\n"); } /* ** This routine is called if a blob operation fails because we ** have run out of memory. */ static void blob_panic(void){ ................................................................................ if( size<0 ){ fossil_fatal("no such file: %s", zFilename); } if( size==0 ){ return 0; } blob_resize(pBlob, size); in = fossil_fopen(zFilename, "rb"); if( in==0 ){ fossil_panic("cannot open %s for reading", zFilename); } got = fread(blob_buffer(pBlob), 1, size, in); fclose(in); if( got<size ){ blob_resize(pBlob, got); ................................................................................ } #if defined(_WIN32) } #endif zName[i] = '/'; } } out = fossil_fopen(zName, "wb"); if( out==0 ){ fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); return 0; } needToClose = 1; if( zName!=zBuf ) free(zName); } blob_is_init(pBlob); wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); if( needToClose ) fclose(out); if( wrote!=blob_size(pBlob) && out!=stdout ){ fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, blob_size(pBlob), zFilename); } return wrote; } /* ................................................................................ if( blob_compare(&b1, &b3) ){ fossil_panic("compress/uncompress cycle failed for %s", g.argv[i]); } blob_reset(&b1); blob_reset(&b2); blob_reset(&b3); } fossil_print("ok\n"); } #if defined(_WIN32) /* ** Convert every \n character in the given blob into \r\n. */ void blob_add_cr(Blob *p){ |
Changes to src/branch.c.
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); if( manifest_crosslink(brid, &branch)==0 ){ fossil_panic("unable to install new manifest"); } assert( blob_is_reset(&branch) ); content_deltify(rootid, brid, 0); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid); printf("New branch: %s\n", zUuid); if( g.argc==3 ){ printf( "\n" "Note: the local check-out has not been updated to the new\n" " branch. To begin working on the new branch, do this:\n" "\n" " %s update %s\n", fossil_nameofexe(), zBranch ); ................................................................................ " AND NOT %z" " ORDER BY value /*sort*/", TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") ); while( db_step(&q)==SQLITE_ROW ){ const char *zBr = db_column_text(&q, 0); int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; printf("%s%s\n", (isCur ? "* " : " "), zBr); } db_finalize(&q); }else{ fossil_panic("branch subcommand should be one of: " "new list ls"); } } |
|
|
|
|
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); if( manifest_crosslink(brid, &branch)==0 ){ fossil_panic("unable to install new manifest"); } assert( blob_is_reset(&branch) ); content_deltify(rootid, brid, 0); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid); fossil_print("New branch: %s\n", zUuid); if( g.argc==3 ){ fossil_print( "\n" "Note: the local check-out has not been updated to the new\n" " branch. To begin working on the new branch, do this:\n" "\n" " %s update %s\n", fossil_nameofexe(), zBranch ); ................................................................................ " AND NOT %z" " ORDER BY value /*sort*/", TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") ); while( db_step(&q)==SQLITE_ROW ){ const char *zBr = db_column_text(&q, 0); int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; fossil_print("%s%s\n", (isCur ? "* " : " "), zBr); } db_finalize(&q); }else{ fossil_panic("branch subcommand should be one of: " "new list ls"); } } |
Changes to src/captcha.c.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
char *z;
for(i=2; i<g.argc; i++){
char zHex[30];
v = (unsigned int)atoi(g.argv[i]);
sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
z = captcha_render(zHex);
printf("%s:\n%s", zHex, z);
free(z);
}
}
/*
** Compute a seed value for a captcha. The seed is public and is sent
** as a hidden parameter with the page that contains the captcha. Knowledge
|
| |
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
char *z;
for(i=2; i<g.argc; i++){
char zHex[30];
v = (unsigned int)atoi(g.argv[i]);
sqlite3_snprintf(sizeof(zHex), zHex, "%x", v);
z = captcha_render(zHex);
fossil_print("%s:\n%s", zHex, z);
free(z);
}
}
/*
** Compute a seed value for a captcha. The seed is public and is sent
** as a hidden parameter with the page that contains the captcha. Knowledge
|
Changes to src/cgi.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
....
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
|
/* ** Copyright (c) 2006 D. Richard Hipp ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the Simplified BSD License (also ** known as the "2-Clause License" or "FreeBSD License".) ** This program is distributed in the hope that it will be useful, ** but without any warranty; without even the implied warranty of ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ................................................................................ fossil_fatal("unable to open listening socket on any" " port in the range %d..%d", mnPort, mxPort); } } if( iPort>mxPort ) return 1; listen(listener,10); if( iPort>mnPort ){ printf("Listening for HTTP requests on TCP port %d\n", iPort); fflush(stdout); } if( zBrowser ){ zBrowser = mprintf(zBrowser, iPort); system(zBrowser); } while( 1 ){ |
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
....
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
|
/* ** Copyright (c) 2006 D. Richard Hipp ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the Simplified BSD License (also ** known as the "2-Clause License" or "FreeBSD License".) ** ** This program is distributed in the hope that it will be useful, ** but without any warranty; without even the implied warranty of ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ................................................................................ fossil_fatal("unable to open listening socket on any" " port in the range %d..%d", mnPort, mxPort); } } if( iPort>mxPort ) return 1; listen(listener,10); if( iPort>mnPort ){ fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); fflush(stdout); } if( zBrowser ){ zBrowser = mprintf(zBrowser, iPort); system(zBrowser); } while( 1 ){ |
Changes to src/checkin.c.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ... 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 ... 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 ... 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 ... 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 .... 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 .... 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
int isNew = db_column_int(&q,3)==0; int isRenamed = db_column_int(&q,4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); blob_append(report, zPrefix, nPrefix); if( isDeleted ){ blob_appendf(report, "DELETED %s\n", zPathname); }else if( !file_isfile(zFullName) ){ if( access(zFullName, 0)==0 ){ blob_appendf(report, "NOT_A_FILE %s\n", zPathname); if( missingIsFatal ){ fossil_warning("not a file: %s", zPathname); nErr++; } }else{ blob_appendf(report, "MISSING %s\n", zPathname); ................................................................................ ** --sha1sum Verify file status using SHA1 hashing rather ** than relying on file mtimes. */ void status_cmd(void){ int vid; db_must_be_within_tree(); /* 012345678901234 */ printf("repository: %s\n", db_lget("repository","")); printf("local-root: %s\n", g.zLocalRoot); printf("server-code: %s\n", db_get("server-code", "")); vid = db_lget_int("checkout", 0); if( vid ){ show_common_info(vid, "checkout:", 1, 1); } changes_cmd(); } ................................................................................ const char *zPathname = db_column_text(&q,0); int isDeleted = db_column_int(&q, 1); int isNew = db_column_int(&q,2)==0; int chnged = db_column_int(&q,3); int renamed = db_column_int(&q,4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); if( isBrief ){ printf("%s\n", zPathname); }else if( isNew ){ printf("ADDED %s\n", zPathname); }else if( isDeleted ){ printf("DELETED %s\n", zPathname); }else if( !file_isfile(zFullName) ){ if( access(zFullName, 0)==0 ){ printf("NOT_A_FILE %s\n", zPathname); }else{ printf("MISSING %s\n", zPathname); } }else if( chnged ){ printf("EDITED %s\n", zPathname); }else if( renamed ){ printf("RENAMED %s\n", zPathname); }else{ printf("UNCHANGED %s\n", zPathname); } free(zFullName); } db_finalize(&q); } /* ................................................................................ " ORDER BY 1", fossil_all_reserved_names() ); if( file_tree_name(g.zRepositoryName, &repo, 0) ){ db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); } while( db_step(&q)==SQLITE_ROW ){ printf("%s\n", db_column_text(&q, 0)); } db_finalize(&q); } /* ** COMMAND: clean ** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN? ................................................................................ g.zLocalRoot, fossil_all_reserved_names() ); if( file_tree_name(g.zRepositoryName, &repo, 0) ){ db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); } while( db_step(&q)==SQLITE_ROW ){ if( allFlag ){ unlink(db_column_text(&q, 0)); }else{ Blob ans; char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ", db_column_text(&q, 0)); blob_zero(&ans); prompt_user(prompt, &ans); if( blob_str(&ans)[0]=='y' ){ unlink(db_column_text(&q, 0)); } } } db_finalize(&q); } /* ................................................................................ } #if defined(_WIN32) blob_add_cr(&text); #endif blob_write_to_file(&text, zFile); if( zEditor ){ zCmd = mprintf("%s \"%s\"", zEditor, zFile); printf("%s\n", zCmd); if( fossil_system(zCmd) ){ fossil_panic("editor aborted"); } blob_reset(&text); blob_read_from_file(&text, zFile); }else{ char zIn[300]; blob_reset(&text); while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ) break; blob_append(&text, zIn, -1); } } blob_remove_cr(&text); unlink(zFile); free(zFile); blob_zero(pComment); while( blob_line(&text, &line) ){ int i, n; char *z; n = blob_size(&line); z = blob_buffer(&line); ................................................................................ fossil_panic("trouble committing manifest: %s", g.zErrMsg); } db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid); manifest_crosslink(nvid, &manifest); assert( blob_is_reset(&manifest) ); content_deltify(vid, nvid, 0); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid); printf("New_Version: %s\n", zUuid); if( outputManifest ){ zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot); blob_zero(&muuid); blob_appendf(&muuid, "%s\n", zUuid); blob_write_to_file(&muuid, zManifestFile); free(zManifestFile); blob_reset(&muuid); ................................................................................ } db_end_transaction(0); if( !g.markPrivate ){ autosync(AUTOSYNC_PUSH); } if( count_nonbranch_children(vid)>1 ){ printf("**** warning: a fork has occurred *****\n"); } } |
| | | | | | | | | | | | | | | | | | > > > > > | | | |
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ... 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 ... 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 ... 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 ... 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 .... 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 .... 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
int isNew = db_column_int(&q,3)==0; int isRenamed = db_column_int(&q,4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); blob_append(report, zPrefix, nPrefix); if( isDeleted ){ blob_appendf(report, "DELETED %s\n", zPathname); }else if( !file_isfile(zFullName) ){ if( file_access(zFullName, 0)==0 ){ blob_appendf(report, "NOT_A_FILE %s\n", zPathname); if( missingIsFatal ){ fossil_warning("not a file: %s", zPathname); nErr++; } }else{ blob_appendf(report, "MISSING %s\n", zPathname); ................................................................................ ** --sha1sum Verify file status using SHA1 hashing rather ** than relying on file mtimes. */ void status_cmd(void){ int vid; db_must_be_within_tree(); /* 012345678901234 */ fossil_print("repository: %s\n", db_lget("repository","")); fossil_print("local-root: %s\n", g.zLocalRoot); fossil_print("server-code: %s\n", db_get("server-code", "")); vid = db_lget_int("checkout", 0); if( vid ){ show_common_info(vid, "checkout:", 1, 1); } changes_cmd(); } ................................................................................ const char *zPathname = db_column_text(&q,0); int isDeleted = db_column_int(&q, 1); int isNew = db_column_int(&q,2)==0; int chnged = db_column_int(&q,3); int renamed = db_column_int(&q,4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); if( isBrief ){ fossil_print("%s\n", zPathname); }else if( isNew ){ fossil_print("ADDED %s\n", zPathname); }else if( isDeleted ){ fossil_print("DELETED %s\n", zPathname); }else if( !file_isfile(zFullName) ){ if( file_access(zFullName, 0)==0 ){ fossil_print("NOT_A_FILE %s\n", zPathname); }else{ fossil_print("MISSING %s\n", zPathname); } }else if( chnged ){ fossil_print("EDITED %s\n", zPathname); }else if( renamed ){ fossil_print("RENAMED %s\n", zPathname); }else{ fossil_print("UNCHANGED %s\n", zPathname); } free(zFullName); } db_finalize(&q); } /* ................................................................................ " ORDER BY 1", fossil_all_reserved_names() ); if( file_tree_name(g.zRepositoryName, &repo, 0) ){ db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); } while( db_step(&q)==SQLITE_ROW ){ fossil_print("%s\n", db_column_text(&q, 0)); } db_finalize(&q); } /* ** COMMAND: clean ** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN? ................................................................................ g.zLocalRoot, fossil_all_reserved_names() ); if( file_tree_name(g.zRepositoryName, &repo, 0) ){ db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); } while( db_step(&q)==SQLITE_ROW ){ if( allFlag ){ file_delete(db_column_text(&q, 0)); }else{ Blob ans; char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ", db_column_text(&q, 0)); blob_zero(&ans); prompt_user(prompt, &ans); if( blob_str(&ans)[0]=='y' ){ file_delete(db_column_text(&q, 0)); } } } db_finalize(&q); } /* ................................................................................ } #if defined(_WIN32) blob_add_cr(&text); #endif blob_write_to_file(&text, zFile); if( zEditor ){ zCmd = mprintf("%s \"%s\"", zEditor, zFile); fossil_print("%s\n", zCmd); if( fossil_system(zCmd) ){ fossil_panic("editor aborted"); } blob_reset(&text); blob_read_from_file(&text, zFile); }else{ char zIn[300]; blob_reset(&text); while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ char *zUtf8 = fossil_mbcs_to_utf8(zIn); if( zUtf8[0]=='.' && (zUtf8[1]==0 || zUtf8[1]=='\r' || zUtf8[1]=='\n') ){ fossil_mbcs_free(zUtf8); break; } blob_append(&text, zIn, -1); fossil_mbcs_free(zUtf8); } } blob_remove_cr(&text); file_delete(zFile); free(zFile); blob_zero(pComment); while( blob_line(&text, &line) ){ int i, n; char *z; n = blob_size(&line); z = blob_buffer(&line); ................................................................................ fossil_panic("trouble committing manifest: %s", g.zErrMsg); } db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid); manifest_crosslink(nvid, &manifest); assert( blob_is_reset(&manifest) ); content_deltify(vid, nvid, 0); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid); fossil_print("New_Version: %s\n", zUuid); if( outputManifest ){ zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot); blob_zero(&muuid); blob_appendf(&muuid, "%s\n", zUuid); blob_write_to_file(&muuid, zManifestFile); free(zManifestFile); blob_reset(&muuid); ................................................................................ } db_end_transaction(0); if( !g.markPrivate ){ autosync(AUTOSYNC_PUSH); } if( count_nonbranch_children(vid)>1 ){ fossil_print("**** warning: a fork has occurred *****\n"); } } |
Changes to src/checkout.c.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 ... 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 ... 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
blob_append(&hash, "\n", 1); blob_write_to_file(&hash, zManFile); free(zManFile); blob_reset(&hash); }else{ if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){ zManFile = mprintf("%smanifest", g.zLocalRoot); unlink(zManFile); free(zManFile); } if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){ zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); unlink(zManFile); free(zManFile); } } } /* ................................................................................ db_lset_int("checkout", vid); undo_reset(); db_multi_exec("DELETE FROM vmerge"); if( !keepFlag && db_get_boolean("repo-cksum",1) ){ vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b); vfile_aggregate_checksum_disk(vid, &cksum2); if( blob_compare(&cksum1, &cksum2) ){ printf("WARNING: manifest checksum does not agree with disk\n"); } if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ printf("WARNING: manifest checksum does not agree with manifest\n"); } } db_end_transaction(0); } /* ** Unlink the local database file ................................................................................ static void unlink_local_database(int manifestOnly){ const char *zReserved; int i; for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ if( manifestOnly==0 || zReserved[0]=='m' ){ char *z; z = mprintf("%s%s", g.zLocalRoot, zReserved); unlink(z); free(z); } } } /* ** COMMAND: close |
| | | | | |
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 ... 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 ... 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
blob_append(&hash, "\n", 1); blob_write_to_file(&hash, zManFile); free(zManFile); blob_reset(&hash); }else{ if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){ zManFile = mprintf("%smanifest", g.zLocalRoot); file_delete(zManFile); free(zManFile); } if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){ zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); file_delete(zManFile); free(zManFile); } } } /* ................................................................................ db_lset_int("checkout", vid); undo_reset(); db_multi_exec("DELETE FROM vmerge"); if( !keepFlag && db_get_boolean("repo-cksum",1) ){ vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b); vfile_aggregate_checksum_disk(vid, &cksum2); if( blob_compare(&cksum1, &cksum2) ){ fossil_print("WARNING: manifest checksum does not agree with disk\n"); } if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ fossil_print("WARNING: manifest checksum does not agree with manifest\n"); } } db_end_transaction(0); } /* ** Unlink the local database file ................................................................................ static void unlink_local_database(int manifestOnly){ const char *zReserved; int i; for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ if( manifestOnly==0 || zReserved[0]=='m' ){ char *z; z = mprintf("%s%s", g.zLocalRoot, zReserved); file_delete(z); free(z); } } } /* ** COMMAND: close |
Changes to src/clearsign.c.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
blob_zero(pOut); blob_read_from_file(pOut, zIn); }else{ if( pOut!=pIn ){ blob_copy(pOut, pIn); } } unlink(zOut); unlink(zIn); free(zOut); free(zIn); return rc; } |
| | |
50 51 52 53 54 55 56 57 58 59 60 61 62 |
blob_zero(pOut); blob_read_from_file(pOut, zIn); }else{ if( pOut!=pIn ){ blob_copy(pOut, pIn); } } file_delete(zOut); file_delete(zIn); free(zOut); free(zIn); return rc; } |
Changes to src/clone.c.
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
"DELETE FROM private;" ); shun_artifacts(); g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'"); if( g.zLogin==0 ){ db_create_default_users(1,zDefaultUser); } printf("Repository cloned into %s\n", g.argv[3]); }else{ db_create_repository(g.argv[3]); db_open_repository(g.argv[3]); db_begin_transaction(); db_record_repository_filename(g.argv[3]); db_initial_setup(0, zDefaultUser, 0); user_select(); ................................................................................ g.xlinkClusterOnly = 1; nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0); g.xlinkClusterOnly = 0; verify_cancel(); db_end_transaction(0); db_close(1); if( nErr ){ unlink(g.argv[3]); fossil_fatal("server returned an error - clone aborted"); } db_open_repository(g.argv[3]); } db_begin_transaction(); printf("Rebuilding repository meta-data...\n"); rebuild_db(0, 1, 0); printf("project-id: %s\n", db_get("project-code", 0)); printf("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); db_end_transaction(0); } |
|
|
|
|
|
|
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
"DELETE FROM private;" ); shun_artifacts(); g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'"); if( g.zLogin==0 ){ db_create_default_users(1,zDefaultUser); } fossil_print("Repository cloned into %s\n", g.argv[3]); }else{ db_create_repository(g.argv[3]); db_open_repository(g.argv[3]); db_begin_transaction(); db_record_repository_filename(g.argv[3]); db_initial_setup(0, zDefaultUser, 0); user_select(); ................................................................................ g.xlinkClusterOnly = 1; nErr = client_sync(0,0,1,bPrivate,CONFIGSET_ALL,0); g.xlinkClusterOnly = 0; verify_cancel(); db_end_transaction(0); db_close(1); if( nErr ){ file_delete(g.argv[3]); fossil_fatal("server returned an error - clone aborted"); } db_open_repository(g.argv[3]); } db_begin_transaction(); fossil_print("Rebuilding repository meta-data...\n"); rebuild_db(0, 1, 0); fossil_print("project-id: %s\n", db_get("project-code", 0)); fossil_print("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); db_end_transaction(0); } |
Changes to src/comformat.c.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 .. 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 .. 91 92 93 94 95 96 97 98 99 100 |
char zBuf[400]; int lineCnt = 0; for(;;){ while( fossil_isspace(zText[0]) ){ zText++; } if( zText[0]==0 ){ if( doIndent==0 ){ printf("\n"); lineCnt = 1; } return lineCnt; } for(sk=si=i=k=0; zText[i] && k<tlen; i++){ char c = zText[i]; if( fossil_isspace(c) ){ ................................................................................ si = i+1; sk = k+1; } k++; } } if( doIndent ){ printf("%*s", indent, ""); } doIndent = 1; if( sk>0 && zText[i] ){ zText += si; zBuf[sk++] = '\n'; zBuf[sk] = 0; printf("%s", zBuf); }else{ zText += i; zBuf[k++] = '\n'; zBuf[k] = 0; printf("%s", zBuf); } lineCnt++; } } /* ** Test the comment printing ................................................................................ */ void test_comment_format(void){ int indent; if( g.argc!=4 ){ usage("PREFIX TEXT"); } indent = strlen(g.argv[2]) + 1; printf("%s ", g.argv[2]); printf("(%d lines output)\n", comment_print(g.argv[3], indent, 79)); } |
| | | | | | |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 .. 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 .. 91 92 93 94 95 96 97 98 99 100 |
char zBuf[400]; int lineCnt = 0; for(;;){ while( fossil_isspace(zText[0]) ){ zText++; } if( zText[0]==0 ){ if( doIndent==0 ){ fossil_print("\n"); lineCnt = 1; } return lineCnt; } for(sk=si=i=k=0; zText[i] && k<tlen; i++){ char c = zText[i]; if( fossil_isspace(c) ){ ................................................................................ si = i+1; sk = k+1; } k++; } } if( doIndent ){ fossil_print("%*s", indent, ""); } doIndent = 1; if( sk>0 && zText[i] ){ zText += si; zBuf[sk++] = '\n'; zBuf[sk] = 0; fossil_print("%s", zBuf); }else{ zText += i; zBuf[k++] = '\n'; zBuf[k] = 0; fossil_print("%s", zBuf); } lineCnt++; } } /* ** Test the comment printing ................................................................................ */ void test_comment_format(void){ int indent; if( g.argc!=4 ){ usage("PREFIX TEXT"); } indent = strlen(g.argv[2]) + 1; fossil_print("%s ", g.argv[2]); fossil_print("(%d lines output)\n", comment_print(g.argv[3], indent, 79)); } |
Changes to src/configure.c.
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
|
int n = strlen(z); for(i=0; i<count(aGroupName); i++){ if( strncmp(z, &aGroupName[i].zName[1], n)==0 ){ return aGroupName[i].groupMask; } } if( notFoundIsFatal ){ printf("Available configuration areas:\n"); for(i=0; i<count(aGroupName); i++){ printf(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp); } fossil_fatal("no such configuration area: \"%s\"", z); } return 0; } /* ................................................................................ }else if( fossil_strcmp(zName,"@shun")==0 ){ db_multi_exec("DELETE FROM shun"); }else if( fossil_strcmp(zName,"@reportfmt")==0 ){ db_multi_exec("DELETE FROM reportfmt"); } } db_end_transaction(0); printf("Configuration reset to factory defaults.\n"); printf("To recover, use: %s %s import %s\n", fossil_nameofexe(), g.argv[1], zBackup); }else { fossil_fatal("METHOD should be one of:" " export import merge pull push reset"); } } |
|
|
|
|
|
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
|
int n = strlen(z); for(i=0; i<count(aGroupName); i++){ if( strncmp(z, &aGroupName[i].zName[1], n)==0 ){ return aGroupName[i].groupMask; } } if( notFoundIsFatal ){ fossil_print("Available configuration areas:\n"); for(i=0; i<count(aGroupName); i++){ fossil_print(" %-10s %s\n", &aGroupName[i].zName[1], aGroupName[i].zHelp); } fossil_fatal("no such configuration area: \"%s\"", z); } return 0; } /* ................................................................................ }else if( fossil_strcmp(zName,"@shun")==0 ){ db_multi_exec("DELETE FROM shun"); }else if( fossil_strcmp(zName,"@reportfmt")==0 ){ db_multi_exec("DELETE FROM reportfmt"); } } db_end_transaction(0); fossil_print("Configuration reset to factory defaults.\n"); fossil_print("To recover, use: %s %s import %s\n", fossil_nameofexe(), g.argv[1], zBackup); }else { fossil_fatal("METHOD should be one of:" " export import merge pull push reset"); } } |
Changes to src/content.c.
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 ... 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 ... 857 858 859 860 861 862 863 864 865 |
int rid; Blob content; if( g.argc!=3 ) usage("FILENAME"); db_must_be_within_tree(); user_select(); blob_read_from_file(&content, g.argv[2]); rid = content_put(&content); printf("inserted as record %d\n", rid); } /* ** Make sure the content at rid is the original content and is not a ** delta. */ void content_undelta(int rid){ ................................................................................ db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); total = db_int(0, "SELECT max(rid) FROM blob"); while( db_step(&q)==SQLITE_ROW ){ int rid = db_column_int(&q, 0); const char *zUuid = db_column_text(&q, 1); int size = db_column_int(&q, 2); n1++; printf(" %d/%d\r", n1, total); fflush(stdout); if( size<0 ){ printf("skip phantom %d %s\n", rid, zUuid); continue; /* Ignore phantoms */ } content_get(rid, &content); if( blob_size(&content)!=size ){ fossil_warning("size mismatch on blob rid=%d: %d vs %d", rid, blob_size(&content), size); } ................................................................................ rid, blob_str(&cksum), zUuid); } blob_reset(&cksum); blob_reset(&content); n2++; } db_finalize(&q); printf("%d non-phantom blobs (out of %d total) verified\n", n2, n1); } |
| | | | |
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 ... 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 ... 857 858 859 860 861 862 863 864 865 |
int rid; Blob content; if( g.argc!=3 ) usage("FILENAME"); db_must_be_within_tree(); user_select(); blob_read_from_file(&content, g.argv[2]); rid = content_put(&content); fossil_print("inserted as record %d\n", rid); } /* ** Make sure the content at rid is the original content and is not a ** delta. */ void content_undelta(int rid){ ................................................................................ db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); total = db_int(0, "SELECT max(rid) FROM blob"); while( db_step(&q)==SQLITE_ROW ){ int rid = db_column_int(&q, 0); const char *zUuid = db_column_text(&q, 1); int size = db_column_int(&q, 2); n1++; fossil_print(" %d/%d\r", n1, total); fflush(stdout); if( size<0 ){ fossil_print("skip phantom %d %s\n", rid, zUuid); continue; /* Ignore phantoms */ } content_get(rid, &content); if( blob_size(&content)!=size ){ fossil_warning("size mismatch on blob rid=%d: %d vs %d", rid, blob_size(&content), size); } ................................................................................ rid, blob_str(&cksum), zUuid); } blob_reset(&cksum); blob_reset(&content); n2++; } db_finalize(&q); fossil_print("%d non-phantom blobs (out of %d total) verified\n", n2, n1); } |
Changes to src/db.c.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 ... 693 694 695 696 697 698 699 700 701 702 703 704 705 706 ... 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 ... 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 ... 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 ... 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
if( nBegin ){ sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); nBegin = 0; } busy = 0; db_close(0); for(i=0; i<nDeleteOnFail; i++){ unlink(azDeleteOnFail[i]); } } /* ** Install a commit hook. Hooks are installed in sequence order. ** It is an error to install the same commit hook more than once. ** ................................................................................ } } if( zHome==0 ){ fossil_fatal("cannot locate home directory - " "please set the LOCALAPPDATA or APPDATA or HOMEPATH " "environment variables"); } #else zHome = getenv("HOME"); if( zHome==0 ){ fossil_fatal("cannot locate home directory - " "please set the HOME environment variable"); } #endif ................................................................................ ** true. If it is not a valid local database file, return 0. */ static int isValidLocalDb(const char *zDbName){ i64 lsize; int rc; sqlite3_stmt *pStmt; if( access(zDbName, F_OK) ) return 0; lsize = file_size(zDbName); if( lsize%1024!=0 || lsize<4096 ) return 0; db_open_or_attach(zDbName, "localdb"); g.localOpen = 1; db_open_config(0); db_open_repository(0); ................................................................................ db_err("pwd too big: max %d", sizeof(zPwd)-20); } n = strlen(zPwd); zPwdConv = mprintf("%/", zPwd); strncpy(zPwd, zPwdConv, 2000-20); free(zPwdConv); while( n>0 ){ if( access(zPwd, W_OK) ) break; for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){ sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]); if( isValidLocalDb(zPwd) ){ /* Found a valid checkout database file */ zPwd[n] = 0; while( n>1 && zPwd[n-1]=='/' ){ n--; ................................................................................ if( g.localOpen ){ zDbName = db_lget("repository", 0); } if( zDbName==0 ){ db_err("unable to find the name of a repository database"); } } if( access(zDbName, R_OK) || file_size(zDbName)<1024 ){ if( access(zDbName, 0) ){ fossil_panic("repository does not exist or" " is in an unreadable directory: %s", zDbName); }else if( access(zDbName, R_OK) ){ fossil_panic("read permission denied for repository %s", zDbName); }else{ fossil_panic("not a valid repository: %s", zDbName); } } db_open_or_attach(zDbName, "repository"); g.repositoryOpen = 1; ................................................................................ } if( db_open_local()==0 ){ fossil_fatal("not in a local checkout"); return; } file_canonical_name(g.argv[2], &repo); zRepo = blob_str(&repo); if( access(zRepo, 0) ){ fossil_fatal("no such file: %s", zRepo); } db_open_or_attach(zRepo, "test_repo"); db_lset("repository", blob_str(&repo)); db_close(1); } |
| > | | | | | | |
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 ... 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 ... 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 ... 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 ... 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 ... 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
if( nBegin ){ sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); nBegin = 0; } busy = 0; db_close(0); for(i=0; i<nDeleteOnFail; i++){ file_delete(azDeleteOnFail[i]); } } /* ** Install a commit hook. Hooks are installed in sequence order. ** It is an error to install the same commit hook more than once. ** ................................................................................ } } if( zHome==0 ){ fossil_fatal("cannot locate home directory - " "please set the LOCALAPPDATA or APPDATA or HOMEPATH " "environment variables"); } zHome = fossil_mbcs_to_utf8(zHome); #else zHome = getenv("HOME"); if( zHome==0 ){ fossil_fatal("cannot locate home directory - " "please set the HOME environment variable"); } #endif ................................................................................ ** true. If it is not a valid local database file, return 0. */ static int isValidLocalDb(const char *zDbName){ i64 lsize; int rc; sqlite3_stmt *pStmt; if( file_access(zDbName, F_OK) ) return 0; lsize = file_size(zDbName); if( lsize%1024!=0 || lsize<4096 ) return 0; db_open_or_attach(zDbName, "localdb"); g.localOpen = 1; db_open_config(0); db_open_repository(0); ................................................................................ db_err("pwd too big: max %d", sizeof(zPwd)-20); } n = strlen(zPwd); zPwdConv = mprintf("%/", zPwd); strncpy(zPwd, zPwdConv, 2000-20); free(zPwdConv); while( n>0 ){ if( file_access(zPwd, W_OK) ) break; for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){ sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]); if( isValidLocalDb(zPwd) ){ /* Found a valid checkout database file */ zPwd[n] = 0; while( n>1 && zPwd[n-1]=='/' ){ n--; ................................................................................ if( g.localOpen ){ zDbName = db_lget("repository", 0); } if( zDbName==0 ){ db_err("unable to find the name of a repository database"); } } if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){ if( file_access(zDbName, 0) ){ fossil_panic("repository does not exist or" " is in an unreadable directory: %s", zDbName); }else if( file_access(zDbName, R_OK) ){ fossil_panic("read permission denied for repository %s", zDbName); }else{ fossil_panic("not a valid repository: %s", zDbName); } } db_open_or_attach(zDbName, "repository"); g.repositoryOpen = 1; ................................................................................ } if( db_open_local()==0 ){ fossil_fatal("not in a local checkout"); return; } file_canonical_name(g.argv[2], &repo); zRepo = blob_str(&repo); if( file_access(zRepo, 0) ){ fossil_fatal("no such file: %s", zRepo); } db_open_or_attach(zRepo, "test_repo"); db_lset("repository", blob_str(&repo)); db_close(1); } |
Changes to src/deltacmd.c.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 ... 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 ... 150 151 152 153 154 155 156 157 158 |
*/ void delta_create_cmd(void){ Blob orig, target, delta; if( g.argc!=5 ){ usage("ORIGIN TARGET DELTA"); } if( blob_read_from_file(&orig, g.argv[2])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[2]); fossil_exit(1); } if( blob_read_from_file(&target, g.argv[3])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[3]); fossil_exit(1); } blob_delta_create(&orig, &target, &delta); if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ fprintf(stderr,"cannot write %s\n", g.argv[4]); fossil_exit(1); } blob_reset(&orig); blob_reset(&target); blob_reset(&delta); } /* ................................................................................ */ void delta_apply_cmd(void){ Blob orig, target, delta; if( g.argc!=5 ){ usage("ORIGIN DELTA TARGET"); } if( blob_read_from_file(&orig, g.argv[2])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[2]); fossil_exit(1); } if( blob_read_from_file(&delta, g.argv[3])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[3]); fossil_exit(1); } blob_delta_apply(&orig, &delta, &target); if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ fprintf(stderr,"cannot write %s\n", g.argv[4]); fossil_exit(1); } blob_reset(&orig); blob_reset(&target); blob_reset(&delta); } /* ................................................................................ blob_delta_create(&f1, &f2, &d12); blob_delta_create(&f2, &f1, &d21); blob_delta_apply(&f1, &d12, &a2); blob_delta_apply(&f2, &d21, &a1); if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){ fossil_panic("delta test failed"); } printf("ok\n"); } |
| < | < | < | < | < | < | |
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 ... 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 ... 144 145 146 147 148 149 150 151 152 |
*/ void delta_create_cmd(void){ Blob orig, target, delta; if( g.argc!=5 ){ usage("ORIGIN TARGET DELTA"); } if( blob_read_from_file(&orig, g.argv[2])<0 ){ fossil_fatal("cannot read %s\n", g.argv[2]); } if( blob_read_from_file(&target, g.argv[3])<0 ){ fossil_fatal("cannot read %s\n", g.argv[3]); } blob_delta_create(&orig, &target, &delta); if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ fossil_fatal("cannot write %s\n", g.argv[4]); } blob_reset(&orig); blob_reset(&target); blob_reset(&delta); } /* ................................................................................ */ void delta_apply_cmd(void){ Blob orig, target, delta; if( g.argc!=5 ){ usage("ORIGIN DELTA TARGET"); } if( blob_read_from_file(&orig, g.argv[2])<0 ){ fossil_fatal("cannot read %s\n", g.argv[2]); } if( blob_read_from_file(&delta, g.argv[3])<0 ){ fossil_fatal("cannot read %s\n", g.argv[3]); } blob_delta_apply(&orig, &delta, &target); if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ fossil_fatal("cannot write %s\n", g.argv[4]); } blob_reset(&orig); blob_reset(&target); blob_reset(&delta); } /* ................................................................................ blob_delta_create(&f1, &f2, &d12); blob_delta_create(&f2, &f1, &d21); blob_delta_apply(&f1, &d12, &a2); blob_delta_apply(&f2, &d21, &a1); if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){ fossil_panic("delta test failed"); } fossil_print("ok\n"); } |
Changes to src/diff.c.
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 ... 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 ... 924 925 926 927 928 929 930 931 932 933 |
Blob a, b; int r; int i; int *R; if( g.argc<4 ) usage("FILE1 FILE2 ..."); blob_read_from_file(&a, g.argv[2]); for(i=3; i<g.argc; i++){ if( i>3 ) printf("-------------------------------\n"); blob_read_from_file(&b, g.argv[i]); R = text_diff(&a, &b, 0, 0, 0); for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){ printf(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]); } /* free(R); */ blob_reset(&b); } } /* ................................................................................ if( annotation_step(&x, &b, g.argv[i-1]) ){ fossil_fatal("binary file"); } } for(i=0; i<x.nOrig; i++){ const char *zSrc = x.aOrig[i].zSrc; if( zSrc==0 ) zSrc = g.argv[g.argc-1]; printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z); } } /* Annotation flags */ #define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */ /* ................................................................................ if( showLog ){ for(i=0; i<ann.nVers; i++){ printf("version %3d: %s\n", i+1, ann.azVers[i]); } printf("---------------------------------------------------\n"); } for(i=0; i<ann.nOrig; i++){ printf("%s: %.*s\n", ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z); } } |
| | | > | |
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 ... 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 ... 924 925 926 927 928 929 930 931 932 933 934 |
Blob a, b; int r; int i; int *R; if( g.argc<4 ) usage("FILE1 FILE2 ..."); blob_read_from_file(&a, g.argv[2]); for(i=3; i<g.argc; i++){ if( i>3 ) fossil_print("-------------------------------\n"); blob_read_from_file(&b, g.argv[i]); R = text_diff(&a, &b, 0, 0, 0); for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){ fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]); } /* free(R); */ blob_reset(&b); } } /* ................................................................................ if( annotation_step(&x, &b, g.argv[i-1]) ){ fossil_fatal("binary file"); } } for(i=0; i<x.nOrig; i++){ const char *zSrc = x.aOrig[i].zSrc; if( zSrc==0 ) zSrc = g.argv[g.argc-1]; fossil_print("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z); } } /* Annotation flags */ #define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */ /* ................................................................................ if( showLog ){ for(i=0; i<ann.nVers; i++){ printf("version %3d: %s\n", i+1, ann.azVers[i]); } printf("---------------------------------------------------\n"); } for(i=0; i<ann.nOrig; i++){ fossil_print("%s: %.*s\n", ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z); } } |
Changes to src/diffcmd.c.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 ... 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
/* Construct a temporary file to hold pFile1 based on the name of ** zFile2 */ blob_zero(&nameFile1); do{ blob_reset(&nameFile1); blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++); }while( access(blob_str(&nameFile1),0)==0 ); blob_write_to_file(pFile1, blob_str(&nameFile1)); /* Construct the external diff command */ blob_zero(&cmd); blob_appendf(&cmd, "%s ", zDiffCmd); shell_escape(&cmd, blob_str(&nameFile1)); blob_append(&cmd, " ", 1); shell_escape(&cmd, zFile2); /* Run the external diff command */ fossil_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ unlink(blob_str(&nameFile1)); blob_reset(&nameFile1); blob_reset(&cmd); } } /* ** Show the difference between two files, both in memory. ................................................................................ blob_append(&cmd, " ", 1); shell_escape(&cmd, zTemp2); /* Run the external diff command */ fossil_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ unlink(zTemp1); unlink(zTemp2); blob_reset(&cmd); } } /* ** Do a diff against a single file named in g.argv[2] from version zFrom ** against the same file on disk. ................................................................................ int srcid = db_column_int(&q, 4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); char *zToFree = zFullName; int showDiff = 1; if( isDeleted ){ diff_printf("DELETED %s\n", zPathname); if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; } }else if( access(zFullName, 0) ){ diff_printf("MISSING %s\n", zPathname); if( !asNewFile ){ showDiff = 0; } }else if( isNew ){ diff_printf("ADDED %s\n", zPathname); srcid = 0; if( !asNewFile ){ showDiff = 0; } }else if( isChnged==3 ){ |
| | | | | |
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 ... 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
/* Construct a temporary file to hold pFile1 based on the name of ** zFile2 */ blob_zero(&nameFile1); do{ blob_reset(&nameFile1); blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++); }while( file_access(blob_str(&nameFile1),0)==0 ); blob_write_to_file(pFile1, blob_str(&nameFile1)); /* Construct the external diff command */ blob_zero(&cmd); blob_appendf(&cmd, "%s ", zDiffCmd); shell_escape(&cmd, blob_str(&nameFile1)); blob_append(&cmd, " ", 1); shell_escape(&cmd, zFile2); /* Run the external diff command */ fossil_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ file_delete(blob_str(&nameFile1)); blob_reset(&nameFile1); blob_reset(&cmd); } } /* ** Show the difference between two files, both in memory. ................................................................................ blob_append(&cmd, " ", 1); shell_escape(&cmd, zTemp2); /* Run the external diff command */ fossil_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ file_delete(zTemp1); file_delete(zTemp2); blob_reset(&cmd); } } /* ** Do a diff against a single file named in g.argv[2] from version zFrom ** against the same file on disk. ................................................................................ int srcid = db_column_int(&q, 4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); char *zToFree = zFullName; int showDiff = 1; if( isDeleted ){ diff_printf("DELETED %s\n", zPathname); if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; } }else if( file_access(zFullName, 0) ){ diff_printf("MISSING %s\n", zPathname); if( !asNewFile ){ showDiff = 0; } }else if( isNew ){ diff_printf("ADDED %s\n", zPathname); srcid = 0; if( !asNewFile ){ showDiff = 0; } }else if( isChnged==3 ){ |
Changes to src/encode.c.
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 ... 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
** Usage: %fossil test-encode64 STRING */ void test_encode64_cmd(void){ char *z; int i; for(i=2; i<g.argc; i++){ z = encode64(g.argv[i], -1); printf("%s\n", z); free(z); } } /* ** This function treats its input as a base-64 string and returns the ................................................................................ ** Usage: %fossil test-decode64 STRING */ void test_decode64_cmd(void){ char *z; int i, n; for(i=2; i<g.argc; i++){ z = decode64(g.argv[i], &n); printf("%d: %s\n", n, z); free(z); } } /* ** The base-16 encoding using the following characters: ** ................................................................................ */ void test_obscure_cmd(void){ int i; char *z, *z2; for(i=2; i<g.argc; i++){ z = obscure(g.argv[i]); z2 = unobscure(z); printf("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2); free(z); free(z2); z = unobscure(g.argv[i]); printf("UNOBSCURE: %s -> %s\n", g.argv[i], z); free(z); } } |
| | | | |
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 ... 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
** Usage: %fossil test-encode64 STRING */ void test_encode64_cmd(void){ char *z; int i; for(i=2; i<g.argc; i++){ z = encode64(g.argv[i], -1); fossil_print("%s\n", z); free(z); } } /* ** This function treats its input as a base-64 string and returns the ................................................................................ ** Usage: %fossil test-decode64 STRING */ void test_decode64_cmd(void){ char *z; int i, n; for(i=2; i<g.argc; i++){ z = decode64(g.argv[i], &n); fossil_print("%d: %s\n", n, z); free(z); } } /* ** The base-16 encoding using the following characters: ** ................................................................................ */ void test_obscure_cmd(void){ int i; char *z, *z2; for(i=2; i<g.argc; i++){ z = obscure(g.argv[i]); z2 = unobscure(z); fossil_print("OBSCURE: %s -> %s (%s)\n", g.argv[i], z, z2); free(z); free(z2); z = unobscure(g.argv[i]); fossil_print("UNOBSCURE: %s -> %s\n", g.argv[i], z); free(z); } } |
Changes to src/file.c.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 ... 118 119 120 121 122 123 124 125 126 127 128 129 130 131 ... 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 ... 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 ... 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 ... 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 ... 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 ... 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 ... 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 ... 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 ... 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 ... 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 ... 666 667 668 669 670 671 672 |
** Return the number of errors. No error messages are generated. */ static int getStat(const char *zFilename){ int rc = 0; if( zFilename==0 ){ if( fileStatValid==0 ) rc = 1; }else{ if( stat(zFilename, &fileStat)!=0 ){ fileStatValid = 0; rc = 1; }else{ fileStatValid = 1; rc = 0; } } return rc; } /* ** Return the size of a file in bytes. Return -1 if the file does not ................................................................................ rc = getStat(zFN); free(zFN); }else{ rc = getStat(0); } return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2); } /* ** Find an unused filename similar to zBase with zSuffix appended. ** ** Make the name relative to the working directory if relFlag is true. ** ** Space to hold the new filename is obtained form mprintf() and should ................................................................................ /* ** Copy the content of a file from one place to another. */ void file_copy(const char *zFrom, const char *zTo){ FILE *in, *out; int got; char zBuf[8192]; in = fopen(zFrom, "rb"); if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); out = fopen(zTo, "wb"); if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ fwrite(zBuf, 1, got, out); } fclose(in); fclose(out); } ................................................................................ chmod(zFilename, buf.st_mode & ~0111); rc = 1; } } #endif /* _WIN32 */ return rc; } /* ** Create the directory named in the argument, if it does not already ** exist. If forceFlag is 1, delete any prior non-directory object ** with the same name. ** ** Return the number of errors. */ int file_mkdir(const char *zName, int forceFlag){ int rc = file_isdir(zName); if( rc==2 ){ if( !forceFlag ) return 1; unlink(zName); } if( rc!=1 ){ #if defined(_WIN32) return mkdir(zName); #else return mkdir(zName, 0755); #endif } return 0; } ................................................................................ ** Print the simplified versions of each FILENAME. */ void cmd_test_simplify_name(void){ int i; char *z; for(i=2; i<g.argc; i++){ z = mprintf("%s", g.argv[i]); printf("[%s] -> ", z); file_simplify_name(z, -1); printf("[%s]\n", z); fossil_free(z); } } /* ** Compute a canonical pathname for a file or directory. ** Make the name absolute if it is relative. ................................................................................ #endif ){ blob_set(pOut, zOrigName); blob_materialize(pOut); }else{ char zPwd[2000]; if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); fossil_exit(1); } blob_zero(pOut); blob_appendf(pOut, "%//%/", zPwd, zOrigName); } blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); } ................................................................................ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ char zBuf[100]; const char *zName = g.argv[i]; file_canonical_name(zName, &x); printf("[%s] -> [%s]\n", zName, blob_buffer(&x)); blob_reset(&x); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName)); printf(" file_size = %s\n", zBuf); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName)); printf(" file_mtime = %s\n", zBuf); printf(" file_isfile = %d\n", file_isfile(zName)); printf(" file_isexe = %d\n", file_isexe(zName)); printf(" file_isdir = %d\n", file_isdir(zName)); } } /* ** Return TRUE if the given filename is canonical. ** ** Canonical names are full pathnames using "/" not "\" and which ................................................................................ blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); zPath = blob_buffer(pOut); if( zPath[0]=='/' ){ int i, j; Blob tmp; char zPwd[2000]; if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); fossil_exit(1); } for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){} if( zPath[i]==0 ){ blob_reset(pOut); if( zPwd[i]==0 ){ blob_append(pOut, ".", 1); }else{ ................................................................................ */ void cmd_test_relative_name(void){ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ file_relative_name(g.argv[i], &x); printf("%s\n", blob_buffer(&x)); blob_reset(&x); } } /* ** Compute a pathname for a file relative to the root of the local ** tree. Return TRUE on success. On failure, print and error ................................................................................ */ void cmd_test_tree_name(void){ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ if( file_tree_name(g.argv[i], &x, 1) ){ printf("%s\n", blob_buffer(&x)); blob_reset(&x); } } } /* ** Parse a URI into scheme, host, port, and path. ................................................................................ ".", }; static const unsigned char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; unsigned int i, j; struct stat buf; const char *zDir = "."; for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){ if( stat(azDirs[i], &buf) ) continue; if( !S_ISDIR(buf.st_mode) ) continue; if( access(azDirs[i], 07) ) continue; zDir = azDirs[i]; break; } /* Check that the output buffer is large enough for the temporary file ** name. If it is not, return SQLITE_ERROR. */ ................................................................................ sqlite3_snprintf(nBuf-17, zBuf, "%s/", zDir); j = (int)strlen(zBuf); sqlite3_randomness(15, &zBuf[j]); for(i=0; i<15; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; }while( access(zBuf,0)==0 ); } /* ** Return true if a file named zName exists and has identical content ** to the blob pContent. If zName does not exist or if the content is ** different in any way, then return false. ................................................................................ if( iSize<0 ) return 0; if( iSize!=blob_size(pContent) ) return 0; blob_read_from_file(&onDisk, zName); rc = blob_compare(&onDisk, pContent); blob_reset(&onDisk); return rc==0; } |
> | > > > > > > > > > > > | | > > > > > > > > > | > > > > | | | | < | | | | | | | < | | < | < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 ... 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 ... 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 ... 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 ... 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 ... 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 ... 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 ... 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 ... 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 ... 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 ... 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 ... 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 ... 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
** Return the number of errors. No error messages are generated. */ static int getStat(const char *zFilename){ int rc = 0; if( zFilename==0 ){ if( fileStatValid==0 ) rc = 1; }else{ char *zMbcs = fossil_utf8_to_mbcs(zFilename); if( stat(zMbcs, &fileStat)!=0 ){ fileStatValid = 0; rc = 1; }else{ fileStatValid = 1; rc = 0; } fossil_mbcs_free(zMbcs); } return rc; } /* ** Return the size of a file in bytes. Return -1 if the file does not ................................................................................ rc = getStat(zFN); free(zFN); }else{ rc = getStat(0); } return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2); } /* ** Wrapper around the access() system call. */ int file_access(const char *zFilename, int flags){ char *zMbcs = fossil_utf8_to_mbcs(zFilename); int rc = access(zMbcs, flags); fossil_mbcs_free(zMbcs); return rc; } /* ** Find an unused filename similar to zBase with zSuffix appended. ** ** Make the name relative to the working directory if relFlag is true. ** ** Space to hold the new filename is obtained form mprintf() and should ................................................................................ /* ** Copy the content of a file from one place to another. */ void file_copy(const char *zFrom, const char *zTo){ FILE *in, *out; int got; char zBuf[8192]; in = fossil_fopen(zFrom, "rb"); if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); out = fossil_fopen(zTo, "wb"); if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ fwrite(zBuf, 1, got, out); } fclose(in); fclose(out); } ................................................................................ chmod(zFilename, buf.st_mode & ~0111); rc = 1; } } #endif /* _WIN32 */ return rc; } /* ** Delete a file. */ void file_delete(const char *zFilename){ char *z = fossil_utf8_to_mbcs(zFilename); unlink(z); fossil_mbcs_free(z); } /* ** Create the directory named in the argument, if it does not already ** exist. If forceFlag is 1, delete any prior non-directory object ** with the same name. ** ** Return the number of errors. */ int file_mkdir(const char *zName, int forceFlag){ int rc = file_isdir(zName); if( rc==2 ){ if( !forceFlag ) return 1; file_delete(zName); } if( rc!=1 ){ #if defined(_WIN32) int rc; char *zMbcs = fossil_utf8_to_mbcs(zName); rc = mkdir(zMbcs); fossil_mbcs_free(zMbcs); return rc; #else return mkdir(zName, 0755); #endif } return 0; } ................................................................................ ** Print the simplified versions of each FILENAME. */ void cmd_test_simplify_name(void){ int i; char *z; for(i=2; i<g.argc; i++){ z = mprintf("%s", g.argv[i]); fossil_print("[%s] -> ", z); file_simplify_name(z, -1); fossil_print("[%s]\n", z); fossil_free(z); } } /* ** Compute a canonical pathname for a file or directory. ** Make the name absolute if it is relative. ................................................................................ #endif ){ blob_set(pOut, zOrigName); blob_materialize(pOut); }else{ char zPwd[2000]; if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20); } blob_zero(pOut); blob_appendf(pOut, "%//%/", zPwd, zOrigName); } blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); } ................................................................................ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ char zBuf[100]; const char *zName = g.argv[i]; file_canonical_name(zName, &x); fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x)); blob_reset(&x); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName)); fossil_print(" file_size = %s\n", zBuf); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName)); fossil_print(" file_mtime = %s\n", zBuf); fossil_print(" file_isfile = %d\n", file_isfile(zName)); fossil_print(" file_isexe = %d\n", file_isexe(zName)); fossil_print(" file_isdir = %d\n", file_isdir(zName)); } } /* ** Return TRUE if the given filename is canonical. ** ** Canonical names are full pathnames using "/" not "\" and which ................................................................................ blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); zPath = blob_buffer(pOut); if( zPath[0]=='/' ){ int i, j; Blob tmp; char zPwd[2000]; if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ fossil_fatal("pwd too big: max %d\n", (int)sizeof(zPwd)-20); } for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){} if( zPath[i]==0 ){ blob_reset(pOut); if( zPwd[i]==0 ){ blob_append(pOut, ".", 1); }else{ ................................................................................ */ void cmd_test_relative_name(void){ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ file_relative_name(g.argv[i], &x); fossil_print("%s\n", blob_buffer(&x)); blob_reset(&x); } } /* ** Compute a pathname for a file relative to the root of the local ** tree. Return TRUE on success. On failure, print and error ................................................................................ */ void cmd_test_tree_name(void){ int i; Blob x; blob_zero(&x); for(i=2; i<g.argc; i++){ if( file_tree_name(g.argv[i], &x, 1) ){ fossil_print("%s\n", blob_buffer(&x)); blob_reset(&x); } } } /* ** Parse a URI into scheme, host, port, and path. ................................................................................ ".", }; static const unsigned char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; unsigned int i, j; const char *zDir = "."; for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){ if( !file_isdir(azDirs[i]) ) continue; zDir = azDirs[i]; break; } /* Check that the output buffer is large enough for the temporary file ** name. If it is not, return SQLITE_ERROR. */ ................................................................................ sqlite3_snprintf(nBuf-17, zBuf, "%s/", zDir); j = (int)strlen(zBuf); sqlite3_randomness(15, &zBuf[j]); for(i=0; i<15; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; }while( file_size(zBuf)<0 ); } /* ** Return true if a file named zName exists and has identical content ** to the blob pContent. If zName does not exist or if the content is ** different in any way, then return false. ................................................................................ if( iSize<0 ) return 0; if( iSize!=blob_size(pContent) ) return 0; blob_read_from_file(&onDisk, zName); rc = blob_compare(&onDisk, pContent); blob_reset(&onDisk); return rc==0; } /************************************************************************** ** The following routines translate between MBCS and UTF8 on windows. ** Since everything is always UTF8 on unix, these routines are no-ops ** there. */ #ifdef _WIN32 # include <windows.h> #endif /* ** Translate MBCS to UTF8. Return a pointer to the translated text. ** Call fossil_mbcs_free() to deallocate any memory used to store the ** returned pointer when done. */ char *fossil_mbcs_to_utf8(const char *zMbcs){ #ifdef _WIN32 extern char *sqlite3_win32_mbcs_to_utf8(const char*); return sqlite3_win32_mbcs_to_utf8(zMbcs); #else return (char*)zMbcs; /* No-op on unix */ #endif } /* ** Translate UTF8 to MBCS for use in system calls. Return a pointer to the ** translated text.. Call fossil_mbcs_free() to deallocate any memory ** used to store the returned pointer when done. */ char *fossil_utf8_to_mbcs(const char *zUtf8){ #ifdef _WIN32 extern char *sqlite3_win32_utf8_to_mbcs(const char*); return sqlite3_win32_utf8_to_mbcs(zUtf8); #else return (char*)zUtf8; /* No-op on unix */ #endif } /* ** Translate UTF8 to MBCS for display on the console. Return a pointer to the ** translated text.. Call fossil_mbcs_free() to deallocate any memory ** used to store the returned pointer when done. */ char *fossil_utf8_to_console(const char *zUtf8){ #ifdef _WIN32 int nChar, nByte; WCHAR *zUnicode; /* Unicode version of zUtf8 */ char *zConsole; /* Console version of zUtf8 */ int codepage; /* Console code page */ nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0); zUnicode = malloc( nChar*sizeof(zUnicode[0]) ); if( zUnicode==0 ){ return 0; } nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); if( nChar==0 ){ free(zUnicode); return 0; } codepage = GetConsoleCP(); nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, 0, 0, 0, 0); zConsole = malloc( nByte ); if( zConsole==0 ){ free(zUnicode); return 0; } nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, zConsole, nByte, 0, 0); free(zUnicode); if( nByte == 0 ){ free(zConsole); zConsole = 0; } return zConsole; #else return (char*)zUtf8; /* No-op on unix */ #endif } /* ** Translate MBCS to UTF8. Return a pointer. Call fossil_mbcs_free() ** to deallocate any memory used to store the returned pointer when done. */ void fossil_mbcs_free(char *zOld){ #ifdef _WIN32 free(zOld); #else /* No-op on unix */ #endif } /* ** Like fopen() but always takes a UTF8 argument. */ FILE *fossil_fopen(const char *zName, const char *zMode){ char *zMbcs = fossil_utf8_to_mbcs(zName); FILE *f = fopen(zMbcs, zMode); fossil_mbcs_free(zMbcs); return f; } |
Changes to src/finfo.c.
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
blob_appendf(&line, " "); blob_appendf(&line, " %10.10s", blob_str(&uuid)); blob_reset(&uuid); }else{ blob_appendf(&line, "unknown 0000000000"); } db_finalize(&q); printf("%s\n", blob_str(&line)); blob_reset(&fname); blob_reset(&line); }else if( find_option("print","p",0) ){ Blob record; Blob fname; const char *zRevision = find_option("revision", "r", 1); ................................................................................ " AND event.objid=mlink.mid" " AND event.objid=ci.rid" " ORDER BY event.mtime DESC LIMIT %d OFFSET %d", zFilename, iLimit, iOffset ); blob_zero(&line); if( iBrief ){ printf("History of %s\n", blob_str(&fname)); } while( db_step(&q)==SQLITE_ROW ){ const char *zFileUuid = db_column_text(&q, 0); const char *zCiUuid = db_column_text(&q,1); const char *zDate = db_column_text(&q, 2); const char *zCom = db_column_text(&q, 3); const char *zUser = db_column_text(&q, 4); char *zOut; if( iBrief ){ printf("%s ", zDate); zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])", zCiUuid, zCom, zUser, zFileUuid); comment_print(zOut, 11, 79); sqlite3_free(zOut); }else{ blob_reset(&line); blob_appendf(&line, "%.10s ", zCiUuid); |
|
|
|
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
blob_appendf(&line, " "); blob_appendf(&line, " %10.10s", blob_str(&uuid)); blob_reset(&uuid); }else{ blob_appendf(&line, "unknown 0000000000"); } db_finalize(&q); fossil_print("%s\n", blob_str(&line)); blob_reset(&fname); blob_reset(&line); }else if( find_option("print","p",0) ){ Blob record; Blob fname; const char *zRevision = find_option("revision", "r", 1); ................................................................................ " AND event.objid=mlink.mid" " AND event.objid=ci.rid" " ORDER BY event.mtime DESC LIMIT %d OFFSET %d", zFilename, iLimit, iOffset ); blob_zero(&line); if( iBrief ){ fossil_print("History of %s\n", blob_str(&fname)); } while( db_step(&q)==SQLITE_ROW ){ const char *zFileUuid = db_column_text(&q, 0); const char *zCiUuid = db_column_text(&q,1); const char *zDate = db_column_text(&q, 2); const char *zCom = db_column_text(&q, 3); const char *zUser = db_column_text(&q, 4); char *zOut; if( iBrief ){ fossil_print("%s ", zDate); zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])", zCiUuid, zCom, zUser, zFileUuid); comment_print(zOut, 11, 79); sqlite3_free(zOut); }else{ blob_reset(&line); blob_appendf(&line, "%.10s ", zCiUuid); |
Changes to src/glob.c.
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
** PATTERN is a comma-separated list of glob patterns. Show which of ** the STRINGs that follow match the PATTERN. */ void glob_test_cmd(void){ Glob *pGlob; int i; if( g.argc<4 ) usage("PATTERN STRING ..."); printf("SQL expression: %s\n", glob_expr("x", g.argv[2])); pGlob = glob_create(g.argv[2]); for(i=0; i<pGlob->nPattern; i++){ printf("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]); } for(i=3; i<g.argc; i++){ printf("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]); } glob_free(pGlob); } |
| | | |
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
** PATTERN is a comma-separated list of glob patterns. Show which of ** the STRINGs that follow match the PATTERN. */ void glob_test_cmd(void){ Glob *pGlob; int i; if( g.argc<4 ) usage("PATTERN STRING ..."); fossil_print("SQL expression: %s\n", glob_expr("x", g.argv[2])); pGlob = glob_create(g.argv[2]); for(i=0; i<pGlob->nPattern; i++){ fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]); } for(i=3; i<g.argc; i++){ fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]); } glob_free(pGlob); } |
Changes to src/http_transport.c.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 ... 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
if( g.urlPort!=g.urlDfltPort ){ #ifdef __MINGW32__ blob_appendf(&zCmd, " -P %d", g.urlPort); #else blob_appendf(&zCmd, " -p %d", g.urlPort); #endif } printf("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ if( g.urlUser && g.urlUser[0] ){ zHost = mprintf("%s@%s", g.urlUser, g.urlName); #ifdef __MINGW32__ /* Only win32 (and specifically PLINK.EXE) support the -pw option */ if( g.urlPasswd && g.urlPasswd[0] ){ Blob pw; blob_zero(&pw); ................................................................................ free(zPrompt); }else{ blob_init(&pw, g.urlPasswd, -1); } blob_append(&zCmd, " -pw ", -1); shell_escape(&zCmd, blob_str(&pw)); blob_reset(&pw); printf(" -pw ********"); /* Do not show the password text */ } #endif }else{ zHost = mprintf("%s", g.urlName); } blob_append(&zCmd, " ", 1); shell_escape(&zCmd, zHost); printf(" %s\n", zHost); /* Show the conclusion of the SSH command */ free(zHost); popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid); if( sshPid==0 ){ fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd); } blob_reset(&zCmd); ................................................................................ ssl_close(); #endif }else if( g.urlIsFile ){ if( transport.pFile ){ fclose(transport.pFile); transport.pFile = 0; } unlink(transport.zInFile); unlink(transport.zOutFile); free(transport.zInFile); free(transport.zOutFile); }else{ socket_close(); } transport.isOpen = 0; } |
| | | | | |
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 ... 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
if( g.urlPort!=g.urlDfltPort ){ #ifdef __MINGW32__ blob_appendf(&zCmd, " -P %d", g.urlPort); #else blob_appendf(&zCmd, " -p %d", g.urlPort); #endif } fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ if( g.urlUser && g.urlUser[0] ){ zHost = mprintf("%s@%s", g.urlUser, g.urlName); #ifdef __MINGW32__ /* Only win32 (and specifically PLINK.EXE) support the -pw option */ if( g.urlPasswd && g.urlPasswd[0] ){ Blob pw; blob_zero(&pw); ................................................................................ free(zPrompt); }else{ blob_init(&pw, g.urlPasswd, -1); } blob_append(&zCmd, " -pw ", -1); shell_escape(&zCmd, blob_str(&pw)); blob_reset(&pw); fossil_print(" -pw ********"); /* Do not show the password text */ } #endif }else{ zHost = mprintf("%s", g.urlName); } blob_append(&zCmd, " ", 1); shell_escape(&zCmd, zHost); fossil_print(" %s\n", zHost); /* Show the conclusion of the SSH command */ free(zHost); popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid); if( sshPid==0 ){ fossil_fatal("cannot start ssh tunnel using [%b]", &zCmd); } blob_reset(&zCmd); ................................................................................ ssl_close(); #endif }else if( g.urlIsFile ){ if( transport.pFile ){ fclose(transport.pFile); transport.pFile = 0; } file_delete(transport.zInFile); file_delete(transport.zOutFile); free(transport.zInFile); free(transport.zOutFile); }else{ socket_close(); } transport.isOpen = 0; } |
Changes to src/import.c.
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 ... 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 ... 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
}else if( memcmp(zLine, "option", 6)==0 ){ gg.xFinish(); }else if( memcmp(zLine, "progress ", 9)==0 ){ gg.xFinish(); trim_newline(&zLine[9]); printf("%s\n", &zLine[9]); fflush(stdout); }else if( memcmp(zLine, "data ", 5)==0 ){ fossil_free(gg.aData); gg.aData = 0; gg.nData = atoi(&zLine[5]); if( gg.nData ){ int got; ................................................................................ if( g.argc==4 ){ pIn = fopen(g.argv[3], "rb"); }else{ pIn = stdin; fossil_binary_mode(pIn); } if( !incrFlag ){ if( forceFlag ) unlink(g.argv[2]); db_create_repository(g.argv[2]); } db_open_repository(g.argv[2]); db_open_config(0); /* The following temp-tables are used to hold information needed for ** the import. ................................................................................ db_ephemeral_blob(&q, 0, &record); fast_insert_content(&record, 0, 0); import_reset(0); } db_finalize(&q); db_end_transaction(0); db_begin_transaction(); printf("Rebuilding repository meta-data...\n"); rebuild_db(0, 1, !incrFlag); verify_cancel(); db_end_transaction(0); printf("Vacuuming..."); fflush(stdout); db_multi_exec("VACUUM"); printf(" ok\n"); if( !incrFlag ){ printf("project-id: %s\n", db_get("project-code", 0)); printf("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); printf("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); } } |
| | | | | | | | |
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 ... 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 ... 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
}else if( memcmp(zLine, "option", 6)==0 ){ gg.xFinish(); }else if( memcmp(zLine, "progress ", 9)==0 ){ gg.xFinish(); trim_newline(&zLine[9]); fossil_print("%s\n", &zLine[9]); fflush(stdout); }else if( memcmp(zLine, "data ", 5)==0 ){ fossil_free(gg.aData); gg.aData = 0; gg.nData = atoi(&zLine[5]); if( gg.nData ){ int got; ................................................................................ if( g.argc==4 ){ pIn = fopen(g.argv[3], "rb"); }else{ pIn = stdin; fossil_binary_mode(pIn); } if( !incrFlag ){ if( forceFlag ) file_delete(g.argv[2]); db_create_repository(g.argv[2]); } db_open_repository(g.argv[2]); db_open_config(0); /* The following temp-tables are used to hold information needed for ** the import. ................................................................................ db_ephemeral_blob(&q, 0, &record); fast_insert_content(&record, 0, 0); import_reset(0); } db_finalize(&q); db_end_transaction(0); db_begin_transaction(); fossil_print("Rebuilding repository meta-data...\n"); rebuild_db(0, 1, !incrFlag); verify_cancel(); db_end_transaction(0); fossil_print("Vacuuming..."); fflush(stdout); db_multi_exec("VACUUM"); fossil_print(" ok\n"); if( !incrFlag ){ fossil_print("project-id: %s\n", db_get("project-code", 0)); fossil_print("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); } } |
Changes to src/info.c.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 .. 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 ... 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); if( zUuid ){ zDate = db_text(0, "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", rid ); /* 01234567890123 */ printf("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : ""); free(zUuid); free(zDate); } if( zUuid && showComment ){ zComment = db_text(0, "SELECT coalesce(ecomment,comment) || " " ' (user: ' || coalesce(euser,user,'?') || ')' " ................................................................................ " WHERE cid=%d", rid); while( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); zDate = db_text("", "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", db_column_int(&q, 1) ); printf("parent: %s %s\n", zUuid, zDate); free(zDate); } db_finalize(&q); db_prepare(&q, "SELECT uuid, cid FROM plink JOIN blob ON cid=rid " " WHERE pid=%d", rid); while( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); zDate = db_text("", "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", db_column_int(&q, 1) ); printf("child: %s %s\n", zUuid, zDate); free(zDate); } db_finalize(&q); } zTags = info_tags_of_checkin(rid, 0); if( zTags && zTags[0] ){ printf("tags: %s\n", zTags); } free(zTags); if( zComment ){ printf("comment: "); comment_print(zComment, 14, 79); free(zComment); } } /* ................................................................................ if( g.argc!=2 && g.argc!=3 ){ usage("?FILENAME|ARTIFACT-ID?"); } if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){ db_open_config(0); db_record_repository_filename(g.argv[2]); db_open_repository(g.argv[2]); printf("project-name: %s\n", db_get("project-name", "<unnamed>")); printf("project-code: %s\n", db_get("project-code", "<none>")); printf("server-code: %s\n", db_get("server-code", "<none>")); return; } db_must_be_within_tree(); if( g.argc==2 ){ int vid; /* 012345678901234 */ db_record_repository_filename(0); printf("project-name: %s\n", db_get("project-name", "<unnamed>")); printf("repository: %s\n", db_lget("repository", "")); printf("local-root: %s\n", g.zLocalRoot); #if defined(_WIN32) if( g.zHome ){ printf("user-home: %s\n", g.zHome); } #endif printf("project-code: %s\n", db_get("project-code", "")); printf("server-code: %s\n", db_get("server-code", "")); vid = db_lget_int("checkout", 0); if( vid==0 ){ printf("checkout: nil\n"); }else{ show_common_info(vid, "checkout:", 1, 1); } }else{ int rid; rid = name_to_rid(g.argv[2]); if( rid==0 ){ |
| | | | | | | | | | | | | | | |
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 .. 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 ... 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); if( zUuid ){ zDate = db_text(0, "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", rid ); /* 01234567890123 */ fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : ""); free(zUuid); free(zDate); } if( zUuid && showComment ){ zComment = db_text(0, "SELECT coalesce(ecomment,comment) || " " ' (user: ' || coalesce(euser,user,'?') || ')' " ................................................................................ " WHERE cid=%d", rid); while( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); zDate = db_text("", "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", db_column_int(&q, 1) ); fossil_print("parent: %s %s\n", zUuid, zDate); free(zDate); } db_finalize(&q); db_prepare(&q, "SELECT uuid, cid FROM plink JOIN blob ON cid=rid " " WHERE pid=%d", rid); while( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); zDate = db_text("", "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", db_column_int(&q, 1) ); fossil_print("child: %s %s\n", zUuid, zDate); free(zDate); } db_finalize(&q); } zTags = info_tags_of_checkin(rid, 0); if( zTags && zTags[0] ){ fossil_print("tags: %s\n", zTags); } free(zTags); if( zComment ){ fossil_print("comment: "); comment_print(zComment, 14, 79); free(zComment); } } /* ................................................................................ if( g.argc!=2 && g.argc!=3 ){ usage("?FILENAME|ARTIFACT-ID?"); } if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){ db_open_config(0); db_record_repository_filename(g.argv[2]); db_open_repository(g.argv[2]); fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); fossil_print("project-code: %s\n", db_get("project-code", "<none>")); fossil_print("server-code: %s\n", db_get("server-code", "<none>")); return; } db_must_be_within_tree(); if( g.argc==2 ){ int vid; /* 012345678901234 */ db_record_repository_filename(0); fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); fossil_print("repository: %s\n", db_lget("repository", "")); fossil_print("local-root: %s\n", g.zLocalRoot); #if defined(_WIN32) if( g.zHome ){ fossil_print("user-home: %s\n", g.zHome); } #endif fossil_print("project-code: %s\n", db_get("project-code", "")); fossil_print("server-code: %s\n", db_get("server-code", "")); vid = db_lget_int("checkout", 0); if( vid==0 ){ fossil_print("checkout: nil\n"); }else{ show_common_info(vid, "checkout:", 1, 1); } }else{ int rid; rid = name_to_rid(g.argv[2]); if( rid==0 ){ |
Changes to src/main.c.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 ... 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 ... 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 ... 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 ... 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 ... 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 ... 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 ... 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 ... 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 ... 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 ... 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 ... 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 .... 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 .... 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 .... 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
/* ** This procedure runs first. */ int main(int argc, char **argv){ const char *zCmdName = "unknown"; int idx; int rc; sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); g.now = time(0); g.argc = argc; g.argv = argv; if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ zCmdName = "cgi"; }else if( argc<2 ){ fprintf(stderr, "Usage: %s COMMAND ...\n" "\"%s help\" for a list of available commands\n" "\"%s help COMMAND\" for specific details\n", argv[0], argv[0], argv[0]); fossil_exit(1); }else{ g.fQuiet = find_option("quiet", 0, 0)!=0; g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; g.fSqlStats = find_option("sqlstats", 0, 0)!=0; if( g.fSqlTrace ) g.fSqlStats = 1; g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; g.fHttpTrace = find_option("httptrace", 0, 0)!=0; ................................................................................ g.argc++; g.argv = zNewArgv; } zCmdName = g.argv[1]; } rc = name_search(zCmdName, aCommand, count(aCommand), &idx); if( rc==1 ){ fprintf(stderr,"%s: unknown command: %s\n" "%s: use \"help\" for more information\n", argv[0], zCmdName, argv[0]); fossil_exit(1); }else if( rc==2 ){ int i, n; Blob couldbe; blob_zero(&couldbe); n = strlen(zCmdName); for(i=0; i<count(aCommand); i++){ if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){ blob_appendf(&couldbe, " %s", aCommand[i].zName); } } fprintf(stderr,"%s: ambiguous command prefix: %s\n" "%s: could be any of:%s\n" "%s: use \"help\" for more information\n", argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]); fossil_exit(1); } aCommand[idx].xFunc(); fossil_exit(0); /*NOT_REACHED*/ return 0; } ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput && once ){ once = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z); } db_force_rollback(); fossil_exit(1); } void fossil_fatal(const char *zFormat, ...){ char *z; va_list ap; ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ g.cgiOutput = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z); } db_force_rollback(); fossil_exit(1); } /* This routine works like fossil_fatal() except that if called ** recursively, the recursive call is a no-op. ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ g.cgiOutput = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z); } db_force_rollback(); fossil_exit(1); } /* Print a warning message */ ................................................................................ va_list ap; va_start(ap, zFormat); z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ cgi_printf("<p class=\"generalError\">%h</p>", z); }else{ fprintf(stderr, "\r%s: %s\n", fossil_nameofexe(), z); } } /* ** Malloc and free routines that cannot fail */ void *fossil_malloc(size_t n){ ................................................................................ int fossil_system(const char *zOrigCmd){ int rc; #if defined(_WIN32) /* On windows, we have to put double-quotes around the entire command. ** Who knows why - this is just the way windows works. */ char *zNewCmd = mprintf("\"%s\"", zOrigCmd); rc = system(zNewCmd); free(zNewCmd); #else /* On unix, evaluate the command directly. */ rc = system(zOrigCmd); #endif return rc; ................................................................................ fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg); } /* ** Print a usage comment and quit */ void usage(const char *zFormat){ fprintf(stderr, "Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat); fossil_exit(1); } /* ** Remove n elements from g.argv beginning with the i-th element. */ void remove_from_argv(int i, int n){ int j; ................................................................................ } nCol = 80/(mxLen+2); if( nCol==0 ) nCol = 1; nRow = (nWord + nCol - 1)/nCol; for(i=0; i<nRow; i++){ const char *zSpacer = ""; for(j=i; j<nWord; j+=nRow){ printf("%s%-*s", zSpacer, mxLen, azWord[j]); zSpacer = " "; } printf("\n"); } } /* ** List of commands starting with zPrefix, or all commands if zPrefix is NULL. */ static void cmd_cmd_list(const char *zPrefix){ ................................................................................ ** COMMAND: version ** ** Usage: %fossil version ** ** Print the source code version number for the fossil executable. */ void version_cmd(void){ printf("This is fossil version " MANIFEST_VERSION " " MANIFEST_DATE " UTC\n"); } /* ** COMMAND: help ** ** Usage: %fossil help COMMAND ................................................................................ ** ** Display information on how to use COMMAND */ void help_cmd(void){ int rc, idx; const char *z; if( g.argc<3 ){ printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", fossil_nameofexe()); cmd_cmd_list(0); version_cmd(); return; } rc = name_search(g.argv[2], aCommand, count(aCommand), &idx); if( rc==1 ){ fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]); ................................................................................ z = aCmdHelp[idx]; if( z==0 ){ fossil_fatal("no help available for the %s command", aCommand[idx].zName); } while( *z ){ if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){ printf("%s", fossil_nameofexe()); z += 7; }else{ putchar(*z); z++; } } putchar('\n'); ................................................................................ if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost); g.cgiOutput = 1; if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ fossil_fatal("no repository specified"); } g.fullHttpReply = 1; if( g.argc==6 ){ g.httpIn = fopen(g.argv[3], "rb"); g.httpOut = fopen(g.argv[4], "wb"); zIpAddr = g.argv[5]; }else{ g.httpIn = stdin; g.httpOut = stdout; zIpAddr = 0; } find_server_repository(0); ................................................................................ char *zFull; int i; int bExists; while( zPath && zPath[0] ){ while( zPath[0]==':' ) zPath++; for(i=0; zPath[i] && zPath[i]!=':'; i++){} zFull = mprintf("%.*s/%s", i, zPath, zBinary); bExists = access(zFull, X_OK); free(zFull); if( bExists==0 ) return 1; zPath += i; } return 0; } #endif ................................................................................ ** ** Echo all command-line arguments (enclosed in [...]) to the screen so that ** wildcard expansion behavior of the host shell can be investigated. */ void test_echo_cmd(void){ int i; for(i=0; i<g.argc; i++){ printf("argv[%d] = [%s]\n", i, g.argv[i]); } } |
> > | | | | < | | < | | | | < | > | > | > | > > > | > | < | | > | | | | | | | | |
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 ... 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 ... 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 ... 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 ... 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 ... 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 ... 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 ... 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 ... 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 ... 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 ... 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 ... 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 .... 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 .... 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 .... 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 |
/* ** This procedure runs first. */ int main(int argc, char **argv){ const char *zCmdName = "unknown"; int idx; int rc; int i; sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); g.now = time(0); g.argc = argc; g.argv = argv; for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]); if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ zCmdName = "cgi"; }else if( argc<2 ){ fossil_fatal("Usage: %s COMMAND ...\n" "\"%s help\" for a list of available commands\n" "\"%s help COMMAND\" for specific details\n", argv[0], argv[0], argv[0]); }else{ g.fQuiet = find_option("quiet", 0, 0)!=0; g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; g.fSqlStats = find_option("sqlstats", 0, 0)!=0; if( g.fSqlTrace ) g.fSqlStats = 1; g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; g.fHttpTrace = find_option("httptrace", 0, 0)!=0; ................................................................................ g.argc++; g.argv = zNewArgv; } zCmdName = g.argv[1]; } rc = name_search(zCmdName, aCommand, count(aCommand), &idx); if( rc==1 ){ fossil_fatal("%s: unknown command: %s\n" "%s: use \"help\" for more information\n", argv[0], zCmdName, argv[0]); }else if( rc==2 ){ int i, n; Blob couldbe; blob_zero(&couldbe); n = strlen(zCmdName); for(i=0; i<count(aCommand); i++){ if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){ blob_appendf(&couldbe, " %s", aCommand[i].zName); } } fossil_fatal("%s: ambiguous command prefix: %s\n" "%s: could be any of:%s\n" "%s: use \"help\" for more information\n", argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]); } aCommand[idx].xFunc(); fossil_exit(0); /*NOT_REACHED*/ return 0; } ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput && once ){ once = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z); fossil_puts(zOut, 1); } db_force_rollback(); fossil_exit(1); } void fossil_fatal(const char *zFormat, ...){ char *z; va_list ap; ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ g.cgiOutput = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z); fossil_puts(zOut, 1); } db_force_rollback(); fossil_exit(1); } /* This routine works like fossil_fatal() except that if called ** recursively, the recursive call is a no-op. ................................................................................ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ g.cgiOutput = 0; cgi_printf("<p class=\"generalError\">%h</p>", z); cgi_reply(); }else{ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z); fossil_puts(zOut, 1); } db_force_rollback(); fossil_exit(1); } /* Print a warning message */ ................................................................................ va_list ap; va_start(ap, zFormat); z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiOutput ){ cgi_printf("<p class=\"generalError\">%h</p>", z); }else{ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z); fossil_puts(zOut, 1); free(zOut); } } /* ** Malloc and free routines that cannot fail */ void *fossil_malloc(size_t n){ ................................................................................ int fossil_system(const char *zOrigCmd){ int rc; #if defined(_WIN32) /* On windows, we have to put double-quotes around the entire command. ** Who knows why - this is just the way windows works. */ char *zNewCmd = mprintf("\"%s\"", zOrigCmd); char *zMbcs = fossil_utf8_to_mbcs(zNewCmd); rc = system(zMbcs); fossil_mbcs_free(zMbcs); free(zNewCmd); #else /* On unix, evaluate the command directly. */ rc = system(zOrigCmd); #endif return rc; ................................................................................ fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg); } /* ** Print a usage comment and quit */ void usage(const char *zFormat){ fossil_fatal("Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat); } /* ** Remove n elements from g.argv beginning with the i-th element. */ void remove_from_argv(int i, int n){ int j; ................................................................................ } nCol = 80/(mxLen+2); if( nCol==0 ) nCol = 1; nRow = (nWord + nCol - 1)/nCol; for(i=0; i<nRow; i++){ const char *zSpacer = ""; for(j=i; j<nWord; j+=nRow){ fossil_print("%s%-*s", zSpacer, mxLen, azWord[j]); zSpacer = " "; } fossil_print("\n"); } } /* ** List of commands starting with zPrefix, or all commands if zPrefix is NULL. */ static void cmd_cmd_list(const char *zPrefix){ ................................................................................ ** COMMAND: version ** ** Usage: %fossil version ** ** Print the source code version number for the fossil executable. */ void version_cmd(void){ fossil_print("This is fossil version " MANIFEST_VERSION " " MANIFEST_DATE " UTC\n"); } /* ** COMMAND: help ** ** Usage: %fossil help COMMAND ................................................................................ ** ** Display information on how to use COMMAND */ void help_cmd(void){ int rc, idx; const char *z; if( g.argc<3 ){ fossil_print("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", fossil_nameofexe()); cmd_cmd_list(0); version_cmd(); return; } rc = name_search(g.argv[2], aCommand, count(aCommand), &idx); if( rc==1 ){ fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]); ................................................................................ z = aCmdHelp[idx]; if( z==0 ){ fossil_fatal("no help available for the %s command", aCommand[idx].zName); } while( *z ){ if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){ fossil_print("%s", fossil_nameofexe()); z += 7; }else{ putchar(*z); z++; } } putchar('\n'); ................................................................................ if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost); g.cgiOutput = 1; if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ fossil_fatal("no repository specified"); } g.fullHttpReply = 1; if( g.argc==6 ){ g.httpIn = fossil_fopen(g.argv[3], "rb"); g.httpOut = fossil_fopen(g.argv[4], "wb"); zIpAddr = g.argv[5]; }else{ g.httpIn = stdin; g.httpOut = stdout; zIpAddr = 0; } find_server_repository(0); ................................................................................ char *zFull; int i; int bExists; while( zPath && zPath[0] ){ while( zPath[0]==':' ) zPath++; for(i=0; zPath[i] && zPath[i]!=':'; i++){} zFull = mprintf("%.*s/%s", i, zPath, zBinary); bExists = file_access(zFull, X_OK); free(zFull); if( bExists==0 ) return 1; zPath += i; } return 0; } #endif ................................................................................ ** ** Echo all command-line arguments (enclosed in [...]) to the screen so that ** wildcard expansion behavior of the host shell can be investigated. */ void test_echo_cmd(void){ int i; for(i=0; i<g.argc; i++){ fossil_print("argv[%d] = [%s]\n", i, g.argv[i]); } } |
Changes to src/main.mk.
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c $(OBJDIR)/zip.h: $(OBJDIR)/headers $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT2 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o $(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o $(OBJDIR)/th.o: $(SRCDIR)/th.c $(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c $(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o |
| |
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
$(OBJDIR)/zip.h: $(OBJDIR)/headers
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
$(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT2 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c
$(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dfopen=fossil_fopen -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -I$(SRCDIR) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
|
Changes to src/makemake.tcl.
248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0" set SQLITE_OPTIONS $opt writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n" writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c" set opt {-Dmain=sqlite3_shell} append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1" writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n" writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c" writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n" writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c" writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n" |
> |
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
set SQLITE_OPTIONS $opt
writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c"
set opt {-Dmain=sqlite3_shell}
append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
append opt " -Dfopen=fossil_fopen"
writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
writeln "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n"
|
Changes to src/md5.c.
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
...
436
437
438
439
440
441
442
443
444
445
446
|
*/ int md5sum_file(const char *zFilename, Blob *pCksum){ FILE *in; MD5Context ctx; unsigned char zResult[16]; char zBuf[10240]; in = fopen(zFilename,"rb"); if( in==0 ){ return 1; } MD5Init(&ctx); for(;;){ int n; n = fread(zBuf, 1, sizeof(zBuf), in); ................................................................................ for(i=2; i<g.argc; i++){ if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ blob_read_from_channel(&in, stdin, -1); md5sum_blob(&in, &cksum); }else{ md5sum_file(g.argv[i], &cksum); } printf("%s %s\n", blob_str(&cksum), g.argv[i]); blob_reset(&cksum); } } |
|
|
|
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
...
436
437
438
439
440
441
442
443
444
445
446
|
*/ int md5sum_file(const char *zFilename, Blob *pCksum){ FILE *in; MD5Context ctx; unsigned char zResult[16]; char zBuf[10240]; in = fossil_fopen(zFilename,"rb"); if( in==0 ){ return 1; } MD5Init(&ctx); for(;;){ int n; n = fread(zBuf, 1, sizeof(zBuf), in); ................................................................................ for(i=2; i<g.argc; i++){ if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ blob_read_from_channel(&in, stdin, -1); md5sum_blob(&in, &cksum); }else{ md5sum_file(g.argv[i], &cksum); } fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); blob_reset(&cksum); } } |
Changes to src/merge.c.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 ... 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 ... 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 ... 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 ... 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 ... 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 ... 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 ... 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
); if( debugFlag ){ db_prepare(&q, "SELECT rowid, fn, fnp, fnm, chnged, ridv, ridp, ridm, isexe FROM fv" ); while( db_step(&q)==SQLITE_ROW ){ printf("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n", db_column_int(&q, 0), db_column_int(&q, 5), db_column_int(&q, 6), db_column_int(&q, 7), db_column_int(&q, 4), db_column_int(&q, 8)); printf(" fn = [%s]\n", db_column_text(&q, 1)); printf(" fnp = [%s]\n", db_column_text(&q, 2)); printf(" fnm = [%s]\n", db_column_text(&q, 3)); } db_finalize(&q); } /* ** Find files in M and V but not in P and report conflicts. ** The file in M will be ignored. It will be treated as if it ................................................................................ */ db_prepare(&q, "SELECT idm FROM fv WHERE idp=0 AND idv>0 AND idm>0" ); while( db_step(&q)==SQLITE_ROW ){ int idm = db_column_int(&q, 0); char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idm); printf("WARNING - no common ancestor: %s\n", zName); free(zName); db_multi_exec("UPDATE fv SET idm=0 WHERE idm=%d", idm); } db_finalize(&q); /* ** Add to V files that are not in V or P but are in M ................................................................................ "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,pathname)" " SELECT %d,3,0,rid,mrid,isexe,pathname FROM vfile WHERE id=%d", vid, idm ); idv = db_last_insert_rowid(); db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid); zName = db_column_text(&q, 2); printf("ADDED %s\n", zName); if( !nochangeFlag ){ undo_save(zName); vfile_to_disk(0, idm, 0, 0); } } db_finalize(&q); ................................................................................ " AND ridm!=ridp AND ridv=ridp AND NOT chnged" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); int ridm = db_column_int(&q, 1); const char *zName = db_column_text(&q, 2); /* Copy content from idm over into idv. Overwrite idv. */ printf("UPDATE %s\n", zName); if( !nochangeFlag ){ undo_save(zName); db_multi_exec( "UPDATE vfile SET mtime=0, mrid=%d, chnged=2 WHERE id=%d", ridm, idv ); vfile_to_disk(0, idv, 0, 0); } ................................................................................ const char *zName = db_column_text(&q, 5); int isExe = db_column_int(&q, 6); int rc; char *zFullPath; Blob m, p, r; /* Do a 3-way merge of idp->idm into idp->idv. The results go into idv. */ if( detailFlag ){ printf("MERGE %s (pivot=%d v1=%d v2=%d)\n", zName, ridp, ridm, ridv); }else{ printf("MERGE %s\n", zName); } undo_save(zName); zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); content_get(ridp, &p); content_get(ridm, &m); if( isBinary ){ rc = -1; ................................................................................ if( rc>=0 ){ if( !nochangeFlag ){ blob_write_to_file(&r, zFullPath); file_setexe(zFullPath, isExe); } db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); if( rc>0 ){ printf("***** %d merge conflicts in %s\n", rc, zName); nConflict++; } }else{ printf("***** Cannot merge binary file %s\n", zName); nConflict++; } blob_reset(&p); blob_reset(&m); blob_reset(&r); db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(%d,%d)", idv,ridm); ................................................................................ " WHERE idp>0 AND idv>0 AND idm=0" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); const char *zName = db_column_text(&q, 1); int chnged = db_column_int(&q, 2); /* Delete the file idv */ printf("DELETE %s\n", zName); if( chnged ){ printf("WARNING: local edits lost for %s\n", zName); nConflict++; } undo_save(zName); db_multi_exec( "UPDATE vfile SET deleted=1 WHERE id=%d", idv ); if( !nochangeFlag ){ char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName); unlink(zFullPath); free(zFullPath); } } db_finalize(&q); /* ** Rename files that have taken a rename on P->M but which keep the same ................................................................................ "SELECT idv, fnp, fnm FROM fv" " WHERE idv>0 AND idp>0 AND idm>0 AND fnp=fn AND fnm!=fnp" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); const char *zOldName = db_column_text(&q, 1); const char *zNewName = db_column_text(&q, 2); printf("RENAME %s -> %s\n", zOldName, zNewName); undo_save(zOldName); undo_save(zNewName); db_multi_exec( "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)" " WHERE id=%d AND vid=%d", zNewName, idv, vid ); if( !nochangeFlag ){ char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); file_copy(zFullOldPath, zFullNewPath); unlink(zFullOldPath); free(zFullNewPath); free(zFullOldPath); } } db_finalize(&q); /* Report on conflicts */ if( nConflict && !nochangeFlag ){ printf("WARNING: merge conflicts - see messages above for details.\n"); } /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid); if( !pickFlag ){ db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid); } undo_finish(); db_end_transaction(nochangeFlag); } |
| | | | | | | | > | | | | | | | | > | |
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 ... 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 ... 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 ... 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 ... 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 ... 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 ... 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 ... 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
); if( debugFlag ){ db_prepare(&q, "SELECT rowid, fn, fnp, fnm, chnged, ridv, ridp, ridm, isexe FROM fv" ); while( db_step(&q)==SQLITE_ROW ){ fossil_print("%3d: ridv=%-4d ridp=%-4d ridm=%-4d chnged=%d isexe=%d\n", db_column_int(&q, 0), db_column_int(&q, 5), db_column_int(&q, 6), db_column_int(&q, 7), db_column_int(&q, 4), db_column_int(&q, 8)); fossil_print(" fn = [%s]\n", db_column_text(&q, 1)); fossil_print(" fnp = [%s]\n", db_column_text(&q, 2)); fossil_print(" fnm = [%s]\n", db_column_text(&q, 3)); } db_finalize(&q); } /* ** Find files in M and V but not in P and report conflicts. ** The file in M will be ignored. It will be treated as if it ................................................................................ */ db_prepare(&q, "SELECT idm FROM fv WHERE idp=0 AND idv>0 AND idm>0" ); while( db_step(&q)==SQLITE_ROW ){ int idm = db_column_int(&q, 0); char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idm); fossil_warning("WARNING - no common ancestor: %s\n", zName); free(zName); db_multi_exec("UPDATE fv SET idm=0 WHERE idm=%d", idm); } db_finalize(&q); /* ** Add to V files that are not in V or P but are in M ................................................................................ "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,pathname)" " SELECT %d,3,0,rid,mrid,isexe,pathname FROM vfile WHERE id=%d", vid, idm ); idv = db_last_insert_rowid(); db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid); zName = db_column_text(&q, 2); fossil_print("ADDED %s\n", zName); if( !nochangeFlag ){ undo_save(zName); vfile_to_disk(0, idm, 0, 0); } } db_finalize(&q); ................................................................................ " AND ridm!=ridp AND ridv=ridp AND NOT chnged" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); int ridm = db_column_int(&q, 1); const char *zName = db_column_text(&q, 2); /* Copy content from idm over into idv. Overwrite idv. */ fossil_print("UPDATE %s\n", zName); if( !nochangeFlag ){ undo_save(zName); db_multi_exec( "UPDATE vfile SET mtime=0, mrid=%d, chnged=2 WHERE id=%d", ridm, idv ); vfile_to_disk(0, idv, 0, 0); } ................................................................................ const char *zName = db_column_text(&q, 5); int isExe = db_column_int(&q, 6); int rc; char *zFullPath; Blob m, p, r; /* Do a 3-way merge of idp->idm into idp->idv. The results go into idv. */ if( detailFlag ){ fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n", zName, ridp, ridm, ridv); }else{ fossil_print("MERGE %s\n", zName); } undo_save(zName); zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); content_get(ridp, &p); content_get(ridm, &m); if( isBinary ){ rc = -1; ................................................................................ if( rc>=0 ){ if( !nochangeFlag ){ blob_write_to_file(&r, zFullPath); file_setexe(zFullPath, isExe); } db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); if( rc>0 ){ fossil_print("***** %d merge conflicts in %s\n", rc, zName); nConflict++; } }else{ fossil_print("***** Cannot merge binary file %s\n", zName); nConflict++; } blob_reset(&p); blob_reset(&m); blob_reset(&r); db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(%d,%d)", idv,ridm); ................................................................................ " WHERE idp>0 AND idv>0 AND idm=0" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); const char *zName = db_column_text(&q, 1); int chnged = db_column_int(&q, 2); /* Delete the file idv */ fossil_print("DELETE %s\n", zName); if( chnged ){ fossil_warning("WARNING: local edits lost for %s\n", zName); nConflict++; } undo_save(zName); db_multi_exec( "UPDATE vfile SET deleted=1 WHERE id=%d", idv ); if( !nochangeFlag ){ char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName); file_delete(zFullPath); free(zFullPath); } } db_finalize(&q); /* ** Rename files that have taken a rename on P->M but which keep the same ................................................................................ "SELECT idv, fnp, fnm FROM fv" " WHERE idv>0 AND idp>0 AND idm>0 AND fnp=fn AND fnm!=fnp" ); while( db_step(&q)==SQLITE_ROW ){ int idv = db_column_int(&q, 0); const char *zOldName = db_column_text(&q, 1); const char *zNewName = db_column_text(&q, 2); fossil_print("RENAME %s -> %s\n", zOldName, zNewName); undo_save(zOldName); undo_save(zNewName); db_multi_exec( "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)" " WHERE id=%d AND vid=%d", zNewName, idv, vid ); if( !nochangeFlag ){ char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); file_copy(zFullOldPath, zFullNewPath); file_delete(zFullOldPath); free(zFullNewPath); free(zFullOldPath); } } db_finalize(&q); /* Report on conflicts */ if( nConflict && !nochangeFlag ){ fossil_warning( "WARNING: merge conflicts - see messages above for details.\n"); } /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid); if( !pickFlag ){ db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid); } undo_finish(); db_end_transaction(nochangeFlag); } |
Changes to src/merge3.c.
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
...
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
*/ void delta_3waymerge_cmd(void){ Blob pivot, v1, v2, merged; if( g.argc!=6 ){ usage("PIVOT V1 V2 MERGED"); } if( blob_read_from_file(&pivot, g.argv[2])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[2]); fossil_exit(1); } if( blob_read_from_file(&v1, g.argv[3])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[3]); fossil_exit(1); } if( blob_read_from_file(&v2, g.argv[4])<0 ){ fprintf(stderr,"cannot read %s\n", g.argv[4]); fossil_exit(1); } blob_merge(&pivot, &v1, &v2, &merged); if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ fprintf(stderr,"cannot write %s\n", g.argv[4]); fossil_exit(1); } blob_reset(&pivot); blob_reset(&v1); blob_reset(&v2); blob_reset(&merged); } ................................................................................ azSubst[4] = "%merge"; azSubst[5] = zOther; azSubst[6] = "%output"; azSubst[7] = zOut; zCmd = string_subst(zGMerge, 8, azSubst); printf("%s\n", zCmd); fflush(stdout); fossil_system(zCmd); if( file_size(zOut)>=0 ){ blob_read_from_file(pOut, zOut); unlink(zPivot); unlink(zOrig); unlink(zOther); unlink(zOut); } fossil_free(zCmd); fossil_free(zOut); } fossil_free(zPivot); fossil_free(zOrig); fossil_free(zOther); } blob_reset(&v1); return rc; } |
|
<
|
<
|
<
|
<
|
|
|
|
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
*/ void delta_3waymerge_cmd(void){ Blob pivot, v1, v2, merged; if( g.argc!=6 ){ usage("PIVOT V1 V2 MERGED"); } if( blob_read_from_file(&pivot, g.argv[2])<0 ){ fossil_fatal("cannot read %s\n", g.argv[2]); } if( blob_read_from_file(&v1, g.argv[3])<0 ){ fossil_fatal("cannot read %s\n", g.argv[3]); } if( blob_read_from_file(&v2, g.argv[4])<0 ){ fossil_fatal("cannot read %s\n", g.argv[4]); } blob_merge(&pivot, &v1, &v2, &merged); if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ fossil_fatal("cannot write %s\n", g.argv[4]); } blob_reset(&pivot); blob_reset(&v1); blob_reset(&v2); blob_reset(&merged); } ................................................................................ azSubst[4] = "%merge"; azSubst[5] = zOther; azSubst[6] = "%output"; azSubst[7] = zOut; zCmd = string_subst(zGMerge, 8, azSubst); printf("%s\n", zCmd); fflush(stdout); fossil_system(zCmd); if( file_size(zOut)>=0 ){ blob_read_from_file(pOut, zOut); file_delete(zPivot); file_delete(zOrig); file_delete(zOther); file_delete(zOut); } fossil_free(zCmd); fossil_free(zOut); } fossil_free(zPivot); fossil_free(zOrig); fossil_free(zOther); } blob_reset(&v1); return rc; } |
Changes to src/name.c.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
*/ void test_name_to_id(void){ int i; Blob name; db_must_be_within_tree(); for(i=2; i<g.argc; i++){ blob_init(&name, g.argv[i], -1); printf("%s -> ", g.argv[i]); if( name_to_uuid(&name, 1) ){ printf("ERROR: %s\n", g.zErrMsg); fossil_error_reset(); }else{ printf("%s\n", blob_buffer(&name)); } blob_reset(&name); } } /* ** Convert a name to a rid. If the name is a small integer value then |
| | | |
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
*/ void test_name_to_id(void){ int i; Blob name; db_must_be_within_tree(); for(i=2; i<g.argc; i++){ blob_init(&name, g.argv[i], -1); fossil_print("%s -> ", g.argv[i]); if( name_to_uuid(&name, 1) ){ fossil_print("ERROR: %s\n", g.zErrMsg); fossil_error_reset(); }else{ fossil_print("%s\n", blob_buffer(&name)); } blob_reset(&name); } } /* ** Convert a name to a rid. If the name is a small integer value then |
Changes to src/path.c.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 ... 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 ... 443 444 445 446 447 448 449 450 451 452 453 454 455 |
for(n=1, p=path.pStart; p; p=p->u.pTo, n++){ char *z; z = db_text(0, "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" " FROM blob, event" " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", p->rid, p->rid); printf("%4d: %s", n, z); fossil_free(z); if( p->u.pTo ){ printf(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child"); }else{ printf("\n"); } } } /* ** Find the closest common ancestor of two nodes. "Closest" means the ** fewest number of arcs. ................................................................................ for(n=1, p=path.pStart; p; p=p->u.pTo, n++){ char *z; z = db_text(0, "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" " FROM blob, event" " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", p->rid, p->rid); printf("%4d: %s", n, z); fossil_free(z); if( p->rid==iFrom ) printf(" VERSION1"); if( p->rid==iTo ) printf(" VERSION2"); if( p->rid==iPivot ) printf(" PIVOT"); printf("\n"); } } /* ** A record of a file rename operation. */ ................................................................................ iTo = name_to_rid(g.argv[3]); find_filename_changes(iFrom, iTo, &nChng, &aChng); for(i=0; i<nChng; i++){ char *zFrom, *zTo; zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]); zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]); printf("[%s] -> [%s]\n", zFrom, zTo); fossil_free(zFrom); fossil_free(zTo); } fossil_free(aChng); } |
| > | | | | | | | | |
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 ... 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 ... 444 445 446 447 448 449 450 451 452 453 454 455 456 |
for(n=1, p=path.pStart; p; p=p->u.pTo, n++){ char *z; z = db_text(0, "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" " FROM blob, event" " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", p->rid, p->rid); fossil_print("%4d: %s", n, z); fossil_free(z); if( p->u.pTo ){ fossil_print(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child"); }else{ fossil_print("\n"); } } } /* ** Find the closest common ancestor of two nodes. "Closest" means the ** fewest number of arcs. ................................................................................ for(n=1, p=path.pStart; p; p=p->u.pTo, n++){ char *z; z = db_text(0, "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" " FROM blob, event" " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", p->rid, p->rid); fossil_print("%4d: %s", n, z); fossil_free(z); if( p->rid==iFrom ) fossil_print(" VERSION1"); if( p->rid==iTo ) fossil_print(" VERSION2"); if( p->rid==iPivot ) fossil_print(" PIVOT"); fossil_print("\n"); } } /* ** A record of a file rename operation. */ ................................................................................ iTo = name_to_rid(g.argv[3]); find_filename_changes(iFrom, iTo, &nChng, &aChng); for(i=0; i<nChng; i++){ char *zFrom, *zTo; zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]); zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]); fossil_print("[%s] -> [%s]\n", zFrom, zTo); fossil_free(zFrom); fossil_free(zTo); } fossil_free(aChng); } |
Changes to src/printf.c.
795
796
797
798
799
800
801
802
803
804
805
806
807
808
...
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
|
g.iErrPriority = iPriority; } void fossil_error_reset(void){ free(g.zErrMsg); g.zErrMsg = 0; g.iErrPriority = 0; } /* ** Write output for user consumption. If g.cgiOutput is enabled, then ** send the output as part of the CGI reply. If g.cgiOutput is false, ** then write on standard output. */ void fossil_print(const char *zFormat, ...){ ................................................................................ va_list ap; va_start(ap, zFormat); if( g.cgiOutput ){ cgi_vprintf(zFormat, ap); }else{ Blob b = empty_blob; vxprintf(&b, zFormat, ap); fwrite(blob_buffer(&b), 1, blob_size(&b), stdout); blob_reset(&b); } } /* ** Case insensitive string comparison. */ |
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
...
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
|
g.iErrPriority = iPriority; } void fossil_error_reset(void){ free(g.zErrMsg); g.zErrMsg = 0; g.iErrPriority = 0; } /* ** Write to standard output or standard error. ** ** On windows, transform the output into the current terminal encoding ** if the output is going to the screen. If output is redirected into ** a file, no translation occurs. No translation ever occurs on unix. */ void fossil_puts(const char *z, int toStdErr){ #if defined(_WIN32) static int once = 1; static int istty[2]; char *zToFree = 0; if( once ){ istty[0] = _isatty(fileno(stdout)); istty[1] = _isatty(fileno(stderr)); once = 0; } assert( toStdErr==0 || toStdErr==1 ); if( istty[toStdErr] ) z = zToFree = fossil_utf8_to_console(z); fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); free(zToFree); #else fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); #endif } /* ** Write output for user consumption. If g.cgiOutput is enabled, then ** send the output as part of the CGI reply. If g.cgiOutput is false, ** then write on standard output. */ void fossil_print(const char *zFormat, ...){ ................................................................................ va_list ap; va_start(ap, zFormat); if( g.cgiOutput ){ cgi_vprintf(zFormat, ap); }else{ Blob b = empty_blob; vxprintf(&b, zFormat, ap); fossil_puts(blob_str(&b), 0); blob_reset(&b); } } /* ** Case insensitive string comparison. */ |
Changes to src/rebuild.c.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 ... 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 ... 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 ... 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 ... 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 ... 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 ... 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 ... 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 ... 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 ... 962 963 964 965 966 967 968 969 970 971 972 973 974 975 |
/* ** Draw the percent-complete message. ** The input is actually the permill complete. */ static void percent_complete(int permill){ static int lastOutput = -1; if( permill>lastOutput ){ printf(" %d.%d%% complete...\r", permill/10, permill%10); fflush(stdout); lastOutput = permill; } } /* ................................................................................ } if( doClustering ) create_cluster(); if( !g.fQuiet && totalSize>0 ){ processCnt += incrSize; percent_complete((processCnt*1000)/totalSize); } if(!g.fQuiet && ttyOutput ){ printf("\n"); } return errCnt; } /* ** Attempt to convert more full-text blobs into delta-blobs for ** storage efficiency. ................................................................................ errCnt = rebuild_db(randomizeFlag, 1, doClustering); db_multi_exec( "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());" "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());", CONTENT_SCHEMA, AUX_SCHEMA ); if( errCnt && !forceFlag ){ printf("%d errors. Rolling back changes. Use --force to force a commit.\n", errCnt); db_end_transaction(1); }else{ if( runCompress ){ printf("Extra delta compression... "); fflush(stdout); extra_deltification(); runVacuum = 1; } if( omitVerify ) verify_cancel(); db_end_transaction(0); if( runCompress ) printf("done\n"); db_close(0); db_open_repository(g.zRepositoryName); if( newPagesize ){ db_multi_exec("PRAGMA page_size=%d", newPagesize); runVacuum = 1; } if( runVacuum ){ printf("Vacuuming the database... "); fflush(stdout); db_multi_exec("VACUUM"); printf("done\n"); } if( activateWal ){ db_multi_exec("PRAGMA journal_mode=WAL;"); } } } ................................................................................ } } manifest_destroy(p); } n = db_int(0, "SELECT count(*) FROM /*scan*/" " (SELECT rid FROM blob EXCEPT SELECT x FROM xdone)"); if( n==0 ){ printf("all artifacts reachable through clusters\n"); }else{ printf("%d unreachable artifacts:\n", n); db_prepare(&q, "SELECT rid, uuid FROM blob WHERE rid NOT IN xdone"); while( db_step(&q)==SQLITE_ROW ){ printf(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1)); } db_finalize(&q); } } /* ** COMMAND: scrub ................................................................................ fossil_panic("some unknown error occurred while reading \"%s\"", blob_str(&path)); } content_put(&aContent); blob_reset(&path); blob_reset(&aContent); free(zSubpath); printf("\r%d", ++nFileRead); fflush(stdout); } closedir(d); }else { fossil_panic("encountered error %d while trying to open \"%s\".", errno, g.argv[3]); } ................................................................................ */ void reconstruct_cmd(void) { char *zPassword; if( g.argc!=4 ){ usage("FILENAME DIRECTORY"); } if( file_isdir(g.argv[3])!=1 ){ printf("\"%s\" is not a directory\n\n", g.argv[3]); usage("FILENAME DIRECTORY"); } db_create_repository(g.argv[2]); db_open_repository(g.argv[2]); db_open_config(0); db_begin_transaction(); db_initial_setup(0, 0, 1); printf("Reading files from directory \"%s\"...\n", g.argv[3]); recon_read_dir(g.argv[3]); printf("\nBuilding the Fossil repository...\n"); rebuild_db(0, 1, 1); /* Reconstruct the private table. The private table contains the rid ** of every manifest that is tagged with "private" and every file that ** is not used by a manifest that is not private. */ ................................................................................ /* Skip the verify_before_commit() step on a reconstruct. Most artifacts ** will have been changed and verification therefore takes a really, really ** long time. */ verify_cancel(); db_end_transaction(0); printf("project-id: %s\n", db_get("project-code", 0)); printf("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); } /* ** COMMAND: deconstruct ** ** Usage %fossil deconstruct ?OPTIONS? DESTIONATION ** ................................................................................ if( zPrefixOpt[0]>='0' && zPrefixOpt[0]<='9' && !zPrefixOpt[1] ){ prefixLength = (int)(*zPrefixOpt-'0'); }else{ fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt); } } #ifndef _WIN32 if( access(zDestDir, W_OK) ){ fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir); } #else /* write access on windows is not checked, errors will be ** dected on blob_write_to_file */ #endif ................................................................................ } /* open repository and open query for all artifacts */ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); bag_init(&bagDone); ttyOutput = 1; processCnt = 0; if (!g.fQuiet) { printf("0 (0%%)...\r"); fflush(stdout); } totalSize = db_int(0, "SELECT count(*) FROM blob"); db_prepare(&s, "SELECT rid, size FROM blob /*scan*/" " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" " AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)" ................................................................................ content_get(rid, &content); rebuild_step(rid, size, &content); } } } db_finalize(&s); if(!g.fQuiet && ttyOutput ){ printf("\n"); } /* free filename format string */ free(zFNameFormat); zFNameFormat = 0; } |
| | > | | > | | | | | | | | | | | | | | | | | |
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 ... 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 ... 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 ... 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 ... 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 ... 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 ... 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 ... 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 ... 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 ... 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
/* ** Draw the percent-complete message. ** The input is actually the permill complete. */ static void percent_complete(int permill){ static int lastOutput = -1; if( permill>lastOutput ){ fossil_print(" %d.%d%% complete...\r", permill/10, permill%10); fflush(stdout); lastOutput = permill; } } /* ................................................................................ } if( doClustering ) create_cluster(); if( !g.fQuiet && totalSize>0 ){ processCnt += incrSize; percent_complete((processCnt*1000)/totalSize); } if(!g.fQuiet && ttyOutput ){ fossil_print("\n"); } return errCnt; } /* ** Attempt to convert more full-text blobs into delta-blobs for ** storage efficiency. ................................................................................ errCnt = rebuild_db(randomizeFlag, 1, doClustering); db_multi_exec( "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());" "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());", CONTENT_SCHEMA, AUX_SCHEMA ); if( errCnt && !forceFlag ){ fossil_print( "%d errors. Rolling back changes. Use --force to force a commit.\n", errCnt ); db_end_transaction(1); }else{ if( runCompress ){ fossil_print("Extra delta compression... "); fflush(stdout); extra_deltification(); runVacuum = 1; } if( omitVerify ) verify_cancel(); db_end_transaction(0); if( runCompress ) fossil_print("done\n"); db_close(0); db_open_repository(g.zRepositoryName); if( newPagesize ){ db_multi_exec("PRAGMA page_size=%d", newPagesize); runVacuum = 1; } if( runVacuum ){ fossil_print("Vacuuming the database... "); fflush(stdout); db_multi_exec("VACUUM"); fossil_print("done\n"); } if( activateWal ){ db_multi_exec("PRAGMA journal_mode=WAL;"); } } } ................................................................................ } } manifest_destroy(p); } n = db_int(0, "SELECT count(*) FROM /*scan*/" " (SELECT rid FROM blob EXCEPT SELECT x FROM xdone)"); if( n==0 ){ fossil_print("all artifacts reachable through clusters\n"); }else{ fossil_print("%d unreachable artifacts:\n", n); db_prepare(&q, "SELECT rid, uuid FROM blob WHERE rid NOT IN xdone"); while( db_step(&q)==SQLITE_ROW ){ fossil_print(" %3d %s\n", db_column_int(&q,0), db_column_text(&q,1)); } db_finalize(&q); } } /* ** COMMAND: scrub ................................................................................ fossil_panic("some unknown error occurred while reading \"%s\"", blob_str(&path)); } content_put(&aContent); blob_reset(&path); blob_reset(&aContent); free(zSubpath); fossil_print("\r%d", ++nFileRead); fflush(stdout); } closedir(d); }else { fossil_panic("encountered error %d while trying to open \"%s\".", errno, g.argv[3]); } ................................................................................ */ void reconstruct_cmd(void) { char *zPassword; if( g.argc!=4 ){ usage("FILENAME DIRECTORY"); } if( file_isdir(g.argv[3])!=1 ){ fossil_print("\"%s\" is not a directory\n\n", g.argv[3]); usage("FILENAME DIRECTORY"); } db_create_repository(g.argv[2]); db_open_repository(g.argv[2]); db_open_config(0); db_begin_transaction(); db_initial_setup(0, 0, 1); fossil_print("Reading files from directory \"%s\"...\n", g.argv[3]); recon_read_dir(g.argv[3]); fossil_print("\nBuilding the Fossil repository...\n"); rebuild_db(0, 1, 1); /* Reconstruct the private table. The private table contains the rid ** of every manifest that is tagged with "private" and every file that ** is not used by a manifest that is not private. */ ................................................................................ /* Skip the verify_before_commit() step on a reconstruct. Most artifacts ** will have been changed and verification therefore takes a really, really ** long time. */ verify_cancel(); db_end_transaction(0); fossil_print("project-id: %s\n", db_get("project-code", 0)); fossil_print("server-id: %s\n", db_get("server-code", 0)); zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); } /* ** COMMAND: deconstruct ** ** Usage %fossil deconstruct ?OPTIONS? DESTIONATION ** ................................................................................ if( zPrefixOpt[0]>='0' && zPrefixOpt[0]<='9' && !zPrefixOpt[1] ){ prefixLength = (int)(*zPrefixOpt-'0'); }else{ fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt); } } #ifndef _WIN32 if( file_access(zDestDir, W_OK) ){ fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir); } #else /* write access on windows is not checked, errors will be ** dected on blob_write_to_file */ #endif ................................................................................ } /* open repository and open query for all artifacts */ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); bag_init(&bagDone); ttyOutput = 1; processCnt = 0; if (!g.fQuiet) { fossil_print("0 (0%%)...\r"); fflush(stdout); } totalSize = db_int(0, "SELECT count(*) FROM blob"); db_prepare(&s, "SELECT rid, size FROM blob /*scan*/" " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" " AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)" ................................................................................ content_get(rid, &content); rebuild_step(rid, size, &content); } } } db_finalize(&s); if(!g.fQuiet && ttyOutput ){ fossil_print("\n"); } /* free filename format string */ free(zFNameFormat); zFNameFormat = 0; } |
Changes to src/report.c.
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 .... 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 .... 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
** show all reports, which can be used for ticket show. ** Output is written to stdout as tab delimited table */ void rpt_list_reports(void){ Stmt q; char const aRptOutFrmt[] = "%s\t%s\n"; printf("Available reports:\n"); printf(aRptOutFrmt,"report number","report title"); printf(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle); db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn"); while( db_step(&q)==SQLITE_ROW ){ const char *zRn = db_column_text(&q, 0); const char *zTitle = db_column_text(&q, 1); printf(aRptOutFrmt,zRn,zTitle); } db_finalize(&q); } /* ** user defined separator used by ticket show command */ ................................................................................ static void output_no_tabs_file(const char *z){ switch( tktEncode ){ case tktFossilize: { char *zFosZ; if( z && *z ){ zFosZ = fossilize(z,-1); printf("%s",zFosZ); free(zFosZ); } break; } default: while( z && z[0] ){ int i, j; for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){} if( i>0 ){ printf("%.*s", i, z); } for(j=i; fossil_isspace(z[j]); j++){} if( j>i ){ printf("%*s", j-i, ""); } z += j; } break; } } ................................................................................ ){ int *pCount = (int*)pUser; int i; if( *pCount==0 ){ for(i=0; i<nArg; i++){ output_no_tabs_file(azName[i]); printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); } } ++*pCount; for(i=0; i<nArg; i++){ output_no_tabs_file(azArg[i]); printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); } return 0; } /* ** Generate a report. The rn query parameter is the report number. ** The output is written to stdout as flat file. The zFilter paramater |
| | | | | | | | | |
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 .... 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 .... 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
** show all reports, which can be used for ticket show. ** Output is written to stdout as tab delimited table */ void rpt_list_reports(void){ Stmt q; char const aRptOutFrmt[] = "%s\t%s\n"; fossil_print("Available reports:\n"); fossil_print(aRptOutFrmt,"report number","report title"); fossil_print(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle); db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn"); while( db_step(&q)==SQLITE_ROW ){ const char *zRn = db_column_text(&q, 0); const char *zTitle = db_column_text(&q, 1); fossil_print(aRptOutFrmt,zRn,zTitle); } db_finalize(&q); } /* ** user defined separator used by ticket show command */ ................................................................................ static void output_no_tabs_file(const char *z){ switch( tktEncode ){ case tktFossilize: { char *zFosZ; if( z && *z ){ zFosZ = fossilize(z,-1); fossil_print("%s",zFosZ); free(zFosZ); } break; } default: while( z && z[0] ){ int i, j; for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){} if( i>0 ){ fossil_print("%.*s", i, z); } for(j=i; fossil_isspace(z[j]); j++){} if( j>i ){ fossil_print("%*s", j-i, ""); } z += j; } break; } } ................................................................................ ){ int *pCount = (int*)pUser; int i; if( *pCount==0 ){ for(i=0; i<nArg; i++){ output_no_tabs_file(azName[i]); fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); } } ++*pCount; for(i=0; i<nArg; i++){ output_no_tabs_file(azArg[i]); fossil_print("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n"); } return 0; } /* ** Generate a report. The rn query parameter is the report number. ** The output is written to stdout as flat file. The zFilter paramater |
Changes to src/sha1.c.
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
428
429
430
431
432
433
434
435
436
437
438
|
*/ int sha1sum_file(const char *zFilename, Blob *pCksum){ FILE *in; SHA1Context ctx; unsigned char zResult[20]; char zBuf[10240]; in = fopen(zFilename,"rb"); if( in==0 ){ return 1; } SHA1Init(&ctx); for(;;){ int n; n = fread(zBuf, 1, sizeof(zBuf), in); ................................................................................ blob_init(&cksum, "************** not found ***************", -1); if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ blob_read_from_channel(&in, stdin, -1); sha1sum_blob(&in, &cksum); }else{ sha1sum_file(g.argv[i], &cksum); } printf("%s %s\n", blob_str(&cksum), g.argv[i]); blob_reset(&cksum); } } |
|
|
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
428
429
430
431
432
433
434
435
436
437
438
|
*/ int sha1sum_file(const char *zFilename, Blob *pCksum){ FILE *in; SHA1Context ctx; unsigned char zResult[20]; char zBuf[10240]; in = fossil_fopen(zFilename,"rb"); if( in==0 ){ return 1; } SHA1Init(&ctx); for(;;){ int n; n = fread(zBuf, 1, sizeof(zBuf), in); ................................................................................ blob_init(&cksum, "************** not found ***************", -1); if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ blob_read_from_channel(&in, stdin, -1); sha1sum_blob(&in, &cksum); }else{ sha1sum_file(g.argv[i], &cksum); } fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); blob_reset(&cksum); } } |
Changes to src/stash.c.
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 ... 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 ... 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
Blob delta; undo_save(zNew); blob_zero(&delta); if( rid==0 ){ db_ephemeral_blob(&q, 5, &delta); blob_write_to_file(&delta, zNPath); file_setexe(zNPath, isExec); printf("ADD %s\n", zNew); }else if( isRemoved ){ printf("DELETE %s\n", zOrig); unlink(zOPath); }else{ Blob a, b, out, disk; db_ephemeral_blob(&q, 5, &delta); blob_read_from_file(&disk, zOPath); content_get(rid, &a); blob_delta_apply(&a, &delta, &b); if( blob_compare(&disk, &a)==0 ){ blob_write_to_file(&b, zNPath); file_setexe(zNPath, isExec); printf("UPDATE %s\n", zNew); }else{ int rc = merge_3way(&a, zOPath, &b, &out); blob_write_to_file(&out, zNPath); file_setexe(zNPath, isExec); if( rc ){ printf("CONFLICT %s\n", zNew); nConflict++; }else{ printf("MERGE %s\n", zNew); } blob_reset(&out); } blob_reset(&a); blob_reset(&b); blob_reset(&disk); } blob_reset(&delta); if( fossil_strcmp(zOrig,zNew)!=0 ){ undo_save(zOrig); unlink(zOPath); } } db_finalize(&q); if( nConflict ){ printf("WARNING: merge conflicts - see messages above for details.\n"); } } /* ** Show the diffs associate with a single stash. */ static void stash_diff(int stashid, const char *zDiffCmd){ ................................................................................ int isRemoved = db_column_int(&q, 1); const char *zOrig = db_column_text(&q, 3); const char *zNew = db_column_text(&q, 4); char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig); Blob delta; if( rid==0 ){ db_ephemeral_blob(&q, 5, &delta); printf("ADDED %s\n", zNew); diff_print_index(zNew); diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0); }else if( isRemoved ){ printf("DELETE %s\n", zOrig); blob_read_from_file(&delta, zOPath); diff_print_index(zNew); diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0); }else{ Blob a, b, disk; db_ephemeral_blob(&q, 5, &delta); blob_read_from_file(&disk, zOPath); content_get(rid, &a); blob_delta_apply(&a, &delta, &b); printf("CHANGED %s\n", zNew); diff_file_mem(&disk, &b, zNew, zDiffCmd, 0); blob_reset(&a); blob_reset(&b); blob_reset(&disk); } blob_reset(&delta); } ................................................................................ "SELECT stashid, (SELECT uuid FROM blob WHERE rid=vid)," " comment, datetime(ctime) FROM stash" " ORDER BY ctime DESC" ); while( db_step(&q)==SQLITE_ROW ){ const char *zCom; n++; printf("%5d: [%.14s] on %s\n", db_column_int(&q, 0), db_column_text(&q, 1), db_column_text(&q, 3) ); zCom = db_column_text(&q, 2); if( zCom && zCom[0] ){ printf(" "); comment_print(zCom, 7, 79); } } db_finalize(&q); if( n==0 ) printf("empty stash\n"); }else if( memcmp(zCmd, "drop", nCmd)==0 ){ int allFlag = find_option("all", 0, 0)!=0; if( g.argc>4 ) usage("stash apply STASHID"); if( allFlag ){ db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;"); }else{ |
| | | | | | | | | | | | | | |
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 ... 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 ... 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
Blob delta; undo_save(zNew); blob_zero(&delta); if( rid==0 ){ db_ephemeral_blob(&q, 5, &delta); blob_write_to_file(&delta, zNPath); file_setexe(zNPath, isExec); fossil_print("ADD %s\n", zNew); }else if( isRemoved ){ fossil_print("DELETE %s\n", zOrig); file_delete(zOPath); }else{ Blob a, b, out, disk; db_ephemeral_blob(&q, 5, &delta); blob_read_from_file(&disk, zOPath); content_get(rid, &a); blob_delta_apply(&a, &delta, &b); if( blob_compare(&disk, &a)==0 ){ blob_write_to_file(&b, zNPath); file_setexe(zNPath, isExec); fossil_print("UPDATE %s\n", zNew); }else{ int rc = merge_3way(&a, zOPath, &b, &out); blob_write_to_file(&out, zNPath); file_setexe(zNPath, isExec); if( rc ){ fossil_print("CONFLICT %s\n", zNew); nConflict++; }else{ fossil_print("MERGE %s\n", zNew); } blob_reset(&out); } blob_reset(&a); blob_reset(&b); blob_reset(&disk); } blob_reset(&delta); if( fossil_strcmp(zOrig,zNew)!=0 ){ undo_save(zOrig); file_delete(zOPath); } } db_finalize(&q); if( nConflict ){ fossil_print("WARNING: merge conflicts - see messages above for details.\n"); } } /* ** Show the diffs associate with a single stash. */ static void stash_diff(int stashid, const char *zDiffCmd){ ................................................................................ int isRemoved = db_column_int(&q, 1); const char *zOrig = db_column_text(&q, 3); const char *zNew = db_column_text(&q, 4); char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig); Blob delta; if( rid==0 ){ db_ephemeral_blob(&q, 5, &delta); fossil_print("ADDED %s\n", zNew); diff_print_index(zNew); diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0); }else if( isRemoved ){ fossil_print("DELETE %s\n", zOrig); blob_read_from_file(&delta, zOPath); diff_print_index(zNew); diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0); }else{ Blob a, b, disk; db_ephemeral_blob(&q, 5, &delta); blob_read_from_file(&disk, zOPath); content_get(rid, &a); blob_delta_apply(&a, &delta, &b); fossil_print("CHANGED %s\n", zNew); diff_file_mem(&disk, &b, zNew, zDiffCmd, 0); blob_reset(&a); blob_reset(&b); blob_reset(&disk); } blob_reset(&delta); } ................................................................................ "SELECT stashid, (SELECT uuid FROM blob WHERE rid=vid)," " comment, datetime(ctime) FROM stash" " ORDER BY ctime DESC" ); while( db_step(&q)==SQLITE_ROW ){ const char *zCom; n++; fossil_print("%5d: [%.14s] on %s\n", db_column_int(&q, 0), db_column_text(&q, 1), db_column_text(&q, 3) ); zCom = db_column_text(&q, 2); if( zCom && zCom[0] ){ fossil_print(" "); comment_print(zCom, 7, 79); } } db_finalize(&q); if( n==0 ) fossil_print("empty stash\n"); }else if( memcmp(zCmd, "drop", nCmd)==0 ){ int allFlag = find_option("all", 0, 0)!=0; if( g.argc>4 ) usage("stash apply STASHID"); if( allFlag ){ db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;"); }else{ |
Changes to src/sync.c.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 ... 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 ... 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
** TODO: What happens if the shun list gets really big? ** Maybe the shunning list should only be pulled on every 10th ** autosync, or something? */ configSync = CONFIGSET_SHUN; } #endif printf("Autosync: %s\n", g.urlCanonical); url_enable_proxy("via proxy: "); rc = client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, configSync, 0); if( rc ) fossil_warning("Autosync failed"); return rc; } /* ................................................................................ } if( !g.dontKeepUrl ){ db_set("last-sync-url", g.urlCanonical, 0); if( g.urlPasswd ) db_set("last-sync-pw", obscure(g.urlPasswd), 0); } user_select(); if( g.argc==2 ){ printf("Server: %s\n", g.urlCanonical); } url_enable_proxy("via proxy: "); *pConfigSync = configSync; } /* ** COMMAND: pull ................................................................................ }else{ db_unset("last-sync-pw", 0); } } } zUrl = db_get("last-sync-url", 0); if( zUrl==0 ){ printf("off\n"); return; }else{ url_parse(zUrl); printf("%s\n", g.urlCanonical); } } |
| | | | |
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 ... 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 ... 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
** TODO: What happens if the shun list gets really big? ** Maybe the shunning list should only be pulled on every 10th ** autosync, or something? */ configSync = CONFIGSET_SHUN; } #endif fossil_print("Autosync: %s\n", g.urlCanonical); url_enable_proxy("via proxy: "); rc = client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, configSync, 0); if( rc ) fossil_warning("Autosync failed"); return rc; } /* ................................................................................ } if( !g.dontKeepUrl ){ db_set("last-sync-url", g.urlCanonical, 0); if( g.urlPasswd ) db_set("last-sync-pw", obscure(g.urlPasswd), 0); } user_select(); if( g.argc==2 ){ fossil_print("Server: %s\n", g.urlCanonical); } url_enable_proxy("via proxy: "); *pConfigSync = configSync; } /* ** COMMAND: pull ................................................................................ }else{ db_unset("last-sync-pw", 0); } } } zUrl = db_get("last-sync-url", 0); if( zUrl==0 ){ fossil_print("off\n"); return; }else{ url_parse(zUrl); fossil_print("%s\n", g.urlCanonical); } } |
Changes to src/tag.c.
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 ... 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 ... 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
"SELECT blob.uuid FROM tagxref, blob" " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" " AND tagxref.tagtype>0" " AND blob.rid=tagxref.rid", g.argv[3] ); while( db_step(&q)==SQLITE_ROW ){ printf("%s\n", db_column_text(&q, 0)); } db_finalize(&q); }else{ int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", g.argv[3]); if( tagid>0 ){ db_prepare(&q, ................................................................................ " WHERE tagid=tag.tagid" " AND tagtype>0)" " ORDER BY tagname" ); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); if( fRaw ){ printf("%s\n", zName); }else if( strncmp(zName, "sym-", 4)==0 ){ printf("%s\n", &zName[4]); } } db_finalize(&q); }else if( g.argc==4 ){ int rid = name_to_rid(g.argv[3]); db_prepare(&q, "SELECT tagname, value FROM tagxref, tag" ................................................................................ const char *zName = db_column_text(&q, 0); const char *zValue = db_column_text(&q, 1); if( fRaw==0 ){ if( strncmp(zName, "sym-", 4)!=0 ) continue; zName += 4; } if( zValue && zValue[0] ){ printf("%s=%s\n", zName, zValue); }else{ printf("%s\n", zName); } } db_finalize(&q); }else{ usage("tag list ?CHECK-IN?"); } }else |
| | | | | |
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 ... 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 ... 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
"SELECT blob.uuid FROM tagxref, blob" " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" " AND tagxref.tagtype>0" " AND blob.rid=tagxref.rid", g.argv[3] ); while( db_step(&q)==SQLITE_ROW ){ fossil_print("%s\n", db_column_text(&q, 0)); } db_finalize(&q); }else{ int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", g.argv[3]); if( tagid>0 ){ db_prepare(&q, ................................................................................ " WHERE tagid=tag.tagid" " AND tagtype>0)" " ORDER BY tagname" ); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); if( fRaw ){ fossil_print("%s\n", zName); }else if( strncmp(zName, "sym-", 4)==0 ){ fossil_print("%s\n", &zName[4]); } } db_finalize(&q); }else if( g.argc==4 ){ int rid = name_to_rid(g.argv[3]); db_prepare(&q, "SELECT tagname, value FROM tagxref, tag" ................................................................................ const char *zName = db_column_text(&q, 0); const char *zValue = db_column_text(&q, 1); if( fRaw==0 ){ if( strncmp(zName, "sym-", 4)!=0 ) continue; zName += 4; } if( zValue && zValue[0] ){ fossil_print("%s=%s\n", zName, zValue); }else{ fossil_print("%s\n", zName); } } db_finalize(&q); }else{ usage("tag list ?CHECK-IN?"); } }else |
Changes to src/timeline.c.
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
....
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
|
char *zFree = 0; int n = 0; char zPrefix[80]; char zUuid[UUID_SIZE+1]; sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); if( memcmp(zDate, zPrevDate, 10) ){ printf("=== %.10s ===\n", zDate); memcpy(zPrevDate, zDate, 10); nLine++; } if( zCom==0 ) zCom = ""; printf("%.8s ", &zDate[11]); zPrefix[0] = 0; if( nParent>1 ){ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* "); n = strlen(zPrefix); } if( nChild>1 ){ const char *zBrType; ................................................................................ " (SELECT uuid FROM blob WHERE rid=c.cid)," " datetime(p.mtime), datetime(c.mtime)" " FROM plink p, plink c" " WHERE p.cid=c.pid AND p.mtime>c.mtime" ); while( db_step(&q)==SQLITE_ROW ){ if( !showDetail ){ printf("%s\n", db_column_text(&q, 1)); }else{ printf("%.14s -> %.14s %s -> %s\n", db_column_text(&q, 0), db_column_text(&q, 1), db_column_text(&q, 2), db_column_text(&q, 3)); } } db_finalize(&q); |
|
|
|
|
|
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
....
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
|
char *zFree = 0; int n = 0; char zPrefix[80]; char zUuid[UUID_SIZE+1]; sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); if( memcmp(zDate, zPrevDate, 10) ){ fossil_print("=== %.10s ===\n", zDate); memcpy(zPrevDate, zDate, 10); nLine++; } if( zCom==0 ) zCom = ""; fossil_print("%.8s ", &zDate[11]); zPrefix[0] = 0; if( nParent>1 ){ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* "); n = strlen(zPrefix); } if( nChild>1 ){ const char *zBrType; ................................................................................ " (SELECT uuid FROM blob WHERE rid=c.cid)," " datetime(p.mtime), datetime(c.mtime)" " FROM plink p, plink c" " WHERE p.cid=c.pid AND p.mtime>c.mtime" ); while( db_step(&q)==SQLITE_ROW ){ if( !showDetail ){ fossil_print("%s\n", db_column_text(&q, 1)); }else{ fossil_print("%.14s -> %.14s %s -> %s\n", db_column_text(&q, 0), db_column_text(&q, 1), db_column_text(&q, 2), db_column_text(&q, 3)); } } db_finalize(&q); |
Changes to src/tkt.c.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
*/
void ticket_rebuild_entry(const char *zTktUuid){
char *zTag = mprintf("tkt-%s", zTktUuid);
int tagid = tag_findid(zTag, 1);
Stmt q;
Manifest *pTicket;
int createFlag = 1;
db_multi_exec(
"DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
);
db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
pTicket = manifest_get(rid, CFTYPE_TICKET);
|
| > |
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
*/
void ticket_rebuild_entry(const char *zTktUuid){
char *zTag = mprintf("tkt-%s", zTktUuid);
int tagid = tag_findid(zTag, 1);
Stmt q;
Manifest *pTicket;
int createFlag = 1;
fossil_free(zTag);
db_multi_exec(
"DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
);
db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
pTicket = manifest_get(rid, CFTYPE_TICKET);
|
Changes to src/undo.c.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 ... 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 ... 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 ... 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 ... 408 409 410 411 412 413 414 415 416 417 418 419 420 |
old_exists = db_column_int(&q, 1); old_exe = db_column_int(&q, 2); if( old_exists ){ db_ephemeral_blob(&q, 0, &new); } if( old_exists ){ if( new_exists ){ printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname); }else{ printf("NEW %s\n", zPathname); } blob_write_to_file(&new, zFullname); file_setexe(zFullname, old_exe); }else{ printf("DELETE %s\n", zPathname); unlink(zFullname); } blob_reset(&new); free(zFullname); db_finalize(&q); db_prepare(&q, "UPDATE undo SET content=:c, existsflag=%d, isExe=%d," " redoflag=NOT redoflag" ................................................................................ /* ** Complete the undo process is one is currently in process. */ void undo_finish(void){ if( undoActive ){ if( undoNeedRollback ){ printf("\"fossil undo\" is available to undo changes" " to the working checkout.\n"); } undoActive = 0; undoNeedRollback = 0; } } ................................................................................ ** was locked or had permissions turned off. */ void undo_rollback(void){ if( !undoNeedRollback ) return; assert( undoActive ); undoNeedRollback = 0; undoActive = 0; printf("Rolling back prior filesystem changes...\n"); undo_all_filesystem(0); } /* ** COMMAND: undo ** COMMAND: redo ** ................................................................................ const char *zCmd = isRedo ? "redo" : "undo"; db_must_be_within_tree(); verify_all_options(); db_begin_transaction(); undo_available = db_lget_int("undo_available", 0); if( explainFlag ){ if( undo_available==0 ){ printf("No undo or redo is available\n"); }else{ Stmt q; int nChng = 0; zCmd = undo_available==1 ? "undo" : "redo"; printf("A %s is available for the following command:\n\n %s %s\n\n", zCmd, g.argv[0], db_lget("undo_cmdline", "???")); db_prepare(&q, "SELECT existsflag, pathname FROM undo ORDER BY pathname" ); while( db_step(&q)==SQLITE_ROW ){ if( nChng==0 ){ printf("The following file changes would occur if the " "command above is %sne:\n\n", zCmd); } nChng++; printf("%s %s\n", db_column_int(&q,0) ? "UPDATE" : "DELETE", db_column_text(&q, 1) ); } db_finalize(&q); if( nChng==0 ){ printf("No file changes would occur with this undo/redo.\n"); } } }else{ int vid1 = db_lget_int("checkout", 0); int vid2; if( g.argc==2 ){ if( undo_available!=(1+isRedo) ){ ................................................................................ file_tree_name(zFile, &path, 1); undo_one(blob_str(&path), isRedo); blob_reset(&path); } } vid2 = db_lget_int("checkout", 0); if( vid1!=vid2 ){ printf("--------------------\n"); show_common_info(vid2, "updated-to:", 1, 0); } } db_end_transaction(0); } |
| | | | | | | | > | | | | | | |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 ... 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 ... 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 ... 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 ... 409 410 411 412 413 414 415 416 417 418 419 420 421 |
old_exists = db_column_int(&q, 1); old_exe = db_column_int(&q, 2); if( old_exists ){ db_ephemeral_blob(&q, 0, &new); } if( old_exists ){ if( new_exists ){ fossil_print("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname); }else{ fossil_print("NEW %s\n", zPathname); } blob_write_to_file(&new, zFullname); file_setexe(zFullname, old_exe); }else{ fossil_print("DELETE %s\n", zPathname); file_delete(zFullname); } blob_reset(&new); free(zFullname); db_finalize(&q); db_prepare(&q, "UPDATE undo SET content=:c, existsflag=%d, isExe=%d," " redoflag=NOT redoflag" ................................................................................ /* ** Complete the undo process is one is currently in process. */ void undo_finish(void){ if( undoActive ){ if( undoNeedRollback ){ fossil_print("\"fossil undo\" is available to undo changes" " to the working checkout.\n"); } undoActive = 0; undoNeedRollback = 0; } } ................................................................................ ** was locked or had permissions turned off. */ void undo_rollback(void){ if( !undoNeedRollback ) return; assert( undoActive ); undoNeedRollback = 0; undoActive = 0; fossil_print("Rolling back prior filesystem changes...\n"); undo_all_filesystem(0); } /* ** COMMAND: undo ** COMMAND: redo ** ................................................................................ const char *zCmd = isRedo ? "redo" : "undo"; db_must_be_within_tree(); verify_all_options(); db_begin_transaction(); undo_available = db_lget_int("undo_available", 0); if( explainFlag ){ if( undo_available==0 ){ fossil_print("No undo or redo is available\n"); }else{ Stmt q; int nChng = 0; zCmd = undo_available==1 ? "undo" : "redo"; fossil_print("A %s is available for the following command:\n\n" " %s %s\n\n", zCmd, g.argv[0], db_lget("undo_cmdline", "???")); db_prepare(&q, "SELECT existsflag, pathname FROM undo ORDER BY pathname" ); while( db_step(&q)==SQLITE_ROW ){ if( nChng==0 ){ fossil_print("The following file changes would occur if the " "command above is %sne:\n\n", zCmd); } nChng++; fossil_print("%s %s\n", db_column_int(&q,0) ? "UPDATE" : "DELETE", db_column_text(&q, 1) ); } db_finalize(&q); if( nChng==0 ){ fossil_print("No file changes would occur with this undo/redo.\n"); } } }else{ int vid1 = db_lget_int("checkout", 0); int vid2; if( g.argc==2 ){ if( undo_available!=(1+isRedo) ){ ................................................................................ file_tree_name(zFile, &path, 1); undo_one(blob_str(&path), isRedo); blob_reset(&path); } } vid2 = db_lget_int("checkout", 0); if( vid1!=vid2 ){ fossil_print("--------------------\n"); show_common_info(vid2, "updated-to:", 1, 0); } } db_end_transaction(0); } |
Changes to src/update.c.
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 ... 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 ... 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
); if( debugFlag ){ db_prepare(&q, "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv" ); while( db_step(&q)==SQLITE_ROW ){ printf("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n", db_column_int(&q, 0), db_column_int(&q, 4), db_column_int(&q, 5), db_column_int(&q, 3), db_column_int(&q, 6)); printf(" fnv = [%s]\n", db_column_text(&q, 1)); printf(" fnt = [%s]\n", db_column_text(&q, 2)); } db_finalize(&q); } /* If FILES appear on the command-line, remove from the "fv" table ** every entry that is not named on the command-line or which is not ** in a directory named on the command-line. ................................................................................ zFullPath = mprintf("%s%s", g.zLocalRoot, zName); zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); nameChng = fossil_strcmp(zName, zNewName); if( idv>0 && ridv==0 && idt>0 && ridt>0 ){ /* Conflict. This file has been added to the current checkout ** but also exists in the target checkout. Use the current version. */ printf("CONFLICT %s\n", zName); nConflict++; }else if( idt>0 && idv==0 ){ /* File added in the target. */ printf("ADD %s\n", zName); undo_save(zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){ /* The file is unedited. Change it to the target version */ undo_save(zName); printf("UPDATE %s\n", zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){ /* The file missing from the local check-out. Restore it to the ** version that appears in the target. */ printf("UPDATE %s\n", zName); undo_save(zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt==0 && idv>0 ){ if( ridv==0 ){ /* Added in current checkout. Continue to hold the file as ** as an addition */ db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv); }else if( chnged ){ /* Edited locally but deleted from the target. Do not track the ** file but keep the edited version around. */ printf("CONFLICT %s - edited locally but deleted by update\n", zName); nConflict++; }else{ printf("REMOVE %s\n", zName); undo_save(zName); if( !nochangeFlag ) unlink(zFullPath); } }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ /* Merge the changes in the current tree into the target version */ Blob r, t, v; int rc; if( nameChng ){ printf("MERGE %s -> %s\n", zName, zNewName); }else{ printf("MERGE %s\n", zName); } undo_save(zName); content_get(ridt, &t); content_get(ridv, &v); rc = merge_3way(&v, zFullPath, &t, &r); if( rc>=0 ){ if( !nochangeFlag ){ blob_write_to_file(&r, zFullNewPath); file_setexe(zFullNewPath, isexe); } if( rc>0 ){ printf("***** %d merge conflicts in %s\n", rc, zNewName); nConflict++; } }else{ if( !nochangeFlag ){ blob_write_to_file(&t, zFullNewPath); file_setexe(zFullNewPath, isexe); } printf("***** Cannot merge binary file %s\n", zNewName); nConflict++; } if( nameChng && !nochangeFlag ) unlink(zFullPath); blob_reset(&v); blob_reset(&t); blob_reset(&r); }else{ if( chnged ){ if( verboseFlag ) printf("EDITED %s\n", zName); }else{ db_bind_int(&mtimeXfer, ":idv", idv); db_bind_int(&mtimeXfer, ":idt", idt); db_step(&mtimeXfer); db_reset(&mtimeXfer); if( verboseFlag ) printf("UNCHANGED %s\n", zName); } } free(zFullPath); free(zFullNewPath); } db_finalize(&q); db_finalize(&mtimeXfer); printf("--------------\n"); show_common_info(tid, "updated-to:", 1, 0); /* Report on conflicts */ if( nConflict && !nochangeFlag ){ if( internalUpdate ){ internalConflictCnt = nConflict; }else{ printf("WARNING: %d merge conflicts - see messages above for details.\n", nConflict); } } /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ ................................................................................ int isExe = 0; char *zFull; zFile = db_column_text(&q, 0); zFull = mprintf("%/%/", g.zLocalRoot, zFile); errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2); if( errCode==2 ){ if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){ printf("UNMANAGE: %s\n", zFile); }else{ undo_save(zFile); unlink(zFull); printf("DELETE: %s\n", zFile); } db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile); }else{ sqlite3_int64 mtime; undo_save(zFile); blob_write_to_file(&record, zFull); file_setexe(zFull, isExe); printf("REVERTED: %s\n", zFile); mtime = file_mtime(zFull); db_multi_exec( "UPDATE vfile" " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid," " pathname=coalesce(origname,pathname), origname=NULL" " WHERE pathname=%Q", mtime, isExe, zFile |
| | | | | | | | > | | | | | | | | | | | | | | | |
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 ... 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 ... 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
); if( debugFlag ){ db_prepare(&q, "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv" ); while( db_step(&q)==SQLITE_ROW ){ fossil_print("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n", db_column_int(&q, 0), db_column_int(&q, 4), db_column_int(&q, 5), db_column_int(&q, 3), db_column_int(&q, 6)); fossil_print(" fnv = [%s]\n", db_column_text(&q, 1)); fossil_print(" fnt = [%s]\n", db_column_text(&q, 2)); } db_finalize(&q); } /* If FILES appear on the command-line, remove from the "fv" table ** every entry that is not named on the command-line or which is not ** in a directory named on the command-line. ................................................................................ zFullPath = mprintf("%s%s", g.zLocalRoot, zName); zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); nameChng = fossil_strcmp(zName, zNewName); if( idv>0 && ridv==0 && idt>0 && ridt>0 ){ /* Conflict. This file has been added to the current checkout ** but also exists in the target checkout. Use the current version. */ fossil_print("CONFLICT %s\n", zName); nConflict++; }else if( idt>0 && idv==0 ){ /* File added in the target. */ fossil_print("ADD %s\n", zName); undo_save(zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){ /* The file is unedited. Change it to the target version */ undo_save(zName); fossil_print("UPDATE %s\n", zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){ /* The file missing from the local check-out. Restore it to the ** version that appears in the target. */ fossil_print("UPDATE %s\n", zName); undo_save(zName); if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); }else if( idt==0 && idv>0 ){ if( ridv==0 ){ /* Added in current checkout. Continue to hold the file as ** as an addition */ db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv); }else if( chnged ){ /* Edited locally but deleted from the target. Do not track the ** file but keep the edited version around. */ fossil_print("CONFLICT %s - edited locally but deleted by update\n", zName); nConflict++; }else{ fossil_print("REMOVE %s\n", zName); undo_save(zName); if( !nochangeFlag ) file_delete(zFullPath); } }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ /* Merge the changes in the current tree into the target version */ Blob r, t, v; int rc; if( nameChng ){ fossil_print("MERGE %s -> %s\n", zName, zNewName); }else{ fossil_print("MERGE %s\n", zName); } undo_save(zName); content_get(ridt, &t); content_get(ridv, &v); rc = merge_3way(&v, zFullPath, &t, &r); if( rc>=0 ){ if( !nochangeFlag ){ blob_write_to_file(&r, zFullNewPath); file_setexe(zFullNewPath, isexe); } if( rc>0 ){ fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); nConflict++; } }else{ if( !nochangeFlag ){ blob_write_to_file(&t, zFullNewPath); file_setexe(zFullNewPath, isexe); } fossil_print("***** Cannot merge binary file %s\n", zNewName); nConflict++; } if( nameChng && !nochangeFlag ) file_delete(zFullPath); blob_reset(&v); blob_reset(&t); blob_reset(&r); }else{ if( chnged ){ if( verboseFlag ) fossil_print("EDITED %s\n", zName); }else{ db_bind_int(&mtimeXfer, ":idv", idv); db_bind_int(&mtimeXfer, ":idt", idt); db_step(&mtimeXfer); db_reset(&mtimeXfer); if( verboseFlag ) fossil_print("UNCHANGED %s\n", zName); } } free(zFullPath); free(zFullNewPath); } db_finalize(&q); db_finalize(&mtimeXfer); fossil_print("--------------\n"); show_common_info(tid, "updated-to:", 1, 0); /* Report on conflicts */ if( nConflict && !nochangeFlag ){ if( internalUpdate ){ internalConflictCnt = nConflict; }else{ fossil_print("WARNING: %d merge conflicts - see messages above for details.\n", nConflict); } } /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ ................................................................................ int isExe = 0; char *zFull; zFile = db_column_text(&q, 0); zFull = mprintf("%/%/", g.zLocalRoot, zFile); errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2); if( errCode==2 ){ if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){ fossil_print("UNMANAGE: %s\n", zFile); }else{ undo_save(zFile); file_delete(zFull); fossil_print("DELETE: %s\n", zFile); } db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile); }else{ sqlite3_int64 mtime; undo_save(zFile); blob_write_to_file(&record, zFull); file_setexe(zFull, isExe); fossil_print("REVERTED: %s\n", zFile); mtime = file_mtime(zFull); db_multi_exec( "UPDATE vfile" " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid," " pathname=coalesce(origname,pathname), origname=NULL" " WHERE pathname=%Q", mtime, isExe, zFile |
Changes to src/url.c.
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
int i; url_proxy_options(); if( g.argc!=3 && g.argc!=4 ){ usage("URL"); } url_parse(g.argv[2]); for(i=0; i<2; i++){ printf("g.urlIsFile = %d\n", g.urlIsFile); printf("g.urlIsHttps = %d\n", g.urlIsHttps); printf("g.urlIsSsh = %d\n", g.urlIsSsh); printf("g.urlProtocol = %s\n", g.urlProtocol); printf("g.urlName = %s\n", g.urlName); printf("g.urlPort = %d\n", g.urlPort); printf("g.urlDfltPort = %d\n", g.urlDfltPort); printf("g.urlHostname = %s\n", g.urlHostname); printf("g.urlPath = %s\n", g.urlPath); printf("g.urlUser = %s\n", g.urlUser); printf("g.urlPasswd = %s\n", g.urlPasswd); printf("g.urlCanonical = %s\n", g.urlCanonical); printf("g.urlFossil = %s\n", g.urlFossil); if( g.urlIsFile || g.urlIsSsh ) break; if( i==0 ){ printf("********\n"); url_enable_proxy("Using proxy: "); } } } /* ** Proxy specified on the command-line using the --proxy option. ................................................................................ char *zOriginalUrl = g.urlCanonical; char *zOriginalHost = g.urlHostname; char *zOriginalUser = g.urlUser; char *zOriginalPasswd = g.urlPasswd; g.urlUser = 0; g.urlPasswd = ""; url_parse(zProxy); if( zMsg ) printf("%s%s\n", zMsg, g.urlCanonical); g.urlPath = zOriginalUrl; g.urlHostname = zOriginalHost; if( g.urlUser ){ char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd); char *zCredentials2 = encode64(zCredentials1, -1); g.urlProxyAuth = mprintf("Basic %z", zCredentials2); free(zCredentials1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
int i; url_proxy_options(); if( g.argc!=3 && g.argc!=4 ){ usage("URL"); } url_parse(g.argv[2]); for(i=0; i<2; i++){ fossil_print("g.urlIsFile = %d\n", g.urlIsFile); fossil_print("g.urlIsHttps = %d\n", g.urlIsHttps); fossil_print("g.urlIsSsh = %d\n", g.urlIsSsh); fossil_print("g.urlProtocol = %s\n", g.urlProtocol); fossil_print("g.urlName = %s\n", g.urlName); fossil_print("g.urlPort = %d\n", g.urlPort); fossil_print("g.urlDfltPort = %d\n", g.urlDfltPort); fossil_print("g.urlHostname = %s\n", g.urlHostname); fossil_print("g.urlPath = %s\n", g.urlPath); fossil_print("g.urlUser = %s\n", g.urlUser); fossil_print("g.urlPasswd = %s\n", g.urlPasswd); fossil_print("g.urlCanonical = %s\n", g.urlCanonical); fossil_print("g.urlFossil = %s\n", g.urlFossil); if( g.urlIsFile || g.urlIsSsh ) break; if( i==0 ){ fossil_print("********\n"); url_enable_proxy("Using proxy: "); } } } /* ** Proxy specified on the command-line using the --proxy option. ................................................................................ char *zOriginalUrl = g.urlCanonical; char *zOriginalHost = g.urlHostname; char *zOriginalUser = g.urlUser; char *zOriginalPasswd = g.urlPasswd; g.urlUser = 0; g.urlPasswd = ""; url_parse(zProxy); if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical); g.urlPath = zOriginalUrl; g.urlHostname = zOriginalHost; if( g.urlUser ){ char *zCredentials1 = mprintf("%s:%s", g.urlUser, g.urlPasswd); char *zCredentials2 = encode64(zCredentials1, -1); g.urlProxyAuth = mprintf("Basic %z", zCredentials2); free(zCredentials1); |
Changes to src/user.c.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 ... 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 ... 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 ... 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 ... 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
blob_zero(&secondTry); while(1){ prompt_for_passphrase(zPrompt, pPassphrase); if( verify==0 ) break; if( verify==1 && blob_size(pPassphrase)==0 ) break; prompt_for_passphrase("Retype new password: ", &secondTry); if( blob_compare(pPassphrase, &secondTry) ){ printf("Passphrases do not match. Try again...\n"); }else{ break; } } blob_reset(&secondTry); } ................................................................................ /* ** Prompt the user to enter a single line of text. */ void prompt_user(const char *zPrompt, Blob *pIn){ char *z; char zLine[1000]; blob_zero(pIn); printf("%s", zPrompt); fflush(stdout); z = fgets(zLine, sizeof(zLine), stdin); if( z ){ strip_string(pIn, z); } } ................................................................................ "VALUES(%B,%Q,%B,%B,now())", &login, zPw, &caps, &contact ); free(zPw); }else if( n>=2 && strncmp(g.argv[2],"default",n)==0 ){ user_select(); if( g.argc==3 ){ printf("%s\n", g.zLogin); }else{ if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.argv[3]) ){ fossil_fatal("no such user: %s", g.argv[3]); } if( g.localOpen ){ db_lset("default-user", g.argv[3]); }else{ ................................................................................ db_set("default-user", g.argv[3], 0); } } }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){ Stmt q; db_prepare(&q, "SELECT login, info FROM user ORDER BY login"); while( db_step(&q)==SQLITE_ROW ){ printf("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1)); } db_finalize(&q); }else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){ char *zPrompt; int uid; Blob pw; if( g.argc!=4 && g.argc!=5 ) usage("password USERNAME ?NEW-PASSWORD?"); ................................................................................ if( g.argc==5 ){ blob_init(&pw, g.argv[4], -1); }else{ zPrompt = mprintf("New password for %s: ", g.argv[3]); prompt_for_password(zPrompt, &pw, 1); } if( blob_size(&pw)==0 ){ printf("password unchanged\n"); }else{ char *zSecret = sha1_shared_secret(blob_str(&pw), g.argv[3], 0); db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d", zSecret, uid); free(zSecret); } }else if( n>=2 && strncmp(g.argv[2],"capabilities",2)==0 ){ ................................................................................ } if( g.argc==5 ){ db_multi_exec( "UPDATE user SET cap=%Q, mtime=now() WHERE uid=%d", g.argv[4], uid ); } printf("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid)); }else{ fossil_panic("user subcommand should be one of: " "capabilities default list new password"); } } /* |
| | | | | | |
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 ... 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 ... 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 ... 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 ... 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
blob_zero(&secondTry); while(1){ prompt_for_passphrase(zPrompt, pPassphrase); if( verify==0 ) break; if( verify==1 && blob_size(pPassphrase)==0 ) break; prompt_for_passphrase("Retype new password: ", &secondTry); if( blob_compare(pPassphrase, &secondTry) ){ fossil_print("Passphrases do not match. Try again...\n"); }else{ break; } } blob_reset(&secondTry); } ................................................................................ /* ** Prompt the user to enter a single line of text. */ void prompt_user(const char *zPrompt, Blob *pIn){ char *z; char zLine[1000]; blob_zero(pIn); fossil_print("%s", zPrompt); fflush(stdout); z = fgets(zLine, sizeof(zLine), stdin); if( z ){ strip_string(pIn, z); } } ................................................................................ "VALUES(%B,%Q,%B,%B,now())", &login, zPw, &caps, &contact ); free(zPw); }else if( n>=2 && strncmp(g.argv[2],"default",n)==0 ){ user_select(); if( g.argc==3 ){ fossil_print("%s\n", g.zLogin); }else{ if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.argv[3]) ){ fossil_fatal("no such user: %s", g.argv[3]); } if( g.localOpen ){ db_lset("default-user", g.argv[3]); }else{ ................................................................................ db_set("default-user", g.argv[3], 0); } } }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){ Stmt q; db_prepare(&q, "SELECT login, info FROM user ORDER BY login"); while( db_step(&q)==SQLITE_ROW ){ fossil_print("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1)); } db_finalize(&q); }else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){ char *zPrompt; int uid; Blob pw; if( g.argc!=4 && g.argc!=5 ) usage("password USERNAME ?NEW-PASSWORD?"); ................................................................................ if( g.argc==5 ){ blob_init(&pw, g.argv[4], -1); }else{ zPrompt = mprintf("New password for %s: ", g.argv[3]); prompt_for_password(zPrompt, &pw, 1); } if( blob_size(&pw)==0 ){ fossil_print("password unchanged\n"); }else{ char *zSecret = sha1_shared_secret(blob_str(&pw), g.argv[3], 0); db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d", zSecret, uid); free(zSecret); } }else if( n>=2 && strncmp(g.argv[2],"capabilities",2)==0 ){ ................................................................................ } if( g.argc==5 ){ db_multi_exec( "UPDATE user SET cap=%Q, mtime=now() WHERE uid=%d", g.argv[4], uid ); } fossil_print("%s\n", db_text(0, "SELECT cap FROM user WHERE uid=%d", uid)); }else{ fossil_panic("user subcommand should be one of: " "capabilities default list new password"); } } /* |
Changes to src/vfile.c.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 ... 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 ... 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 ... 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
cReply = 'y'; } if( cReply=='n' || cReply=='N' ){ blob_reset(&content); continue; } } if( verbose ) printf("%s\n", &zName[nRepos]); blob_write_to_file(&content, zName); file_setexe(zName, isExe); blob_reset(&content); db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", file_mtime(zName), id); } db_finalize(&q); ................................................................................ Stmt q; db_prepare(&q, "SELECT %Q || pathname FROM vfile" " WHERE vid=%d AND mrid>0", g.zLocalRoot, vid); while( db_step(&q)==SQLITE_ROW ){ const char *zName; zName = db_column_text(&q, 0); unlink(zName); } db_finalize(&q); db_multi_exec("UPDATE vfile SET mtime=NULL WHERE vid=%d AND mrid>0", vid); } /* ** Check to see if the directory named in zPath is the top of a checkout. ................................................................................ while( db_step(&q)==SQLITE_ROW ){ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int isSelected = db_column_int(&q, 3); if( isSelected ){ md5sum_step_text(zName, -1); in = fopen(zFullpath,"rb"); if( in==0 ){ md5sum_step_text(" 0\n", -1); continue; } fseek(in, 0L, SEEK_END); sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", ftell(in)); fseek(in, 0L, SEEK_SET); ................................................................................ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int rid = db_column_int(&q, 2); blob_zero(&disk); rc = blob_read_from_file(&disk, zFullpath); if( rc<0 ){ printf("ERROR: cannot read file [%s]\n", zFullpath); blob_reset(&disk); continue; } blob_zero(&repo); content_get(rid, &repo); if( blob_size(&repo)!=blob_size(&disk) ){ printf("ERROR: [%s] is %d bytes on disk but %d in the repository\n", zName, blob_size(&disk), blob_size(&repo)); blob_reset(&disk); blob_reset(&repo); continue; } if( blob_compare(&repo, &disk) ){ printf("ERROR: [%s] is different on disk compared to the repository\n", zName); } blob_reset(&disk); blob_reset(&repo); } db_finalize(&q); } |
| | | | | > | | |
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 ... 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 ... 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 ... 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
cReply = 'y'; } if( cReply=='n' || cReply=='N' ){ blob_reset(&content); continue; } } if( verbose ) fossil_print("%s\n", &zName[nRepos]); blob_write_to_file(&content, zName); file_setexe(zName, isExe); blob_reset(&content); db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", file_mtime(zName), id); } db_finalize(&q); ................................................................................ Stmt q; db_prepare(&q, "SELECT %Q || pathname FROM vfile" " WHERE vid=%d AND mrid>0", g.zLocalRoot, vid); while( db_step(&q)==SQLITE_ROW ){ const char *zName; zName = db_column_text(&q, 0); file_delete(zName); } db_finalize(&q); db_multi_exec("UPDATE vfile SET mtime=NULL WHERE vid=%d AND mrid>0", vid); } /* ** Check to see if the directory named in zPath is the top of a checkout. ................................................................................ while( db_step(&q)==SQLITE_ROW ){ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int isSelected = db_column_int(&q, 3); if( isSelected ){ md5sum_step_text(zName, -1); in = fossil_fopen(zFullpath,"rb"); if( in==0 ){ md5sum_step_text(" 0\n", -1); continue; } fseek(in, 0L, SEEK_END); sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", ftell(in)); fseek(in, 0L, SEEK_SET); ................................................................................ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int rid = db_column_int(&q, 2); blob_zero(&disk); rc = blob_read_from_file(&disk, zFullpath); if( rc<0 ){ fossil_print("ERROR: cannot read file [%s]\n", zFullpath); blob_reset(&disk); continue; } blob_zero(&repo); content_get(rid, &repo); if( blob_size(&repo)!=blob_size(&disk) ){ fossil_print("ERROR: [%s] is %d bytes on disk but %d in the repository\n", zName, blob_size(&disk), blob_size(&repo)); blob_reset(&disk); blob_reset(&repo); continue; } if( blob_compare(&repo, &disk) ){ fossil_print( "ERROR: [%s] is different on disk compared to the repository\n", zName); } blob_reset(&disk); blob_reset(&repo); } db_finalize(&q); } |
Changes to src/wiki.c.
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 ... 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 ... 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
zFile = (g.argc==4) ? 0 : g.argv[4]; if( zFile ){ FILE * zF; short doClose = 0; if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){ zF = stdout; }else{ zF = fopen( zFile, "w" ); doClose = zF ? 1 : 0; } if( ! zF ){ fossil_fatal("wiki export could not open output file for writing."); } fprintf(zF,"%.*s\n", i, zBody); if( doClose ) fclose(zF); }else{ printf("%.*s\n", i, zBody); } manifest_destroy(pWiki); return; }else if( strncmp(g.argv[2],"commit",n)==0 || strncmp(g.argv[2],"create",n)==0 ){ char *zPageName; ................................................................................ if( g.argc==4 ){ blob_read_from_channel(&content, stdin, -1); }else{ blob_read_from_file(&content, g.argv[4]); } if( g.argv[2][1]=='r' ){ wiki_cmd_commit(zPageName, 1, &content); printf("Created new wiki page %s.\n", zPageName); }else{ wiki_cmd_commit(zPageName, 0, &content); printf("Updated wiki page %s.\n", zPageName); } blob_reset(&content); }else if( strncmp(g.argv[2],"delete",n)==0 ){ if( g.argc!=5 ){ usage("delete PAGENAME"); } ................................................................................ Stmt q; db_prepare(&q, "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" " ORDER BY lower(tagname) /*sort*/" ); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); printf( "%s\n",zName); } db_finalize(&q); }else { goto wiki_cmd_usage; } return; wiki_cmd_usage: usage("export|create|commit|list ..."); } |
| | | | | |
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 ... 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 ... 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
zFile = (g.argc==4) ? 0 : g.argv[4]; if( zFile ){ FILE * zF; short doClose = 0; if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){ zF = stdout; }else{ zF = fossil_fopen( zFile, "w" ); doClose = zF ? 1 : 0; } if( ! zF ){ fossil_fatal("wiki export could not open output file for writing."); } fprintf(zF,"%.*s\n", i, zBody); if( doClose ) fclose(zF); }else{ fossil_print("%.*s\n", i, zBody); } manifest_destroy(pWiki); return; }else if( strncmp(g.argv[2],"commit",n)==0 || strncmp(g.argv[2],"create",n)==0 ){ char *zPageName; ................................................................................ if( g.argc==4 ){ blob_read_from_channel(&content, stdin, -1); }else{ blob_read_from_file(&content, g.argv[4]); } if( g.argv[2][1]=='r' ){ wiki_cmd_commit(zPageName, 1, &content); fossil_print("Created new wiki page %s.\n", zPageName); }else{ wiki_cmd_commit(zPageName, 0, &content); fossil_print("Updated wiki page %s.\n", zPageName); } blob_reset(&content); }else if( strncmp(g.argv[2],"delete",n)==0 ){ if( g.argc!=5 ){ usage("delete PAGENAME"); } ................................................................................ Stmt q; db_prepare(&q, "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" " ORDER BY lower(tagname) /*sort*/" ); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); fossil_print( "%s\n",zName); } db_finalize(&q); }else { goto wiki_cmd_usage; } return; wiki_cmd_usage: usage("export|create|commit|list ..."); } |
Changes to src/wikiformat.c.
1732 1733 1734 1735 1736 1737 1738 1739 |
} default: { break; } } z += n; } } |
> |
1732 1733 1734 1735 1736 1737 1738 1739 1740 |
}
default: {
break;
}
}
z += n;
}
free(renderer.aStack);
}
|
Changes to src/winhttp.c.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 ... 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 ... 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 ... 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
z = strstr(zHdr, "\r\n\r\n"); if( z ){ wanted = find_content_length(zHdr) + (&z[4]-zHdr) - amt; break; } } if( amt>=sizeof(zHdr) ) goto end_request; out = fopen(zRequestFName, "wb"); if( out==0 ) goto end_request; fwrite(zHdr, 1, amt, out); while( wanted>0 ){ got = recv(p->s, zHdr, sizeof(zHdr), 0); if( got==SOCKET_ERROR ) goto end_request; if( got ){ fwrite(zHdr, 1, got, out); ................................................................................ fclose(out); out = 0; sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr), p->zOptions ); fossil_system(zCmd); in = fopen(zReplyFName, "rb"); if( in ){ while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ send(p->s, zHdr, got, 0); } } end_request: if( out ) fclose(out); if( in ) fclose(in); closesocket(p->s); unlink(zRequestFName); unlink(zReplyFName); free(p); } /* ** Start a listening socket and process incoming HTTP requests on ** that socket. */ ................................................................................ WSADATA wd; SOCKET s = INVALID_SOCKET; SOCKADDR_IN addr; int idCnt = 0; int iPort = mnPort; Blob options; if( zStopper ) unlink(zStopper); blob_zero(&options); if( zNotFound ){ blob_appendf(&options, " --notfound %s", zNotFound); } if( g.useLocalauth ){ blob_appendf(&options, " --localauth"); } ................................................................................ fossil_fatal("unable to open listening socket on ports %d", mnPort); }else{ fossil_fatal("unable to open listening socket on any" " port in the range %d..%d", mnPort, mxPort); } } zTempPrefix = mprintf("fossil_server_P%d_", iPort); printf("Listening for HTTP requests on TCP port %d\n", iPort); if( zBrowser ){ zBrowser = mprintf(zBrowser, iPort); printf("Launch webbrowser: %s\n", zBrowser); fossil_system(zBrowser); } printf("Type Ctrl-C to stop the HTTP server\n"); for(;;){ SOCKET client; SOCKADDR_IN client_addr; HttpRequest *p; int len = sizeof(client_addr); client = accept(s, (struct sockaddr*)&client_addr, &len); |
| | | | | | | | |
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 ... 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 ... 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 ... 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
z = strstr(zHdr, "\r\n\r\n"); if( z ){ wanted = find_content_length(zHdr) + (&z[4]-zHdr) - amt; break; } } if( amt>=sizeof(zHdr) ) goto end_request; out = fossil_fopen(zRequestFName, "wb"); if( out==0 ) goto end_request; fwrite(zHdr, 1, amt, out); while( wanted>0 ){ got = recv(p->s, zHdr, sizeof(zHdr), 0); if( got==SOCKET_ERROR ) goto end_request; if( got ){ fwrite(zHdr, 1, got, out); ................................................................................ fclose(out); out = 0; sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr), p->zOptions ); fossil_system(zCmd); in = fossil_fopen(zReplyFName, "rb"); if( in ){ while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ send(p->s, zHdr, got, 0); } } end_request: if( out ) fclose(out); if( in ) fclose(in); closesocket(p->s); file_delete(zRequestFName); file_delete(zReplyFName); free(p); } /* ** Start a listening socket and process incoming HTTP requests on ** that socket. */ ................................................................................ WSADATA wd; SOCKET s = INVALID_SOCKET; SOCKADDR_IN addr; int idCnt = 0; int iPort = mnPort; Blob options; if( zStopper ) file_delete(zStopper); blob_zero(&options); if( zNotFound ){ blob_appendf(&options, " --notfound %s", zNotFound); } if( g.useLocalauth ){ blob_appendf(&options, " --localauth"); } ................................................................................ fossil_fatal("unable to open listening socket on ports %d", mnPort); }else{ fossil_fatal("unable to open listening socket on any" " port in the range %d..%d", mnPort, mxPort); } } zTempPrefix = mprintf("fossil_server_P%d_", iPort); fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); if( zBrowser ){ zBrowser = mprintf(zBrowser, iPort); fossil_print("Launch webbrowser: %s\n", zBrowser); fossil_system(zBrowser); } fossil_print("Type Ctrl-C to stop the HTTP server\n"); for(;;){ SOCKET client; SOCKADDR_IN client_addr; HttpRequest *p; int len = sizeof(client_addr); client = accept(s, (struct sockaddr*)&client_addr, &len); |
Changes to src/xfer.c.
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 .... 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 .... 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
if( g.argc!=2 && g.argc!=3 ){ usage("?MESSAGEFILE?"); } blob_zero(&g.cgiIn); blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]); disableLogin = 1; page_xfer(); printf("%s\n", cgi_extract_content(¬Used)); } /* ** Format strings for progress reporting. */ static const char zLabelFormat[] = "%-10s %10s %10s %10s %10s\n"; static const char zValueFormat[] = "\r%-10s %10d %10d %10d %10d\n"; ................................................................................ nCardSent = 0; nCardRcvd = 0; xfer.nFileSent = 0; xfer.nDeltaSent = 0; xfer.nGimmeSent = 0; xfer.nIGotSent = 0; if( !g.cgiOutput && !g.fQuiet ){ printf("waiting for server..."); } fflush(stdout); if( http_exchange(&send, &recv, cloneFlag==0 || nCycle>0) ){ nErr++; break; } lastPctDone = -1; ................................................................................ continue; } xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); nCardRcvd++; if( !g.cgiOutput && !g.fQuiet && recv.nUsed>0 ){ pctDone = (recv.iCursor*100)/recv.nUsed; if( pctDone!=lastPctDone ){ printf("\rprocessed: %d%% ", pctDone); lastPctDone = pctDone; fflush(stdout); } } /* file UUID SIZE \n CONTENT ** file UUID DELTASRC SIZE \n CONTENT |
| | | |
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 .... 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 .... 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
if( g.argc!=2 && g.argc!=3 ){ usage("?MESSAGEFILE?"); } blob_zero(&g.cgiIn); blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]); disableLogin = 1; page_xfer(); fossil_print("%s\n", cgi_extract_content(¬Used)); } /* ** Format strings for progress reporting. */ static const char zLabelFormat[] = "%-10s %10s %10s %10s %10s\n"; static const char zValueFormat[] = "\r%-10s %10d %10d %10d %10d\n"; ................................................................................ nCardSent = 0; nCardRcvd = 0; xfer.nFileSent = 0; xfer.nDeltaSent = 0; xfer.nGimmeSent = 0; xfer.nIGotSent = 0; if( !g.cgiOutput && !g.fQuiet ){ fossil_print("waiting for server..."); } fflush(stdout); if( http_exchange(&send, &recv, cloneFlag==0 || nCycle>0) ){ nErr++; break; } lastPctDone = -1; ................................................................................ continue; } xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); nCardRcvd++; if( !g.cgiOutput && !g.fQuiet && recv.nUsed>0 ){ pctDone = (recv.iCursor*100)/recv.nUsed; if( pctDone!=lastPctDone ){ fossil_print("\rprocessed: %d%% ", pctDone); lastPctDone = pctDone; fflush(stdout); } } /* file UUID SIZE \n CONTENT ** file UUID DELTASRC SIZE \n CONTENT |