Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the --private option to the "fossil commit" command. This option creates a private branch which is never pushed. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
02a584f7f5e58808cc8260b2914345d8 |
| User & Date: | drh 2009-08-26 18:25:48.000 |
Context
|
2009-08-26
| ||
| 18:40 | Update the FAQ to describe the new --private option on the commit command. ... (check-in: 85c6542a16 user: drh tags: trunk) | |
| 18:25 | Add the --private option to the "fossil commit" command. This option creates a private branch which is never pushed. ... (check-in: 02a584f7f5 user: drh tags: trunk) | |
|
2009-08-24
| ||
| 18:02 | Typos in the new selfhost.wiki document. ... (check-in: 93d0646830 user: drh tags: trunk) | |
Changes
Changes to src/checkin.c.
| ︙ | ︙ | |||
258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
int i;
blob_set(&text,
"\n"
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
"# The check-in comment follows wiki formatting rules.\n"
"#\n"
);
status_report(&text, "# ");
zEditor = db_get("editor", 0);
if( zEditor==0 ){
zEditor = getenv("VISUAL");
}
if( zEditor==0 ){
zEditor = getenv("EDITOR");
| > > > > > > > | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
int i;
blob_set(&text,
"\n"
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
"# The check-in comment follows wiki formatting rules.\n"
"#\n"
);
if( g.markPrivate ){
blob_append(&text,
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
"# repositories.\n"
"#\n", -1
);
}
status_report(&text, "# ");
zEditor = db_get("editor", 0);
if( zEditor==0 ){
zEditor = getenv("VISUAL");
}
if( zEditor==0 ){
zEditor = getenv("EDITOR");
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
** to be placed in the named branch. The --bgcolor option can be followed
** by a color name (ex: '#ffc0c0') to specify the background color of
** entries in the new branch when shown in the web timeline interface.
**
** A check-in is not permitted to fork unless the --force or -f
** option appears. A check-in is not allowed against a closed check-in.
**
** Options:
**
** --comment|-m COMMENT-TEXT
** --branch NEW-BRANCH-NAME
** --bgcolor COLOR
** --nosign
** --force|-f
**
*/
void commit_cmd(void){
int rc;
int vid, nrid, nvid;
Blob comment;
const char *zComment;
| > > > > | 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 |
** to be placed in the named branch. The --bgcolor option can be followed
** by a color name (ex: '#ffc0c0') to specify the background color of
** entries in the new branch when shown in the web timeline interface.
**
** A check-in is not permitted to fork unless the --force or -f
** option appears. A check-in is not allowed against a closed check-in.
**
** The --private option creates a private check-in that is never synced.
** Children of private check-ins are automatically private.
**
** Options:
**
** --comment|-m COMMENT-TEXT
** --branch NEW-BRANCH-NAME
** --bgcolor COLOR
** --nosign
** --force|-f
** --private
**
*/
void commit_cmd(void){
int rc;
int vid, nrid, nvid;
Blob comment;
const char *zComment;
|
| ︙ | ︙ | |||
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
url_proxy_options();
noSign = find_option("nosign",0,0)!=0;
zComment = find_option("comment","m",1);
forceFlag = find_option("force", "f", 0)!=0;
zBranch = find_option("branch","b",1);
zBgColor = find_option("bgcolor",0,1);
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
db_must_be_within_tree();
noSign = db_get_boolean("omitsign", 0)|noSign;
if( db_get_boolean("clearsign", 1)==0 ){ noSign = 1; }
verify_all_options();
/*
| > > > > > > > > > > > | > | > | 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 |
url_proxy_options();
noSign = find_option("nosign",0,0)!=0;
zComment = find_option("comment","m",1);
forceFlag = find_option("force", "f", 0)!=0;
zBranch = find_option("branch","b",1);
zBgColor = find_option("bgcolor",0,1);
if( find_option("private",0,0) ){
g.markPrivate = 1;
if( zBranch==0 ) zBranch = "private";
if( zBgColor==0 ) zBgColor = "#fec084"; /* Orange */
}
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
db_must_be_within_tree();
noSign = db_get_boolean("omitsign", 0)|noSign;
if( db_get_boolean("clearsign", 1)==0 ){ noSign = 1; }
verify_all_options();
/* Get the ID of the parent manifest artifact */
vid = db_lget_int("checkout", 0);
if( content_is_private(vid) ){
g.markPrivate = 1;
}
/*
** Autosync if autosync is enabled and this is not a private check-in.
*/
if( !g.markPrivate ){
autosync(AUTOSYNC_PULL);
}
/* There are two ways this command may be executed. If there are
** no arguments following the word "commit", then all modified files
** in the checked out directory are committed. If one or more arguments
** follows "commit", then only those files are committed.
**
** After the following function call has returned, the Global.aCommitFile[]
|
| ︙ | ︙ | |||
480 481 482 483 484 485 486 |
"SELECT pathname FROM vfile WHERE chnged = 0 AND file_is_selected(id)"
);
if( strlen(blob_str(&unmodified)) ){
fossil_panic("file %s has not changed", blob_str(&unmodified));
}
}
| < < | | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
"SELECT pathname FROM vfile WHERE chnged = 0 AND file_is_selected(id)"
);
if( strlen(blob_str(&unmodified)) ){
fossil_panic("file %s has not changed", blob_str(&unmodified));
}
}
/*
** Do not allow a commit that will cause a fork unless the --force flag
** is used or unless this is a private check-in.
*/
if( zBranch==0 && forceFlag==0 && g.markPrivate==0 && !is_a_leaf(vid) ){
fossil_fatal("would fork. \"update\" first or use -f or --force.");
}
/*
** Do not allow a commit against a closed leaf
*/
if( db_exists("SELECT 1 FROM tagxref"
|
| ︙ | ︙ | |||
556 557 558 559 560 561 562 |
blob_append(&comment, "(no comment)", -1);
}
blob_appendf(&manifest, "C %F\n", blob_str(&comment));
zDate = db_text(0, "SELECT datetime('%q')", zDateOvrd ? zDateOvrd : "now");
zDate[10] = 'T';
blob_appendf(&manifest, "D %s\n", zDate);
db_prepare(&q,
| | > > > | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
blob_append(&comment, "(no comment)", -1);
}
blob_appendf(&manifest, "C %F\n", blob_str(&comment));
zDate = db_text(0, "SELECT datetime('%q')", zDateOvrd ? zDateOvrd : "now");
zDate[10] = 'T';
blob_appendf(&manifest, "D %s\n", zDate);
db_prepare(&q,
"SELECT pathname, uuid, origname, blob.rid"
" FROM vfile JOIN blob ON vfile.mrid=blob.rid"
" WHERE NOT deleted AND vfile.vid=%d"
" ORDER BY 1", vid);
blob_zero(&filename);
blob_appendf(&filename, "%s/", g.zLocalRoot);
nBasename = blob_size(&filename);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zUuid = db_column_text(&q, 1);
const char *zOrig = db_column_text(&q, 2);
int frid = db_column_int(&q, 3);
const char *zPerm;
blob_append(&filename, zName, -1);
if( file_isexe(blob_str(&filename)) ){
zPerm = " x";
}else{
zPerm = "";
}
blob_resize(&filename, nBasename);
if( zOrig==0 || strcmp(zOrig,zName)==0 ){
blob_appendf(&manifest, "F %F %s%s\n", zName, zUuid, zPerm);
}else{
if( zPerm[0]==0 ){ zPerm = " w"; }
blob_appendf(&manifest, "F %F %s%s %F\n", zName, zUuid, zPerm, zOrig);
}
if( !g.markPrivate ) content_make_public(frid);
}
blob_reset(&filename);
db_finalize(&q);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
blob_appendf(&manifest, "P %s", zUuid);
db_prepare(&q2, "SELECT merge FROM vmerge WHERE id=:id");
db_bind_int(&q2, ":id", 0);
while( db_step(&q2)==SQLITE_ROW ){
int mid = db_column_int(&q2, 0);
if( !g.markPrivate && content_is_private(mid) ) continue;
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
if( zUuid ){
blob_appendf(&manifest, " %s", zUuid);
free(zUuid);
}
}
db_reset(&q2);
|
| ︙ | ︙ | |||
627 628 629 630 631 632 633 |
}
db_finalize(&q);
}
blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(&manifest, &mcksum);
blob_appendf(&manifest, "Z %b\n", &mcksum);
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
| | | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
}
db_finalize(&q);
}
blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(&manifest, &mcksum);
blob_appendf(&manifest, "Z %b\n", &mcksum);
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){
Blob ans;
blob_zero(&ans);
prompt_user("unable to sign manifest. continue [y/N]? ", &ans);
if( blob_str(&ans)[0]!='y' ){
db_end_transaction(1);
exit(1);
}
|
| ︙ | ︙ | |||
700 701 702 703 704 705 706 | /* Clear the undo/redo stack */ undo_reset(); /* Commit */ db_end_transaction(0); | > | > | 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
/* Clear the undo/redo stack */
undo_reset();
/* Commit */
db_end_transaction(0);
if( !g.markPrivate ){
autosync(AUTOSYNC_PUSH);
}
if( count_nonbranch_children(vid)>1 ){
printf("**** warning: a fork has occurred *****\n");
}
}
/*
** COMMAND: test-import-manifest
|
| ︙ | ︙ |
Changes to src/clone.c.
| ︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
db_multi_exec(
"REPLACE INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"REPLACE INTO config(name,value)"
" VALUES('last-sync-url', '%q');",
g.urlCanonical
);
g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
if( g.zLogin==0 ){
db_create_default_users(1);
}
printf("Repository cloned into %s\n", g.argv[3]);
}else{
db_create_repository(g.argv[3]);
| > > > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
db_multi_exec(
"REPLACE INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"REPLACE INTO config(name,value)"
" VALUES('last-sync-url', '%q');",
g.urlCanonical
);
db_multi_exec(
"DELETE FROM blob WHERE rid IN private;"
"DELETE FROM delta wHERE rid IN private;"
"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);
}
printf("Repository cloned into %s\n", g.argv[3]);
}else{
db_create_repository(g.argv[3]);
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
);
db_bind_blob(&s1, ":data", &cmpr);
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
}
blob_reset(&cmpr);
/* If the srcId is specified, then the data we just added is
** really a delta. Record this fact in the delta table.
*/
if( srcId ){
| > > > > | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
);
db_bind_blob(&s1, ":data", &cmpr);
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
if( g.markPrivate ){
db_multi_exec("INSERT INTO private VALUES(%d)", rid);
markAsUnclustered = 0;
}
}
blob_reset(&cmpr);
/* If the srcId is specified, then the data we just added is
** really a delta. Record this fact in the delta table.
*/
if( srcId ){
|
| ︙ | ︙ | |||
508 509 510 511 512 513 514 |
db_exec(&s1);
rid = db_last_insert_rowid();
db_static_prepare(&s2,
"INSERT INTO phantom VALUES(:rid)"
);
db_bind_int(&s2, ":rid", rid);
db_exec(&s2);
| > > > | | | | | > | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
db_exec(&s1);
rid = db_last_insert_rowid();
db_static_prepare(&s2,
"INSERT INTO phantom VALUES(:rid)"
);
db_bind_int(&s2, ":rid", rid);
db_exec(&s2);
if( g.markPrivate ){
db_multi_exec("INSERT INTO private VALUES(%d)", rid);
}else{
db_static_prepare(&s3,
"INSERT INTO unclustered VALUES(:rid)"
);
db_bind_int(&s3, ":rid", rid);
db_exec(&s3);
}
bag_insert(&contentCache.missing, rid);
db_end_transaction(0);
return rid;
}
/*
|
| ︙ | ︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
void test_content_undelta_cmd(void){
int rid;
if( g.argc!=2 ) usage("RECORDID");
db_must_be_within_tree();
rid = atoi(g.argv[2]);
content_undelta(rid);
}
/*
** Change the storage of rid so that it is a delta of srcid.
**
** If rid is already a delta from some other place then no
** conversion occurs and this is a no-op unless force==1.
**
** If srcid is a delta that depends on rid, then srcid is
** converted to undeltaed text.
**
** If either rid or srcid contain less than 50 bytes, or if the
** resulting delta does not achieve a compression of at least 25% on
** its own the rid is left untouched.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < > > > > > > > > > > > > < | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
void test_content_undelta_cmd(void){
int rid;
if( g.argc!=2 ) usage("RECORDID");
db_must_be_within_tree();
rid = atoi(g.argv[2]);
content_undelta(rid);
}
/*
** Return true if the given RID is marked as PRIVATE.
*/
int content_is_private(int rid){
static Stmt s1;
int rc;
db_static_prepare(&s1,
"SELECT 1 FROM private WHERE rid=:rid"
);
db_bind_int(&s1, ":rid", rid);
rc = db_step(&s1);
db_reset(&s1);
return rc==SQLITE_ROW;
}
/*
** Make sure an artifact is public.
*/
void content_make_public(int rid){
static Stmt s1;
db_static_prepare(&s1,
"DELETE FROM private WHERE rid=:rid"
);
db_bind_int(&s1, ":rid", rid);
db_exec(&s1);
}
/*
** Change the storage of rid so that it is a delta of srcid.
**
** If rid is already a delta from some other place then no
** conversion occurs and this is a no-op unless force==1.
**
** Never generate a delta that carries a private artifact into a public
** artifact. Otherwise, when we go to send the public artifact on a
** sync operation, the other end of the sync will never be able to receive
** the source of the delta. It is OK to delta private->private and
** public->private and public->public. Just no private->public delta.
**
** If srcid is a delta that depends on rid, then srcid is
** converted to undeltaed text.
**
** If either rid or srcid contain less than 50 bytes, or if the
** resulting delta does not achieve a compression of at least 25% on
** its own the rid is left untouched.
*/
void content_deltify(int rid, int srcid, int force){
int s;
Blob data, src, delta;
Stmt s1, s2;
if( srcid==rid ) return;
if( !force && findSrcid(rid)>0 ) return;
if( content_is_private(srcid) && !content_is_private(rid) ){
return;
}
s = srcid;
while( (s = findSrcid(s))>0 ){
if( s==rid ){
content_undelta(srcid);
break;
}
}
content_get(srcid, &src);
if( blob_size(&src)<50 ){
blob_reset(&src);
return;
}
content_get(rid, &data);
if( blob_size(&data)<50 ){
blob_reset(&src);
blob_reset(&data);
return;
}
blob_delta_create(&src, &data, &delta);
if( blob_size(&delta) < blob_size(&data)*0.75 ){
blob_compress(&delta, &delta);
db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, srcid);
db_bind_blob(&s1, ":data", &delta);
db_begin_transaction();
db_exec(&s1);
db_exec(&s2);
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
if( nChng>0 ){
int nrid;
Blob cksum;
blob_appendf(&ctrl, "U %F\n", g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
db_begin_transaction();
nrid = content_put(&ctrl, 0, 0);
manifest_crosslink(nrid, &ctrl);
db_end_transaction(0);
}
cgi_redirectf("ci?name=%d", rid);
}
blob_zero(&comment);
| > | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
if( nChng>0 ){
int nrid;
Blob cksum;
blob_appendf(&ctrl, "U %F\n", g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
db_begin_transaction();
g.markPrivate = content_is_private(rid);
nrid = content_put(&ctrl, 0, 0);
manifest_crosslink(nrid, &ctrl);
db_end_transaction(0);
}
cgi_redirectf("ci?name=%d", rid);
}
blob_zero(&comment);
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
79 80 81 82 83 84 85 | int xferPanic; /* Write error messages in XFER protocol */ int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ Th_Interp *interp; /* The TH1 interpreter */ FILE *httpIn; /* Accept HTTP input from here */ FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */ | < > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | int xferPanic; /* Write error messages in XFER protocol */ int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ Th_Interp *interp; /* The TH1 interpreter */ FILE *httpIn; /* Accept HTTP input from here */ FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */ int *aCommitFile; /* Array of files to be committed */ int markPrivate; /* All new artifacts are private if true */ int urlIsFile; /* True if a "file:" url */ int urlIsHttps; /* True if a "https:" url */ char *urlName; /* Hostname for http: or filename for file: */ char *urlHostname; /* The HOST: parameter on http headers */ char *urlProtocol; /* "http" or "https" */ int urlPort; /* TCP port number for http: or https: */ |
| ︙ | ︙ |
Changes to src/shun.c.
| ︙ | ︙ | |||
190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
content_undelta(srcid);
}
db_finalize(&q);
db_multi_exec(
"DELETE FROM delta WHERE rid IN toshun;"
"DELETE FROM blob WHERE rid IN toshun;"
"DROP TABLE toshun;"
);
}
/*
** WEBPAGE: rcvfromlist
**
** Show a listing of RCVFROM table entries.
| > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
content_undelta(srcid);
}
db_finalize(&q);
db_multi_exec(
"DELETE FROM delta WHERE rid IN toshun;"
"DELETE FROM blob WHERE rid IN toshun;"
"DROP TABLE toshun;"
"DELETE FROM private "
" WHERE NOT EXISTS (SELECT 1 FROM blob WHERE rid=private.rid);"
);
}
/*
** WEBPAGE: rcvfromlist
**
** Show a listing of RCVFROM table entries.
|
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
fossil_fatal("tag should begin with '+', '*', or '-'");
return;
}
rid = name_to_rid(g.argv[3]);
if( rid==0 ){
fossil_fatal("no such object: %s", g.argv[3]);
}
zValue = g.argc==5 ? g.argv[4] : 0;
db_begin_transaction();
tag_insert(zTag, tagtype, zValue, -1, 0.0, rid);
db_end_transaction(0);
}
/*
| > | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
fossil_fatal("tag should begin with '+', '*', or '-'");
return;
}
rid = name_to_rid(g.argv[3]);
if( rid==0 ){
fossil_fatal("no such object: %s", g.argv[3]);
}
g.markPrivate = content_is_private(rid);
zValue = g.argc==5 ? g.argv[4] : 0;
db_begin_transaction();
tag_insert(zTag, tagtype, zValue, -1, 0.0, rid);
db_end_transaction(0);
}
/*
|
| ︙ | ︙ | |||
274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
blob_zero(&uuid);
blob_append(&uuid, zObjName, -1);
if( name_to_uuid(&uuid, 9) ){
fossil_fatal("%s", g.zErrMsg);
return;
}
rid = name_to_rid(blob_str(&uuid));
blob_zero(&ctrl);
#if 0
if( validate16(zTagname, strlen(zTagname)) ){
fossil_fatal(
"invalid tag name \"%s\" - might be confused with"
" a hexadecimal artifact ID",
| > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
blob_zero(&uuid);
blob_append(&uuid, zObjName, -1);
if( name_to_uuid(&uuid, 9) ){
fossil_fatal("%s", g.zErrMsg);
return;
}
rid = name_to_rid(blob_str(&uuid));
g.markPrivate = content_is_private(rid);
blob_zero(&ctrl);
#if 0
if( validate16(zTagname, strlen(zTagname)) ){
fossil_fatal(
"invalid tag name \"%s\" - might be confused with"
" a hexadecimal artifact ID",
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
**
** The content is SIZE bytes immediately following the newline.
** If DELTASRC exists, then the CONTENT is a delta against the
** content of DELTASRC.
**
** If any error occurs, write a message into pErr which has already
** be initialized to an empty string.
*/
static void xfer_accept_file(Xfer *pXfer){
int n;
int rid;
int srcid = 0;
Blob content, hash;
| > > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
**
** The content is SIZE bytes immediately following the newline.
** If DELTASRC exists, then the CONTENT is a delta against the
** content of DELTASRC.
**
** If any error occurs, write a message into pErr which has already
** be initialized to an empty string.
**
** Any artifact successfully received by this routine is considered to
** be public and is therefore removed from the "private" table.
*/
static void xfer_accept_file(Xfer *pXfer){
int n;
int rid;
int srcid = 0;
Blob content, hash;
|
| ︙ | ︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
if( pXfer->nToken==4 ){
Blob src;
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
if( content_get(srcid, &src)==0 ){
rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
pXfer->nDanglingFile++;
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
return;
}
pXfer->nDeltaRcvd++;
blob_delta_apply(&src, &content, &content);
blob_reset(&src);
}else{
pXfer->nFileRcvd++;
}
sha1sum_blob(&content, &hash);
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
blob_appendf(&pXfer->err, "content does not match sha1 hash");
}
rid = content_put(&content, blob_str(&hash), 0);
blob_reset(&hash);
if( rid==0 ){
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
}else{
| > | > > | 129 130 131 132 133 134 135 136 137 138 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 |
if( pXfer->nToken==4 ){
Blob src;
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
if( content_get(srcid, &src)==0 ){
rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
pXfer->nDanglingFile++;
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
content_make_public(rid);
return;
}
pXfer->nDeltaRcvd++;
blob_delta_apply(&src, &content, &content);
blob_reset(&src);
}else{
pXfer->nFileRcvd++;
}
sha1sum_blob(&content, &hash);
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
blob_appendf(&pXfer->err, "content does not match sha1 hash");
}
rid = content_put(&content, blob_str(&hash), 0);
blob_reset(&hash);
if( rid==0 ){
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
}else{
content_make_public(rid);
manifest_crosslink(rid, &content);
}
remote_has(rid);
}
/*
** Try to send a file as a delta against its parent.
** If successful, return the number of bytes in the delta.
** If we cannot generate an appropriate delta, then send
** nothing and return zero.
**
** Never send a delta against a private artifact.
*/
static int send_delta_parent(
Xfer *pXfer, /* The transfer context */
int rid, /* record id of the file to send */
Blob *pContent, /* The content of the file to send */
Blob *pUuid /* The UUID of the file to send */
){
|
| ︙ | ︙ | |||
182 183 184 185 186 187 188 |
Blob src, delta;
int size = 0;
int srcId = 0;
for(i=0; srcId==0 && i<count(azQuery); i++){
srcId = db_int(0, azQuery[i], rid);
}
| | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
Blob src, delta;
int size = 0;
int srcId = 0;
for(i=0; srcId==0 && i<count(azQuery); i++){
srcId = db_int(0, azQuery[i], rid);
}
if( srcId>0 && !content_is_private(srcId) && content_get(srcId, &src) ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", srcId);
blob_delta_create(&src, pContent, &delta);
size = blob_size(&delta);
if( size>=blob_size(pContent)-50 ){
size = 0;
}else if( uuid_is_shunned(zUuid) ){
size = 0;
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
}
/*
** Try to send a file as a native delta.
** If successful, return the number of bytes in the delta.
** If we cannot generate an appropriate delta, then send
** nothing and return zero.
*/
static int send_delta_native(
Xfer *pXfer, /* The transfer context */
int rid, /* record id of the file to send */
Blob *pUuid /* The UUID of the file to send */
){
Blob src, delta;
int size = 0;
int srcId;
srcId = db_int(0, "SELECT srcid FROM delta WHERE rid=%d", rid);
| > > | | 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 |
}
/*
** Try to send a file as a native delta.
** If successful, return the number of bytes in the delta.
** If we cannot generate an appropriate delta, then send
** nothing and return zero.
**
** Never send a delta against a private artifact.
*/
static int send_delta_native(
Xfer *pXfer, /* The transfer context */
int rid, /* record id of the file to send */
Blob *pUuid /* The UUID of the file to send */
){
Blob src, delta;
int size = 0;
int srcId;
srcId = db_int(0, "SELECT srcid FROM delta WHERE rid=%d", rid);
if( srcId>0 && !content_is_private(srcId) ){
blob_zero(&src);
db_blob(&src, "SELECT uuid FROM blob WHERE rid=%d", srcId);
if( uuid_is_shunned(blob_str(&src)) ){
blob_reset(&src);
return 0;
}
blob_zero(&delta);
|
| ︙ | ︙ | |||
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
** Send the file identified by rid.
**
** The pUuid can be NULL in which case the correct UUID is computed
** from the rid.
**
** Try to send the file as a native delta if nativeDelta is true, or
** as a parent delta if nativeDelta is false.
*/
static void send_file(Xfer *pXfer, int rid, Blob *pUuid, int nativeDelta){
Blob content, uuid;
int size = 0;
if( db_exists("SELECT 1 FROM onremote WHERE rid=%d", rid) ){
return;
}
blob_zero(&uuid);
db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
if( blob_size(&uuid)==0 ){
return;
| > > > > > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
** Send the file identified by rid.
**
** The pUuid can be NULL in which case the correct UUID is computed
** from the rid.
**
** Try to send the file as a native delta if nativeDelta is true, or
** as a parent delta if nativeDelta is false.
**
** It should never be the case that rid is a private artifact. But
** as a precaution, this routine does check on rid and if it is private
** this routine becomes a no-op.
*/
static void send_file(Xfer *pXfer, int rid, Blob *pUuid, int nativeDelta){
Blob content, uuid;
int size = 0;
if( content_is_private(rid) ) return;
if( db_exists("SELECT 1 FROM onremote WHERE rid=%d", rid) ){
return;
}
blob_zero(&uuid);
db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
if( blob_size(&uuid)==0 ){
return;
|
| ︙ | ︙ | |||
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
}
remote_has(rid);
blob_reset(&uuid);
}
/*
** Send a gimme message for every phantom.
*/
static void request_phantoms(Xfer *pXfer, int maxReq){
Stmt q;
db_prepare(&q,
"SELECT uuid FROM phantom JOIN blob USING(rid)"
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
);
while( db_step(&q)==SQLITE_ROW && maxReq-- > 0 ){
const char *zUuid = db_column_text(&q, 0);
blob_appendf(pXfer->pOut, "gimme %s\n", zUuid);
pXfer->nGimmeSent++;
}
db_finalize(&q);
| > > > > | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
}
remote_has(rid);
blob_reset(&uuid);
}
/*
** Send a gimme message for every phantom.
**
** It should not be possible to have a private phantom. But just to be
** sure, take care not to send any "gimme" messagse on private artifacts.
*/
static void request_phantoms(Xfer *pXfer, int maxReq){
Stmt q;
db_prepare(&q,
"SELECT uuid FROM phantom JOIN blob USING(rid)"
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
" AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
);
while( db_step(&q)==SQLITE_ROW && maxReq-- > 0 ){
const char *zUuid = db_column_text(&q, 0);
blob_appendf(pXfer->pOut, "gimme %s\n", zUuid);
pXfer->nGimmeSent++;
}
db_finalize(&q);
|
| ︙ | ︙ | |||
399 400 401 402 403 404 405 |
**
** This is really just an optimization. If you clear the
** unsent table, all the right files will still get transferred.
** It just might require an extra round trip or two.
*/
static void send_unsent(Xfer *pXfer){
Stmt q;
| | > > > > > > > | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 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 |
**
** This is really just an optimization. If you clear the
** unsent table, all the right files will still get transferred.
** It just might require an extra round trip or two.
*/
static void send_unsent(Xfer *pXfer){
Stmt q;
db_prepare(&q, "SELECT rid FROM unsent EXCEPT SELECT rid FROM private");
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
send_file(pXfer, rid, 0, 0);
}
db_finalize(&q);
db_multi_exec("DELETE FROM unsent");
}
/*
** Check to see if the number of unclustered entries is greater than
** 100 and if it is, form a new cluster. Unclustered phantoms do not
** count toward the 100 total. And phantoms are never added to a new
** cluster.
*/
static void create_cluster(void){
Blob cluster, cksum;
Stmt q;
int nUncl;
/* We should not ever get any private artifacts in the unclustered table.
** But if we do (because of a bug) now is a good time to delete them. */
db_multi_exec(
"DELETE FROM unclustered WHERE rid IN (SELECT rid FROM private)"
);
nUncl = db_int(0, "SELECT count(*) FROM unclustered"
" WHERE NOT EXISTS(SELECT 1 FROM phantom"
" WHERE rid=unclustered.rid)");
if( nUncl<100 ){
return;
}
blob_zero(&cluster);
|
| ︙ | ︙ | |||
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
*/
static int send_unclustered(Xfer *pXfer){
Stmt q;
int cnt = 0;
db_prepare(&q,
"SELECT uuid FROM unclustered JOIN blob USING(rid)"
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
cnt++;
}
db_finalize(&q);
return cnt;
}
/*
** Send an igot message for every artifact.
*/
static void send_all(Xfer *pXfer){
Stmt q;
db_prepare(&q,
"SELECT uuid FROM blob "
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
| > > | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
*/
static int send_unclustered(Xfer *pXfer){
Stmt q;
int cnt = 0;
db_prepare(&q,
"SELECT uuid FROM unclustered JOIN blob USING(rid)"
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
" AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
cnt++;
}
db_finalize(&q);
return cnt;
}
/*
** Send an igot message for every artifact.
*/
static void send_all(Xfer *pXfer){
Stmt q;
db_prepare(&q,
"SELECT uuid FROM blob "
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
" AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
|
| ︙ | ︙ | |||
1034 1035 1036 1037 1038 1039 1040 |
** not transmit it by accident.
*/
if( xfer.nToken==2
&& blob_eq(&xfer.aToken[0], "igot")
&& blob_is_uuid(&xfer.aToken[1])
){
int rid = rid_from_uuid(&xfer.aToken[1], 0);
| > > | | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
** not transmit it by accident.
*/
if( xfer.nToken==2
&& blob_eq(&xfer.aToken[0], "igot")
&& blob_is_uuid(&xfer.aToken[1])
){
int rid = rid_from_uuid(&xfer.aToken[1], 0);
if( rid>0 ){
content_make_public(rid);
}else if( pullFlag || cloneFlag ){
rid = content_new(blob_str(&xfer.aToken[1]));
if( rid ) newPhantom = 1;
}
remote_has(rid);
}else
|
| ︙ | ︙ |