Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge the delta-manifest enhancement into the trunk. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
d13054ce84eaa950dd661a5dac11941f |
| User & Date: | drh 2010-10-26 12:51:53.000 |
Context
|
2010-10-26
| ||
| 18:29 | Change the "artifact" command to accept the -R or --repository command-line options. Ticket [d3ab7965c636275e51]. ... (check-in: d6e21fddd3 user: drh tags: trunk) | |
| 12:51 | Merge the delta-manifest enhancement into the trunk. ... (check-in: d13054ce84 user: drh tags: trunk) | |
|
2010-10-25
| ||
| 21:47 | Improvements and minor bug fixes in "browse" processing. ... (Closed-Leaf check-in: b27d50b421 user: drh tags: experimental) | |
|
2010-10-16
| ||
| 16:24 | Do not attempt to parse control artifacts that do not end with a '\n' character. Ticket [be56c89def7f86bcbd] ... (check-in: 7954ccba68 user: drh tags: trunk) | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 | char *zUuid; /* Artifact ID of origin */ Stmt q; /* Generic query */ const char *zBranch; /* Name of the new branch */ char *zDate; /* Date that branch was created */ char *zComment; /* Check-in comment for the new branch */ const char *zColor; /* Color of the new branch */ Blob branch; /* manifest for the new branch */ | < | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
char *zUuid; /* Artifact ID of origin */
Stmt q; /* Generic query */
const char *zBranch; /* Name of the new branch */
char *zDate; /* Date that branch was created */
char *zComment; /* Check-in comment for the new branch */
const char *zColor; /* Color of the new branch */
Blob branch; /* manifest for the new branch */
Manifest *pParent; /* Parsed parent manifest */
Blob mcksum; /* Self-checksum on the manifest */
const char *zDateOvrd; /* Override date string */
const char *zUserOvrd; /* Override user name */
noSign = find_option("nosign","",0)!=0;
zColor = find_option("bgcolor","c",1);
zDateOvrd = find_option("date-override",0,1);
|
| ︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
user_select();
db_begin_transaction();
rootid = name_to_rid(g.argv[4]);
if( rootid==0 ){
fossil_fatal("unable to locate check-in off of which to branch");
}
/* Create a manifest for the new branch */
blob_zero(&branch);
zComment = mprintf("Create new branch named \"%h\"", zBranch);
blob_appendf(&branch, "C %F\n", zComment);
zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
zDate[10] = 'T';
blob_appendf(&branch, "D %s\n", zDate);
/* Copy all of the content from the parent into the branch */
| > > > > > > > > < < < < < | < | | | | < | < < | | > > | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 |
user_select();
db_begin_transaction();
rootid = name_to_rid(g.argv[4]);
if( rootid==0 ){
fossil_fatal("unable to locate check-in off of which to branch");
}
pParent = manifest_get(rootid, CFTYPE_MANIFEST);
if( pParent==0 ){
fossil_fatal("%s is not a valid check-in", g.argv[4]);
}
/* Create a manifest for the new branch */
blob_zero(&branch);
if( pParent->zBaseline ){
blob_appendf(&branch, "B %s\n", pParent->zBaseline);
}
zComment = mprintf("Create new branch named \"%h\"", zBranch);
blob_appendf(&branch, "C %F\n", zComment);
zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
zDate[10] = 'T';
blob_appendf(&branch, "D %s\n", zDate);
/* Copy all of the content from the parent into the branch */
for(i=0; i<pParent->nFile; ++i){
blob_appendf(&branch, "F %F", pParent->aFile[i].zName);
if( pParent->aFile[i].zUuid ){
blob_appendf(&branch, " %s", pParent->aFile[i].zUuid);
if( pParent->aFile[i].zPerm[0] ){
blob_appendf(&branch, " %s", pParent->aFile[i].zPerm);
}
}
blob_append(&branch, "\n", 1);
}
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rootid);
blob_appendf(&branch, "P %s\n", zUuid);
blob_appendf(&branch, "R %s\n", pParent->zRepoCksum);
manifest_destroy(pParent);
/* Add the symbolic branch name and the "branch" tag to identify
** this as a new branch */
if( zColor!=0 ){
blob_appendf(&branch, "T *bgcolor * %F\n", zColor);
}
blob_appendf(&branch, "T *branch * %F\n", zBranch);
|
| ︙ | ︙ |
Changes to src/browse.c.
| ︙ | ︙ | |||
69 70 71 72 73 74 75 | ** to the "dir" page for the directory. ** ** There is no hyperlink on the file element of the path. ** ** The computed string is appended to the pOut blob. pOut should ** have already been initialized. */ | | > > > > | | > > < | | | | < < > | > > > > > | | > > | > < > > > | > | > > | > > > > > | | > > > < < < < < | | | | | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 124 125 126 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 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 |
** to the "dir" page for the directory.
**
** There is no hyperlink on the file element of the path.
**
** The computed string is appended to the pOut blob. pOut should
** have already been initialized.
*/
void hyperlinked_path(const char *zPath, Blob *pOut, const char *zCI){
int i, j;
char *zSep = "";
for(i=0; zPath[i]; i=j){
for(j=i; zPath[j] && zPath[j]!='/'; j++){}
if( zPath[j] && g.okHistory ){
if( zCI ){
blob_appendf(pOut, "%s<a href=\"%s/dir?ci=%S&name=%#T\">%#h</a>",
zSep, g.zBaseURL, zCI, j, zPath, j-i, &zPath[i]);
}else{
blob_appendf(pOut, "%s<a href=\"%s/dir?name=%#T\">%#h</a>",
zSep, g.zBaseURL, j, zPath, j-i, &zPath[i]);
}
}else{
blob_appendf(pOut, "%s%#h", zSep, j-i, &zPath[i]);
}
zSep = "/";
while( zPath[j]=='/' ){ j++; }
}
}
/*
** WEBPAGE: dir
**
** Query parameters:
**
** name=PATH Directory to display. Required.
** ci=LABEL Show only files in this check-in. Optional.
*/
void page_dir(void){
const char *zD = P("name");
int nD = zD ? strlen(zD)+1 : 0;
int mxLen;
int nCol, nRow;
int cnt, i;
char *zPrefix;
Stmt q;
const char *zCI = P("ci");
int rid = 0;
char *zUuid = 0;
Blob dirname;
Manifest *pM = 0;
const char *zSubdirLink;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
style_header("File List");
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
pathelementFunc, 0, 0);
/* If the name= parameter is an empty string, make it a NULL pointer */
if( zD && strlen(zD)==0 ){ zD = 0; }
/* If a specific check-in is requested, fetch and parse it. If the
** specific check-in does not exist, clear zCI. zCI==0 will cause all
** files from all check-ins to be displayed.
*/
if( zCI ){
pM = manifest_get_by_name(zCI, &rid);
if( pM ){
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
}else{
zCI = 0;
}
}
/* Compute the title of the page */
blob_zero(&dirname);
if( zD ){
blob_append(&dirname, "in directory ", -1);
hyperlinked_path(zD, &dirname, zCI);
zPrefix = mprintf("%h/", zD);
}else{
blob_append(&dirname, "in the top-level directory", -1);
zPrefix = "";
}
if( zCI ){
char zShort[20];
memcpy(zShort, zUuid, 10);
zShort[10] = 0;
@ <h2>Files of check-in [<a href="vinfo?name=%T(zUuid)">%s(zShort)</a>]
@ %s(blob_str(&dirname))</h2>
zSubdirLink = mprintf("%s/dir?ci=%S&name=%T", g.zTop, zUuid, zPrefix);
if( zD ){
style_submenu_element("Top", "Top", "%s/dir?ci=%S", g.zTop, zUuid);
style_submenu_element("All", "All", "%s/dir?name=%t", g.zTop, zD);
}else{
style_submenu_element("All", "All", "%s/dir", g.zBaseURL);
}
}else{
int hasTrunk;
@ <h2>The union of all files from all check-ins
@ %s(blob_str(&dirname))</h2>
hasTrunk = db_exists(
"SELECT 1 FROM tagxref WHERE tagid=%d AND value='trunk'",
TAG_BRANCH);
zSubdirLink = mprintf("%s/dir?name=%T", g.zBaseURL, zPrefix);
if( zD ){
style_submenu_element("Top", "Top", "%s/dir", g.zBaseURL);
style_submenu_element("Tip", "Tip", "%s/dir?name=%t&ci=tip",
g.zBaseURL, zD);
if( hasTrunk ){
style_submenu_element("Trunk", "Trunk", "%s/dir?name=%t&ci=trunk",
g.zBaseURL,zD);
}
}else{
style_submenu_element("Tip", "Tip", "%s/dir?ci=tip", g.zBaseURL);
if( hasTrunk ){
style_submenu_element("Trunk", "Trunk", "%s/dir?ci=trunk", g.zBaseURL);
}
}
}
/* Compute the temporary table "localfiles" containing the names
** of all files and subdirectories in the zD[] directory.
**
** Subdirectory names begin with "/". This causes them to sort
** first and it also gives us an easy way to distinguish files
** from directories in the loop that follows.
*/
db_multi_exec(
"CREATE TEMP TABLE localfiles(x UNIQUE NOT NULL, u);"
);
if( zCI ){
Stmt ins;
ManifestFile *pFile;
ManifestFile *pPrev = 0;
int nPrev = 0;
int c;
db_prepare(&ins,
"INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
);
manifest_file_rewind(pM);
while( (pFile = manifest_file_next(pM,0))!=0 ){
if( nD>0 && memcmp(pFile->zName, zD, nD-1)!=0 ) continue;
if( pPrev && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 ){
continue;
}
db_bind_text(&ins, ":x", &pFile->zName[nD]);
db_bind_text(&ins, ":u", pFile->zUuid);
db_step(&ins);
db_reset(&ins);
pPrev = pFile;
for(nPrev=0; (c=pPrev->zName[nD+nPrev]) && c!='/'; nPrev++){}
if( c=='/' ) nPrev++;
}
db_finalize(&ins);
}else if( zD ){
db_multi_exec(
"INSERT OR IGNORE INTO localfiles"
" SELECT pathelement(name,%d), NULL FROM filename"
" WHERE name GLOB '%q/*'",
nD, zD
);
}else{
db_multi_exec(
"INSERT OR IGNORE INTO localfiles"
" SELECT pathelement(name,0), NULL FROM filename"
);
}
/* Generate a multi-column table listing the contents of zD[]
** directory.
*/
mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
|
| ︙ | ︙ | |||
244 245 246 247 248 249 250 251 252 253 |
@ <li><a href="%s(g.zBaseURL)/artifact?name=%s(zUuid)">%h(zFN)</a></li>
}else{
@ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFN)">%h(zFN)
@ </a></li>
}
}
db_finalize(&q);
@ </ul></td></tr></table>
style_footer();
}
| > | 264 265 266 267 268 269 270 271 272 273 274 |
@ <li><a href="%s(g.zBaseURL)/artifact?name=%s(zUuid)">%h(zFN)</a></li>
}else{
@ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFN)">%h(zFN)
@ </a></li>
}
}
db_finalize(&q);
manifest_destroy(pM);
@ </ul></td></tr></table>
style_footer();
}
|
Changes to src/checkin.c.
| ︙ | ︙ | |||
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
void extra_cmd(void){
Blob path;
Blob repo;
Stmt q;
int n;
const char *zIgnoreFlag = find_option("ignore",0,1);
int allFlag = find_option("dotfiles",0,0)!=0;
db_must_be_within_tree();
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
n = strlen(g.zLocalRoot);
blob_init(&path, g.zLocalRoot, n-1);
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
vfile_scan(0, &path, blob_size(&path), allFlag);
db_prepare(&q,
"SELECT x FROM sfile"
| > | > > | 257 258 259 260 261 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 |
void extra_cmd(void){
Blob path;
Blob repo;
Stmt q;
int n;
const char *zIgnoreFlag = find_option("ignore",0,1);
int allFlag = find_option("dotfiles",0,0)!=0;
int outputManifest = db_get_boolean("manifest",0);
db_must_be_within_tree();
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
n = strlen(g.zLocalRoot);
blob_init(&path, g.zLocalRoot, n-1);
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
vfile_scan(0, &path, blob_size(&path), allFlag);
db_prepare(&q,
"SELECT x FROM sfile"
" WHERE x NOT IN ('%s','%s','_FOSSIL_',"
"'_FOSSIL_-journal','.fos','.fos-journal',"
"'_FOSSIL_-wal','_FOSSIL_-shm','.fos-wal',"
"'.fos-shm')"
" AND NOT %s"
" ORDER BY 1",
outputManifest ? "manifest" : "_FOSSIL_",
outputManifest ? "manifest.uuid" : "_FOSSIL_",
glob_expr("x", zIgnoreFlag)
);
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));
|
| ︙ | ︙ | |||
535 536 537 538 539 540 541 | assert( strlen(zDate)==19 ); assert( zDate[10]==' ' ); zDate[10] = 'T'; return zDate; } /* | < < | < < < > > > > > > > > > > | > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 538 539 540 541 542 543 544 545 546 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 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 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
assert( strlen(zDate)==19 );
assert( zDate[10]==' ' );
zDate[10] = 'T';
return zDate;
}
/*
** Create a manifest.
*/
static void create_manifest(
Blob *pOut, /* Write the manifest here */
const char *zBaselineUuid, /* UUID of baseline, or zero */
Manifest *pBaseline, /* Make it a delta manifest if not zero */
Blob *pComment, /* Check-in comment text */
int vid, /* blob-id of the parent manifest */
int verifyDate, /* Verify that child is younger */
Blob *pCksum, /* Repository checksum. May be 0 */
const char *zDateOvrd, /* Date override. If 0 then use 'now' */
const char *zUserOvrd, /* User override. If 0 then use g.zLogin */
const char *zBranch, /* Branch name. May be 0 */
const char *zBgColor, /* Background color. May be 0 */
int *pnFBcard /* Number of generated B- and F-cards */
){
char *zDate; /* Date of the check-in */
char *zParentUuid; /* UUID of parent check-in */
Blob filename; /* A single filename */
int nBasename; /* Size of base filename */
Stmt q; /* Query of files changed */
Stmt q2; /* Query of merge parents */
Blob mcksum; /* Manifest checksum */
ManifestFile *pFile; /* File from the baseline */
int nFBcard = 0; /* Number of B-cards and F-cards */
assert( pBaseline==0 || pBaseline->zBaseline==0 );
assert( pBaseline==0 || zBaselineUuid!=0 );
blob_zero(pOut);
zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
if( pBaseline ){
blob_appendf(pOut, "B %s\n", zBaselineUuid);
manifest_file_rewind(pBaseline);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}else{
pFile = 0;
}
blob_appendf(pOut, "C %F\n", blob_str(pComment));
zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
blob_appendf(pOut, "D %s\n", zDate);
zDate[10] = ' ';
db_prepare(&q,
"SELECT pathname, uuid, origname, blob.rid, isexe"
" 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);
int isexe = db_column_int(&q, 4);
const char *zPerm;
int cmp;
blob_append(&filename, zName, -1);
#if !defined(_WIN32)
/* For unix, extract the "executable" permission bit directly from
** the filesystem. On windows, the "executable" bit is retained
** unchanged from the original. */
isexe = file_isexe(blob_str(&filename));
#endif
if( isexe ){
zPerm = " x";
}else{
zPerm = "";
}
if( !g.markPrivate ) content_make_public(frid);
while( pFile && strcmp(pFile->zName,zName)<0 ){
blob_appendf(pOut, "F %F\n", pFile->zName);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}
cmp = 1;
if( pFile==0
|| (cmp = strcmp(pFile->zName,zName))!=0
|| strcmp(pFile->zUuid, zUuid)!=0
){
blob_resize(&filename, nBasename);
if( zOrig==0 || strcmp(zOrig,zName)==0 ){
blob_appendf(pOut, "F %F %s%s\n", zName, zUuid, zPerm);
}else{
if( zPerm[0]==0 ){ zPerm = " w"; }
blob_appendf(pOut, "F %F %s%s %F\n", zName, zUuid, zPerm, zOrig);
}
nFBcard++;
}
if( cmp==0 ) pFile = manifest_file_next(pBaseline,0);
}
blob_reset(&filename);
db_finalize(&q);
while( pFile ){
blob_appendf(pOut, "F %F\n", pFile->zName);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}
blob_appendf(pOut, "P %s", zParentUuid);
if( verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate);
free(zParentUuid);
db_prepare(&q2, "SELECT merge FROM vmerge WHERE id=:id");
db_bind_int(&q2, ":id", 0);
while( db_step(&q2)==SQLITE_ROW ){
char *zMergeUuid;
int mid = db_column_int(&q2, 0);
if( !g.markPrivate && content_is_private(mid) ) continue;
zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
if( zMergeUuid ){
blob_appendf(pOut, " %s", zMergeUuid);
if( verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
free(zMergeUuid);
}
}
db_finalize(&q2);
free(zDate);
blob_appendf(pOut, "\n");
if( pCksum ) blob_appendf(pOut, "R %b\n", pCksum);
if( zBranch && zBranch[0] ){
Stmt q;
if( zBgColor && zBgColor[0] ){
blob_appendf(pOut, "T *bgcolor * %F\n", zBgColor);
}
blob_appendf(pOut, "T *branch * %F\n", zBranch);
blob_appendf(pOut, "T *sym-%F *\n", zBranch);
/* Cancel all other symbolic tags */
db_prepare(&q,
"SELECT tagname FROM tagxref, tag"
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
" AND tagtype>0 AND tagname GLOB 'sym-*'"
" AND tagname!='sym-'||%Q"
" ORDER BY tagname",
vid, zBranch);
while( db_step(&q)==SQLITE_ROW ){
const char *zTag = db_column_text(&q, 0);
blob_appendf(pOut, "T -%F *\n", zTag);
}
db_finalize(&q);
}
blob_appendf(pOut, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(pOut, &mcksum);
blob_appendf(pOut, "Z %b\n", &mcksum);
if( pnFBcard ) *pnFBcard = nFBcard;
}
/*
** COMMAND: ci
** COMMAND: commit
**
** Usage: %fossil commit ?OPTIONS? ?FILE...?
**
|
| ︙ | ︙ | |||
584 585 586 587 588 589 590 591 592 593 |
**
** --comment|-m COMMENT-TEXT
** --branch NEW-BRANCH-NAME
** --bgcolor COLOR
** --nosign
** --force|-f
** --private
**
*/
void commit_cmd(void){
| > > | | > > | | | < | > > > > | < | < > > > > > > > > > > > > > > > > > > > > | 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 794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
**
** --comment|-m COMMENT-TEXT
** --branch NEW-BRANCH-NAME
** --bgcolor COLOR
** --nosign
** --force|-f
** --private
** --baseline
** --delta
**
*/
void commit_cmd(void){
int hasChanges; /* True if unsaved changes exist */
int vid; /* blob-id of parent version */
int nrid; /* blob-id of a modified file */
int nvid; /* Blob-id of the new check-in */
Blob comment; /* Check-in comment */
const char *zComment; /* Check-in comment */
Stmt q; /* Query to find files that have been modified */
char *zUuid; /* UUID of the new check-in */
int noSign = 0; /* True to omit signing the manifest using GPG */
int isAMerge = 0; /* True if checking in a merge */
int forceFlag = 0; /* Force a fork */
int forceDelta = 0; /* Force a delta-manifest */
int forceBaseline = 0; /* Force a baseline-manifest */
char *zManifestFile; /* Name of the manifest file */
int useCksum; /* True if checksums should be computed and verified */
int outputManifest; /* True to output "manifest" and "manifest.uuid" */
int testRun; /* True for a test run. Debugging only */
const char *zBranch; /* Create a new branch with this name */
const char *zBgColor; /* Set background color when branching */
const char *zDateOvrd; /* Override date string */
const char *zUserOvrd; /* Override user name */
const char *zComFile; /* Read commit message from this file */
Blob manifest; /* Manifest in baseline form */
Blob muuid; /* Manifest uuid */
Blob cksum1, cksum2; /* Before and after commit checksums */
Blob cksum1b; /* Checksum recorded in the manifest */
int szD; /* Size of the delta manifest */
int szB; /* Size of the baseline manifest */
url_proxy_options();
noSign = find_option("nosign",0,0)!=0;
forceDelta = find_option("delta",0,0)!=0;
forceBaseline = find_option("baseline",0,0)!=0;
if( forceDelta && forceBaseline ){
fossil_fatal("cannot use --delta and --baseline together");
}
testRun = find_option("test",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);
zComFile = find_option("message-file", "M", 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", 0)==0 ){ noSign = 1; }
useCksum = db_get_boolean("repo-cksum", 1);
outputManifest = db_get_boolean("manifest", 0);
verify_all_options();
/* So that older versions of Fossil (that do not understand delta-
** manifest) can continue to use this repository, do not create a new
** delta-manifest unless this repository already contains one or more
** delta-manifets, or unless the delta-manifest is explicitly requested
** by the --delta option.
*/
if( !forceDelta && !db_get_boolean("seen-delta-manifest",0) ){
forceBaseline = 1;
}
/* Get the ID of the parent manifest artifact */
vid = db_lget_int("checkout", 0);
if( content_is_private(vid) ){
g.markPrivate = 1;
}
|
| ︙ | ︙ | |||
679 680 681 682 683 684 685 |
/*
** Check that the user exists.
*/
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
fossil_fatal("no such user: %s", g.zLogin);
}
| | | | 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
/*
** Check that the user exists.
*/
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
fossil_fatal("no such user: %s", g.zLogin);
}
hasChanges = unsaved_changes();
db_begin_transaction();
db_record_repository_filename(0);
if( hasChanges==0 && !isAMerge && !forceFlag ){
fossil_fatal("nothing has changed");
}
/* If one or more files that were named on the command line have not
** been modified, bail out now.
*/
if( g.aCommitFile ){
|
| ︙ | ︙ | |||
718 719 720 721 722 723 724 |
*/
if( db_exists("SELECT 1 FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_CLOSED, vid) ){
fossil_fatal("cannot commit against a closed leaf");
}
| | | 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
*/
if( db_exists("SELECT 1 FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_CLOSED, vid) ){
fossil_fatal("cannot commit against a closed leaf");
}
if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
if( zComment ){
blob_zero(&comment);
blob_append(&comment, zComment, -1);
}else if( zComFile ){
blob_zero(&comment);
blob_read_from_file(&comment, zComFile);
}else{
|
| ︙ | ︙ | |||
773 774 775 776 777 778 779 |
content_deltify(rid, nrid, 0);
}
db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
}
db_finalize(&q);
| | < | < < < < < < < < | < < < < < < < < < < < < < < < < < < | < > > > | | > | > | > > > > > < < < < < < < | < > | | > | < | < < < < | > | | < < < < < | > | > > | < < > > > > > > > > > > | | > | | < | < < < < < < | < < < | < | < < < | > > > > > > > > | > | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 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 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
content_deltify(rid, nrid, 0);
}
db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
}
db_finalize(&q);
/* Create the new manifest */
if( blob_size(&comment)==0 ){
blob_append(&comment, "(no comment)", -1);
}
if( forceDelta ){
blob_zero(&manifest);
}else{
create_manifest(&manifest, 0, 0, &comment, vid,
!forceFlag, useCksum ? &cksum1 : 0,
zDateOvrd, zUserOvrd, zBranch, zBgColor, &szB);
}
/* See if a delta-manifest would be more appropriate */
if( !forceBaseline ){
const char *zBaselineUuid;
Manifest *pParent;
Manifest *pBaseline;
pParent = manifest_get(vid, CFTYPE_MANIFEST);
if( pParent && pParent->zBaseline ){
zBaselineUuid = pParent->zBaseline;
pBaseline = manifest_get_by_name(zBaselineUuid, 0);
}else{
zBaselineUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
pBaseline = pParent;
}
if( pBaseline ){
Blob delta;
create_manifest(&delta, zBaselineUuid, pBaseline, &comment, vid,
!forceFlag, useCksum ? &cksum1 : 0,
zDateOvrd, zUserOvrd, zBranch, zBgColor, &szD);
/*
** At this point, two manifests have been constructed, either of
** which would work for this checkin. The first manifest (held
** in the "manifest" variable) is a baseline manifest and the second
** (held in variable named "delta") is a delta manifest. The
** question now is: which manifest should we use?
**
** Let B be the number of F-cards in the baseline manifest and
** let D be the number of F-cards in the delta manifest, plus one for
** the B-card. (B is held in the szB variable and D is held in the
** szD variable.) Assume that all delta manifests adds X new F-cards.
** Then to minimize the total number of F- and B-cards in the repository,
** we should use the delta manifest if and only if:
**
** D*D < B*X - X*X
**
** X is an unknown here, but for most repositories, we will not be
** far wrong if we assume X=3.
*/
if( forceDelta || (szD*szD)<(szB*3-9) ){
blob_reset(&manifest);
manifest = delta;
}else{
blob_reset(&delta);
}
}else if( forceDelta ){
fossil_panic("unable to find a baseline-manifest for the delta");
}
}
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' ){
fossil_exit(1);
}
}
/* If the --test option is specified, output the manifest file
** and rollback the transaction.
*/
if( testRun ){
blob_write_to_file(&manifest, "");
}
if( outputManifest ){
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
blob_write_to_file(&manifest, zManifestFile);
blob_reset(&manifest);
blob_read_from_file(&manifest, zManifestFile);
free(zManifestFile);
}
nvid = content_put(&manifest, 0, 0);
if( nvid==0 ){
fossil_panic("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
manifest_crosslink(nvid, &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);
}
/* Update the vfile and vmerge tables */
db_multi_exec(
"DELETE FROM vfile WHERE (vid!=%d OR deleted) AND file_is_selected(id);"
"DELETE FROM vmerge WHERE file_is_selected(id) OR id=0;"
"UPDATE vfile SET vid=%d;"
"UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL"
" WHERE file_is_selected(id);"
, vid, nvid
);
db_lset_int("checkout", nvid);
if( useCksum ){
/* Verify that the repository checksum matches the expected checksum
** calculated before the checkin started (and stored as the R record
** of the manifest file).
*/
vfile_aggregate_checksum_repository(nvid, &cksum2);
if( blob_compare(&cksum1, &cksum2) ){
fossil_panic("tree checksum does not match repository after commit");
}
/* Verify that the manifest checksum matches the expected checksum */
vfile_aggregate_checksum_manifest(nvid, &cksum2, &cksum1b);
if( blob_compare(&cksum1, &cksum1b) ){
fossil_panic("manifest checksum does not agree with manifest: "
"%b versus %b", &cksum1, &cksum1b);
}
if( blob_compare(&cksum1, &cksum2) ){
fossil_panic("tree checksum does not match manifest after commit: "
"%b versus %b", &cksum1, &cksum2);
}
/* Verify that the commit did not modify any disk images. */
vfile_aggregate_checksum_disk(nvid, &cksum2);
if( blob_compare(&cksum1, &cksum2) ){
fossil_panic("tree checksums before and after commit do not match");
}
}
/* Clear the undo/redo stack */
undo_reset();
/* Commit */
db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'");
if( testRun ){
db_end_transaction(1);
exit(1);
}
db_end_transaction(0);
if( !g.markPrivate ){
autosync(AUTOSYNC_PUSH);
}
if( count_nonbranch_children(vid)>1 ){
printf("**** warning: a fork has occurred *****\n");
}
}
|
Changes to src/checkout.c.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 |
return vid;
}
/*
** Load a vfile from a record ID.
*/
void load_vfile_from_rid(int vid){
| < < < | < > > | > > > > | > > | > > > > > | > > > > > > > > > > > > > > > > > > > | > > > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < < > > > > > | > > > > > > > | 76 77 78 79 80 81 82 83 84 85 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 124 125 126 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
return vid;
}
/*
** Load a vfile from a record ID.
*/
void load_vfile_from_rid(int vid){
if( db_exists("SELECT 1 FROM vfile WHERE vid=%d", vid) ){
return;
}
vfile_build(vid);
}
/*
** Set or clear the vfile.isexe flag for a file.
*/
static void set_or_clear_isexe(const char *zFilename, int vid, int onoff){
static Stmt s;
db_static_prepare(&s,
"UPDATE vfile SET isexe=:isexe"
" WHERE vid=:vid AND pathname=:path AND isexe!=:isexe"
);
db_bind_int(&s, ":isexe", onoff);
db_bind_int(&s, ":vid", vid);
db_bind_text(&s, ":path", zFilename);
db_step(&s);
db_reset(&s);
}
/*
** Set or clear the execute permission bit (as appropriate) for all
** files in the current check-out.
*/
void checkout_set_all_exe(int vid){
Blob filename;
int baseLen;
Manifest *pManifest;
ManifestFile *pFile;
/* Check the EXE permission status of all files
*/
pManifest = manifest_get(vid, CFTYPE_MANIFEST);
if( pManifest==0 ) return;
blob_zero(&filename);
blob_appendf(&filename, "%s/", g.zLocalRoot);
baseLen = blob_size(&filename);
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
int isExe;
blob_append(&filename, pFile->zName, -1);
isExe = pFile->zPerm && strstr(pFile->zPerm, "x");
file_setexe(blob_str(&filename), isExe);
set_or_clear_isexe(pFile->zName, vid, isExe);
blob_resize(&filename, baseLen);
}
blob_reset(&filename);
manifest_destroy(pManifest);
}
/*
** If the "manifest" setting is true, then automatically generate
** files named "manifest" and "manifest.uuid" containing, respectively,
** the text of the manifest and the artifact ID of the manifest.
*/
void manifest_to_disk(int vid){
char *zManFile;
Blob manifest;
Blob hash;
if( db_get_boolean("manifest",0) ){
blob_zero(&manifest);
content_get(vid, &manifest);
zManFile = mprintf("%smanifest", g.zLocalRoot);
blob_write_to_file(&manifest, zManFile);
free(zManFile);
blob_zero(&hash);
sha1sum_blob(&manifest, &hash);
zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
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);
}
}
}
/*
** COMMAND: checkout
** COMMAND: co
**
** Usage: %fossil checkout VERSION ?-f|--force? ?--keep?
|
| ︙ | ︙ | |||
226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
if( !keepFlag ){
uncheckout(prior);
}
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
if( !keepFlag ){
vfile_to_disk(vid, 0, 1, promptFlag);
}
manifest_to_disk(vid);
db_lset_int("checkout", vid);
undo_reset();
db_multi_exec("DELETE FROM vmerge");
if( !keepFlag ){
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
vfile_aggregate_checksum_disk(vid, &cksum2);
| > | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
if( !keepFlag ){
uncheckout(prior);
}
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
if( !keepFlag ){
vfile_to_disk(vid, 0, 1, promptFlag);
}
checkout_set_all_exe(vid);
manifest_to_disk(vid);
db_lset_int("checkout", vid);
undo_reset();
db_multi_exec("DELETE FROM vmerge");
if( !keepFlag ){
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
vfile_aggregate_checksum_disk(vid, &cksum2);
|
| ︙ | ︙ |
Changes to src/configure.c.
| ︙ | ︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
{ "css", CONFIGSET_SKIN },
{ "header", CONFIGSET_SKIN },
{ "footer", CONFIGSET_SKIN },
{ "logo-mimetype", CONFIGSET_SKIN },
{ "logo-image", CONFIGSET_SKIN },
{ "project-name", CONFIGSET_PROJ },
{ "project-description", CONFIGSET_PROJ },
{ "index-page", CONFIGSET_SKIN },
{ "timeline-block-markup", CONFIGSET_SKIN },
{ "timeline-max-comment", CONFIGSET_SKIN },
{ "ticket-table", CONFIGSET_TKT },
{ "ticket-common", CONFIGSET_TKT },
{ "ticket-newpage", CONFIGSET_TKT },
{ "ticket-viewpage", CONFIGSET_TKT },
| > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
{ "css", CONFIGSET_SKIN },
{ "header", CONFIGSET_SKIN },
{ "footer", CONFIGSET_SKIN },
{ "logo-mimetype", CONFIGSET_SKIN },
{ "logo-image", CONFIGSET_SKIN },
{ "project-name", CONFIGSET_PROJ },
{ "project-description", CONFIGSET_PROJ },
{ "manifest", CONFIGSET_PROJ },
{ "index-page", CONFIGSET_SKIN },
{ "timeline-block-markup", CONFIGSET_SKIN },
{ "timeline-max-comment", CONFIGSET_SKIN },
{ "ticket-table", CONFIGSET_TKT },
{ "ticket-common", CONFIGSET_TKT },
{ "ticket-newpage", CONFIGSET_TKT },
{ "ticket-viewpage", CONFIGSET_TKT },
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
1508 1509 1510 1511 1512 1513 1514 |
char const *name; /* Name of the setting */
char const *var; /* Internal variable name used by db_set() */
int width; /* Width of display. 0 for boolean values */
char const *def; /* Default value */
};
#endif /* INTERFACE */
struct stControlSettings const ctrlSettings[] = {
| | | | | | | | | > | > | 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
char const *name; /* Name of the setting */
char const *var; /* Internal variable name used by db_set() */
int width; /* Width of display. 0 for boolean values */
char const *def; /* Default value */
};
#endif /* INTERFACE */
struct stControlSettings const ctrlSettings[] = {
{ "auto-captcha", "autocaptcha", 0, "on" },
{ "auto-shun", 0, 0, "on" },
{ "autosync", 0, 0, "on" },
{ "binary-glob", 0, 32, "" },
{ "clearsign", 0, 0, "off" },
{ "diff-command", 0, 16, "" },
{ "dont-push", 0, 0, "off" },
{ "editor", 0, 16, "" },
{ "gdiff-command", 0, 16, "gdiff" },
{ "ignore-glob", 0, 40, "" },
{ "http-port", 0, 16, "8080" },
{ "localauth", 0, 0, "off" },
{ "manifest", 0, 0, "off" },
{ "mtime-changes", 0, 0, "off" },
{ "pgp-command", 0, 32, "gpg --clearsign -o " },
{ "proxy", 0, 32, "off" },
{ "repo-cksum", 0, 0, "on" },
{ "ssh-command", 0, 32, "" },
{ "web-browser", 0, 32, "" },
{ 0,0,0,0 }
};
/*
** COMMAND: settings
|
| ︙ | ︙ | |||
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | ** ** ** auto-captcha If enabled, the Login page provides a button to ** fill in the captcha password. Default: on ** ** auto-shun If enabled, automatically pull the shunning list ** from a server to which the client autosyncs. ** ** autosync If enabled, automatically pull prior to commit ** or update and automatically push after commit or ** tag or branch creation. If the value is "pullonly" ** then only pull operations occur automatically. ** ** binary-glob The VALUE is a comma-separated list of GLOB patterns ** that should be treated as binary files for merging ** purposes. Example: *.xml ** ** clearsign When enabled, fossil will attempt to sign all commits ** with gpg. When disabled (the default), commits will | > > | | 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 | ** ** ** auto-captcha If enabled, the Login page provides a button to ** fill in the captcha password. Default: on ** ** auto-shun If enabled, automatically pull the shunning list ** from a server to which the client autosyncs. ** Default: on ** ** autosync If enabled, automatically pull prior to commit ** or update and automatically push after commit or ** tag or branch creation. If the value is "pullonly" ** then only pull operations occur automatically. ** Default: on ** ** binary-glob The VALUE is a comma-separated list of GLOB patterns ** that should be treated as binary files for merging ** purposes. Example: *.xml ** ** clearsign When enabled, fossil will attempt to sign all commits ** with gpg. When disabled (the default), commits will ** be unsigned. Default: off ** ** diff-command External command to run when performing a diff. ** If undefined, the internal text diff will be used. ** ** dont-push Prevent this repository from pushing from client to ** server. Useful when setting up a private branch. ** |
| ︙ | ︙ | |||
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 | ** Example: *.o,*.obj,*.exe ** ** localauth If enabled, require that HTTP connections from ** 127.0.0.1 be authenticated by password. If ** false, all HTTP requests from localhost have ** unrestricted access to the repository. ** ** mtime-changes Use file modification times (mtimes) to detect when ** files have been modified. (Default "on".) ** ** pgp-command Command used to clear-sign manifests at check-in. ** The default is "gpg --clearsign -o ". ** ** proxy URL of the HTTP proxy. If undefined or "off" then ** the "http_proxy" environment variable is consulted. ** If the http_proxy environment variable is undefined ** then a direct HTTP connection is used. ** ** ssh-command Command used to talk to a remote machine with ** the "ssh://" protocol. ** ** web-browser A shell command used to launch your preferred ** web browser when given a URL as an argument. ** Defaults to "start" on windows, "open" on Mac, | > > > > > > > > > | 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 | ** Example: *.o,*.obj,*.exe ** ** localauth If enabled, require that HTTP connections from ** 127.0.0.1 be authenticated by password. If ** false, all HTTP requests from localhost have ** unrestricted access to the repository. ** ** manifest If enabled, automatically create files "manifest" and ** "manifest.uuid" in every checkout. The SQLite and ** Fossil repositories both require this. Default: off. ** ** mtime-changes Use file modification times (mtimes) to detect when ** files have been modified. (Default "on".) ** ** pgp-command Command used to clear-sign manifests at check-in. ** The default is "gpg --clearsign -o ". ** ** proxy URL of the HTTP proxy. If undefined or "off" then ** the "http_proxy" environment variable is consulted. ** If the http_proxy environment variable is undefined ** then a direct HTTP connection is used. ** ** repo-cksum Compute checksums over all files in each checkout ** as a double-check of correctness. Defaults to "on". ** Disable on large repositories for a performance ** improvement. ** ** ssh-command Command used to talk to a remote machine with ** the "ssh://" protocol. ** ** web-browser A shell command used to launch your preferred ** web browser when given a URL as an argument. ** Defaults to "start" on windows, "open" on Mac, |
| ︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 |
}
if( g.argc==2 ){
for(i=0; ctrlSettings[i].name; i++){
print_setting(ctrlSettings[i].name);
}
}else if( g.argc==3 || g.argc==4 ){
const char *zName = g.argv[2];
int n = strlen(zName);
for(i=0; ctrlSettings[i].name; i++){
if( strncmp(ctrlSettings[i].name, zName, n)==0 ) break;
}
if( !ctrlSettings[i].name ){
fossil_fatal("no such setting: %s", zName);
}
if( unsetFlag ){
db_unset(ctrlSettings[i].name, globalFlag);
}else if( g.argc==4 ){
db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
}else{
print_setting(ctrlSettings[i].name);
}
}else{
usage("?PROPERTY? ?VALUE?");
}
}
/*
** The input in a a timespan measured in days. Return a string which
| > > > > > > > > > | 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
}
if( g.argc==2 ){
for(i=0; ctrlSettings[i].name; i++){
print_setting(ctrlSettings[i].name);
}
}else if( g.argc==3 || g.argc==4 ){
const char *zName = g.argv[2];
int isManifest;
int n = strlen(zName);
for(i=0; ctrlSettings[i].name; i++){
if( strncmp(ctrlSettings[i].name, zName, n)==0 ) break;
}
if( !ctrlSettings[i].name ){
fossil_fatal("no such setting: %s", zName);
}
isManifest = strcmp(ctrlSettings[i].name, "manifest")==0;
if( isManifest && globalFlag ){
fossil_fatal("cannot set 'manifest' globally");
}
if( unsetFlag ){
db_unset(ctrlSettings[i].name, globalFlag);
}else if( g.argc==4 ){
db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
}else{
isManifest = 0;
print_setting(ctrlSettings[i].name);
}
if( isManifest ){
manifest_to_disk(db_lget_int("checkout", 0));
}
}else{
usage("?PROPERTY? ?VALUE?");
}
}
/*
** The input in a a timespan measured in days. Return a string which
|
| ︙ | ︙ |
Changes to src/delta.c.
| ︙ | ︙ | |||
193 194 195 196 197 198 199 |
}
/*
** Compute a 32-bit checksum on the N-byte buffer. Return the result.
*/
static unsigned int checksum(const char *zIn, size_t N){
const unsigned char *z = (const unsigned char *)zIn;
| | > > > | | | | | > > > > | | | | | 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 |
}
/*
** Compute a 32-bit checksum on the N-byte buffer. Return the result.
*/
static unsigned int checksum(const char *zIn, size_t N){
const unsigned char *z = (const unsigned char *)zIn;
unsigned sum0 = 0;
unsigned sum1 = 0;
unsigned sum2 = 0;
unsigned sum3 = 0;
while(N >= 16){
sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);
sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);
sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);
sum3 += ((unsigned)z[3] + z[7] + z[11]+ z[15]);
z += 16;
N -= 16;
}
while(N >= 4){
sum0 += z[0];
sum1 += z[1];
sum2 += z[2];
sum3 += z[3];
z += 4;
N -= 4;
}
sum3 += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
switch(N){
case 3: sum3 += (z[2] << 8);
case 2: sum3 += (z[1] << 16);
case 1: sum3 += (z[0] << 24);
default: ;
}
return sum3;
}
/*
** Create a new delta.
**
** The delta is written into a preallocated buffer, zDelta, which
** should be at least 60 bytes longer than the target file, zOut.
|
| ︙ | ︙ | |||
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
int lenSrc, /* Length of the source file */
const char *zDelta, /* Delta to apply to the pattern */
int lenDelta, /* Length of the delta */
char *zOut /* Write the output into this preallocated buffer */
){
unsigned int limit;
unsigned int total = 0;
char *zOrigOut = zOut;
limit = getInt(&zDelta, &lenDelta);
if( *zDelta!='\n' ){
/* ERROR: size integer not terminated by "\n" */
return -1;
}
zDelta++; lenDelta--;
| > > | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
int lenSrc, /* Length of the source file */
const char *zDelta, /* Delta to apply to the pattern */
int lenDelta, /* Length of the delta */
char *zOut /* Write the output into this preallocated buffer */
){
unsigned int limit;
unsigned int total = 0;
#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST
char *zOrigOut = zOut;
#endif
limit = getInt(&zDelta, &lenDelta);
if( *zDelta!='\n' ){
/* ERROR: size integer not terminated by "\n" */
return -1;
}
zDelta++; lenDelta--;
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
zDelta += cnt;
lenDelta -= cnt;
break;
}
case ';': {
zDelta++; lenDelta--;
zOut[0] = 0;
if( cnt!=checksum(zOrigOut, total) ){
/* ERROR: bad checksum */
return -1;
}
if( total!=limit ){
/* ERROR: generated size does not match predicted size */
return -1;
}
return total;
}
default: {
| > > | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
zDelta += cnt;
lenDelta -= cnt;
break;
}
case ';': {
zDelta++; lenDelta--;
zOut[0] = 0;
#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST
if( cnt!=checksum(zOrigOut, total) ){
/* ERROR: bad checksum */
return -1;
}
#endif
if( total!=limit ){
/* ERROR: generated size does not match predicted size */
return -1;
}
return total;
}
default: {
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
353 354 355 356 357 358 359 |
*/
static void diff_all_two_versions(
const char *zFrom,
const char *zTo,
const char *zDiffCmd,
int diffFlags
){
| | | > | > > | > | | | | | | | | | | | | | | | < | | | | | | 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 |
*/
static void diff_all_two_versions(
const char *zFrom,
const char *zTo,
const char *zDiffCmd,
int diffFlags
){
Manifest *pFrom, *pTo;
ManifestFile *pFromFile, *pToFile;
int ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0 ? 1 : 0;
int asNewFlag = (diffFlags & DIFF_NEWFILE)!=0 ? 1 : 0;
pFrom = manifest_get_by_name(zFrom, 0);
manifest_file_rewind(pFrom);
pFromFile = manifest_file_next(pFrom,0);
pTo = manifest_get_by_name(zTo, 0);
manifest_file_rewind(pTo);
pToFile = manifest_file_next(pTo,0);
while( pFromFile || pToFile ){
int cmp;
if( pFromFile==0 ){
cmp = +1;
}else if( pToFile==0 ){
cmp = -1;
}else{
cmp = strcmp(pFromFile->zName, pToFile->zName);
}
if( cmp<0 ){
printf("DELETED %s\n", pFromFile->zName);
if( asNewFlag ){
diff_manifest_entry(pFromFile, 0, zDiffCmd, ignoreEolWs);
}
pFromFile = manifest_file_next(pFrom,0);
}else if( cmp>0 ){
printf("ADDED %s\n", pToFile->zName);
if( asNewFlag ){
diff_manifest_entry(0, pToFile, zDiffCmd, ignoreEolWs);
}
pToFile = manifest_file_next(pTo,0);
}else if( strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){
/* No changes */
pFromFile = manifest_file_next(pFrom,0);
pToFile = manifest_file_next(pTo,0);
}else{
printf("CHANGED %s\n", pFromFile->zName);
diff_manifest_entry(pFromFile, pToFile, zDiffCmd, ignoreEolWs);
pFromFile = manifest_file_next(pFrom,0);
pToFile = manifest_file_next(pTo,0);
}
}
manifest_destroy(pFrom);
manifest_destroy(pTo);
}
/*
** COMMAND: diff
** COMMAND: gdiff
**
** Usage: %fossil diff|gdiff ?options? ?FILE?
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
386 387 388 389 390 391 392 |
" WHERE vid=%d AND fname=%Q", vid, zName);
if( rid==0 && db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
goto doc_not_found;
}
if( rid==0 ){
Stmt s;
| | | | < < | | > | | | | 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 |
" WHERE vid=%d AND fname=%Q", vid, zName);
if( rid==0 && db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
goto doc_not_found;
}
if( rid==0 ){
Stmt s;
Manifest *pM;
ManifestFile *pFile;
/* Add the vid baseline to the cache */
if( db_int(0, "SELECT count(*) FROM vcache")>10000 ){
db_multi_exec("DELETE FROM vcache");
}
pM = manifest_get(vid, CFTYPE_MANIFEST);
if( pM==0 ){
goto doc_not_found;
}
db_prepare(&s,
"INSERT INTO vcache(vid,fname,rid)"
" SELECT %d, :fname, rid FROM blob"
" WHERE uuid=:uuid",
vid
);
manifest_file_rewind(pM);
while( (pFile = manifest_file_next(pM,0))!=0 ){
db_bind_text(&s, ":fname", pFile->zName);
db_bind_text(&s, ":uuid", pFile->zUuid);
db_step(&s);
db_reset(&s);
}
db_finalize(&s);
manifest_destroy(pM);
/* Try again to find the file */
rid = db_int(0, "SELECT rid FROM vcache"
" WHERE vid=%d AND fname=%Q", vid, zName);
}
if( rid==0 ){
goto doc_not_found;
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
265 266 267 268 269 270 271 |
}
/*
** Decode a fossilized string in-place.
*/
void defossilize(char *z){
int i, j, c;
| | > | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
}
/*
** Decode a fossilized string in-place.
*/
void defossilize(char *z){
int i, j, c;
for(i=0; (c=z[i])!=0 && c!='\\'; i++){}
if( c==0 ) return;
for(j=i; (c=z[i])!=0; i++){
if( c=='\\' && z[i+1] ){
i++;
switch( z[i] ){
case 'n': c = '\n'; break;
case 's': c = ' '; break;
case 't': c = '\t'; break;
case 'r': c = '\r'; break;
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
61 62 63 64 65 66 67 | int rid = 0; /* rid of the event artifact */ char *zUuid; /* UUID corresponding to rid */ const char *zEventId; /* Event identifier */ char *zETime; /* Time of the event */ char *zATime; /* Time the artifact was created */ int specRid; /* rid specified by aid= parameter */ int prevRid, nextRid; /* Previous or next edits of this event */ | | < | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | int rid = 0; /* rid of the event artifact */ char *zUuid; /* UUID corresponding to rid */ const char *zEventId; /* Event identifier */ char *zETime; /* Time of the event */ char *zATime; /* Time the artifact was created */ int specRid; /* rid specified by aid= parameter */ int prevRid, nextRid; /* Previous or next edits of this event */ Manifest *pEvent; /* Parsed event artifact */ Blob fullbody; /* Complete content of the event body */ Blob title; /* Title extracted from the event body */ Blob tail; /* Event body that comes after the title */ Stmt q1; /* Query to search for the event */ int showDetail; /* True to show details */ |
| ︙ | ︙ | |||
111 112 113 114 115 116 117 |
return;
}
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
showDetail = atoi(PD("detail","0"));
/* Extract the event content.
*/
| < < | < | | | | 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 137 138 139 |
return;
}
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
showDetail = atoi(PD("detail","0"));
/* Extract the event content.
*/
pEvent = manifest_get(rid, CFTYPE_EVENT);
if( pEvent==0 ){
fossil_panic("Object #%d is not an event", rid);
}
blob_init(&fullbody, pEvent->zWiki, -1);
if( wiki_find_title(&fullbody, &title, &tail) ){
style_header(blob_str(&title));
}else{
style_header("Event %S", zEventId);
tail = fullbody;
}
if( g.okWrWiki && g.okWrite && nextRid==0 ){
style_submenu_element("Edit", "Edit", "%s/eventedit?name=%s",
g.zTop, zEventId);
}
zETime = db_text(0, "SELECT datetime(%.17g)", pEvent->rEventDate);
style_submenu_element("Context", "Context", "%s/timeline?c=%T",
g.zTop, zETime);
if( g.okHistory ){
if( showDetail ){
style_submenu_element("Plain", "Plain", "%s/event?name=%s&aid=%s",
g.zTop, zEventId, zUuid);
if( nextRid ){
|
| ︙ | ︙ | |||
164 165 166 167 168 169 170 |
}
if( showDetail && g.okHistory ){
int i;
const char *zClr = 0;
Blob comment;
| | | | | | | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 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 |
}
if( showDetail && g.okHistory ){
int i;
const char *zClr = 0;
Blob comment;
zATime = db_text(0, "SELECT datetime(%.17g)", pEvent->rDate);
@ <p>Event [<a href="%s(g.zTop)/artifact/%s(zUuid)">%S(zUuid)</a>] at
@ [<a href="%s(g.zTop)/timeline?c=%T(zETime)">%s(zETime)</a>]
@ entered by user <b>%h(pEvent->zUser)</b> on
@ [<a href="%s(g.zTop)/timeline?c=%T(zATime)">%s(zATime)</a>]:</p>
@ <blockquote>
for(i=0; i<pEvent->nTag; i++){
if( strcmp(pEvent->aTag[i].zName,"+bgcolor")==0 ){
zClr = pEvent->aTag[i].zValue;
}
}
if( zClr && zClr[0]==0 ) zClr = 0;
if( zClr ){
@ <div style="background-color: %h(zClr);">
}else{
@ <div>
}
blob_init(&comment, pEvent->zComment, -1);
wiki_convert(&comment, 0, WIKI_INLINE);
blob_reset(&comment);
@ </div>
@ </blockquote><hr />
}
wiki_convert(&tail, 0, 0);
style_footer();
manifest_destroy(pEvent);
}
/*
** WEBPAGE: eventedit
** URL: /eventedit?name=EVENTID
**
** Edit an event. If name is omitted, create a new event.
|
| ︙ | ︙ | |||
257 258 259 260 261 262 263 |
if( strcmp(zClr,"##")==0 ) zClr = PD("cclr","");
/* If editing an existing event, extract the key fields to use as
** a starting point for the edit.
*/
if( rid && (zBody==0 || zETime==0 || zComment==0 || zTags==0) ){
| | < < < | < | | | | | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
if( strcmp(zClr,"##")==0 ) zClr = PD("cclr","");
/* If editing an existing event, extract the key fields to use as
** a starting point for the edit.
*/
if( rid && (zBody==0 || zETime==0 || zComment==0 || zTags==0) ){
Manifest *pEvent;
pEvent = manifest_get(rid, CFTYPE_EVENT);
if( pEvent && pEvent->type==CFTYPE_EVENT ){
if( zBody==0 ) zBody = pEvent->zWiki;
if( zETime==0 ){
zETime = db_text(0, "SELECT datetime(%.17g)", pEvent->rEventDate);
}
if( zComment==0 ) zComment = pEvent->zComment;
}
if( zTags==0 ){
zTags = db_text(0,
"SELECT group_concat(substr(tagname,5),', ')"
" FROM tagxref, tag"
" WHERE tagxref.rid=%d"
" AND tagxref.tagid=tag.tagid"
|
| ︙ | ︙ |
Changes to src/finfo.c.
| ︙ | ︙ | |||
129 130 131 132 133 134 135 |
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC /*sort*/",
TAG_BRANCH,
zFilename
);
blob_zero(&title);
blob_appendf(&title, "History of ");
| | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC /*sort*/",
TAG_BRANCH,
zFilename
);
blob_zero(&title);
blob_appendf(&title, "History of ");
hyperlinked_path(zFilename, &title, 0);
@ <h2>%b(&title)</h2>
blob_reset(&title);
pGraph = graph_init();
@ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
@ <table class="timelineTable">
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
541 542 543 544 545 546 547 |
}else{
style_header("Wiki Information");
rid = 0;
}
db_finalize(&q);
showTags(rid, "wiki-*");
if( rid ){
| < | < < | < | | | | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
}else{
style_header("Wiki Information");
rid = 0;
}
db_finalize(&q);
showTags(rid, "wiki-*");
if( rid ){
Manifest *pWiki;
pWiki = manifest_get(rid, CFTYPE_WIKI);
if( pWiki ){
Blob wiki;
blob_init(&wiki, pWiki->zWiki, -1);
@ <div class="section">Content</div>
wiki_convert(&wiki, 0, 0);
blob_reset(&wiki);
}
manifest_destroy(pWiki);
}
style_footer();
}
/*
** Show a webpage error message
*/
|
| ︙ | ︙ | |||
578 579 580 581 582 583 584 | style_footer(); } /* ** Find an checkin based on query parameter zParam and parse its ** manifest. Return the number of errors. */ | | < | | < < | | 574 575 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 |
style_footer();
}
/*
** Find an checkin based on query parameter zParam and parse its
** manifest. Return the number of errors.
*/
static Manifest *vdiff_parse_manifest(const char *zParam, int *pRid){
int rid;
*pRid = rid = name_to_rid_www(zParam);
if( rid==0 ){
webpage_error("Missing \"%s\" query parameter.", zParam);
return 0;
}
if( !is_a_version(rid) ){
webpage_error("Artifact %s is not a checkin.", P(zParam));
return 0;
}
return manifest_get(rid, CFTYPE_MANIFEST);
}
/*
** Output a description of a check-in
*/
void checkin_description(int rid){
Stmt q;
|
| ︙ | ︙ | |||
633 634 635 636 637 638 639 |
** URL: /vdiff?from=UUID&to=UUID&detail=BOOLEAN
**
** Show all differences between two checkins.
*/
void vdiff_page(void){
int ridFrom, ridTo;
int showDetail = 0;
| | | | > | > > | > > | | | | | | | | | | | | | | | | | | | | | 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 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
** URL: /vdiff?from=UUID&to=UUID&detail=BOOLEAN
**
** Show all differences between two checkins.
*/
void vdiff_page(void){
int ridFrom, ridTo;
int showDetail = 0;
Manifest *pFrom, *pTo;
ManifestFile *pFileFrom, *pFileTo;
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
login_anonymous_available();
pFrom = vdiff_parse_manifest("from", &ridFrom);
if( pFrom==0 ) return;
pTo = vdiff_parse_manifest("to", &ridTo);
if( pTo==0 ) return;
showDetail = atoi(PD("detail","0"));
style_header("Check-in Differences");
@ <h2>Difference From:</h2><blockquote>
checkin_description(ridFrom);
@ </blockquote><h2>To:</h2><blockquote>
checkin_description(ridTo);
@ </blockquote><hr /><p>
manifest_file_rewind(pFrom);
pFileFrom = manifest_file_next(pFrom, 0);
manifest_file_rewind(pTo);
pFileTo = manifest_file_next(pTo, 0);
while( pFileFrom || pFileTo ){
int cmp;
if( pFileFrom==0 ){
cmp = +1;
}else if( pFileTo==0 ){
cmp = -1;
}else{
cmp = strcmp(pFileFrom->zName, pFileTo->zName);
}
if( cmp<0 ){
append_file_change_line(pFileFrom->zName,
pFileFrom->zUuid, 0, 0);
pFileFrom = manifest_file_next(pFrom, 0);
}else if( cmp>0 ){
append_file_change_line(pFileTo->zName,
0, pFileTo->zUuid, 0);
pFileTo = manifest_file_next(pTo, 0);
}else if( strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){
/* No changes */
pFileFrom = manifest_file_next(pFrom, 0);
pFileTo = manifest_file_next(pTo, 0);
}else{
append_file_change_line(pFileFrom->zName,
pFileFrom->zUuid,
pFileTo->zUuid, showDetail);
pFileFrom = manifest_file_next(pFrom, 0);
pFileTo = manifest_file_next(pTo, 0);
}
}
manifest_destroy(pFrom);
manifest_destroy(pTo);
style_footer();
}
/*
** Write a description of an object to the www reply.
**
|
| ︙ | ︙ | |||
1041 1042 1043 1044 1045 1046 1047 |
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
*/
int artifact_from_ci_and_filename(void){
const char *zFilename;
const char *zCI;
int cirid;
| < | < > | | | | | | > > | 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 1064 1065 1066 1067 1068 |
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
*/
int artifact_from_ci_and_filename(void){
const char *zFilename;
const char *zCI;
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
zCI = P("ci");
if( zCI==0 ) return 0;
zFilename = P("filename");
if( zFilename==0 ) return 0;
cirid = name_to_rid_www("ci");
pManifest = manifest_get(cirid, CFTYPE_MANIFEST);
if( pManifest==0 ) return 0;
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
if( strcmp(zFilename, pFile->zName)==0 ){
int rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", pFile->zUuid);
manifest_destroy(pManifest);
return rid;
}
}
return 0;
}
/*
|
| ︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 |
** WEBPAGE: tinfo
** URL: /tinfo?name=ARTIFACTID
**
** Show the details of a ticket change control artifact.
*/
void tinfo_page(void){
int rid;
| < | | | < < < | | | > | | | | | | | 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
** WEBPAGE: tinfo
** URL: /tinfo?name=ARTIFACTID
**
** Show the details of a ticket change control artifact.
*/
void tinfo_page(void){
int rid;
char *zDate;
const char *zUuid;
char zTktName[20];
Manifest *pTktChng;
login_check_credentials();
if( !g.okRdTkt ){ login_needed(); return; }
rid = name_to_rid_www("name");
if( rid==0 ){ fossil_redirect_home(); }
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( g.okAdmin ){
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
pTktChng = manifest_get(rid, CFTYPE_TICKET);
if( pTktChng==0 ){
fossil_redirect_home();
}
style_header("Ticket Change Details");
zDate = db_text(0, "SELECT datetime(%.12f)", pTktChng->rDate);
memcpy(zTktName, pTktChng->zTicketUuid, 10);
zTktName[10] = 0;
if( g.okHistory ){
@ <h2>Changes to ticket
@ <a href="%s(pTktChng->zTicketUuid)">%s(zTktName)</a></h2>
@
@ <p>By %h(pTktChng->zUser) on %s(zDate). See also:
@ <a href="%s(g.zTop)/artifact/%T(zUuid)">artifact content</a>, and
@ <a href="%s(g.zTop)/tkthistory/%s(pTktChng->zTicketUuid)">ticket
@ history</a></p>
}else{
@ <h2>Changes to ticket %s(zTktName)</h2>
@
@ <p>By %h(pTktChng->zUser) on %s(zDate).
@ </p>
}
@
@ <ol>
free(zDate);
ticket_output_change_artifact(pTktChng);
manifest_destroy(pTktChng);
style_footer();
}
/*
** WEBPAGE: info
** URL: info/ARTIFACTID
|
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#include "manifest.h"
#include <assert.h>
#if INTERFACE
/*
** Types of control files
*/
#define CFTYPE_MANIFEST 1
#define CFTYPE_CLUSTER 2
#define CFTYPE_CONTROL 3
#define CFTYPE_WIKI 4
#define CFTYPE_TICKET 5
#define CFTYPE_ATTACHMENT 6
#define CFTYPE_EVENT 7
/*
** A parsed manifest or cluster.
*/
struct Manifest {
Blob content; /* The original content blob */
int type; /* Type of artifact. One of CFTYPE_xxxxx */
char *zComment; /* Decoded comment. The C card. */
double rDate; /* Date and time from D card. 0.0 if no D card. */
char *zUser; /* Name of the user from the U card. */
char *zRepoCksum; /* MD5 checksum of the baseline content. R card. */
char *zWiki; /* Text of the wiki page. W card. */
char *zWikiTitle; /* Name of the wiki page. L card. */
double rEventDate; /* Date of an event. E card. */
char *zEventId; /* UUID for an event. E card. */
char *zTicketUuid; /* UUID for a ticket. K card. */
char *zAttachName; /* Filename of an attachment. A card. */
char *zAttachSrc; /* UUID of document being attached. A card. */
char *zAttachTarget; /* Ticket or wiki that attachment applies to. A card */
int nFile; /* Number of F cards */
int nFileAlloc; /* Slots allocated in aFile[] */
| > > > > > > > > > > > > > > > < | < < < < | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#include "manifest.h"
#include <assert.h>
#if INTERFACE
/*
** Types of control files
*/
#define CFTYPE_ANY 0
#define CFTYPE_MANIFEST 1
#define CFTYPE_CLUSTER 2
#define CFTYPE_CONTROL 3
#define CFTYPE_WIKI 4
#define CFTYPE_TICKET 5
#define CFTYPE_ATTACHMENT 6
#define CFTYPE_EVENT 7
/*
** A single F-card within a manifest
*/
struct ManifestFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
char *zPerm; /* File permissions */
char *zPrior; /* Prior name if the name was changed */
};
/*
** A parsed manifest or cluster.
*/
struct Manifest {
Blob content; /* The original content blob */
int type; /* Type of artifact. One of CFTYPE_xxxxx */
int rid; /* The blob-id for this manifest */
char *zBaseline; /* Baseline manifest. The B card. */
Manifest *pBaseline; /* The actual baseline manifest */
char *zComment; /* Decoded comment. The C card. */
double rDate; /* Date and time from D card. 0.0 if no D card. */
char *zUser; /* Name of the user from the U card. */
char *zRepoCksum; /* MD5 checksum of the baseline content. R card. */
char *zWiki; /* Text of the wiki page. W card. */
char *zWikiTitle; /* Name of the wiki page. L card. */
double rEventDate; /* Date of an event. E card. */
char *zEventId; /* UUID for an event. E card. */
char *zTicketUuid; /* UUID for a ticket. K card. */
char *zAttachName; /* Filename of an attachment. A card. */
char *zAttachSrc; /* UUID of document being attached. A card. */
char *zAttachTarget; /* Ticket or wiki that attachment applies to. A card */
int nFile; /* Number of F cards */
int nFileAlloc; /* Slots allocated in aFile[] */
int iFile; /* Index of current file in iterator */
ManifestFile *aFile; /* One entry for each F-card */
int nParent; /* Number of parents. */
int nParentAlloc; /* Slots allocated in azParent[] */
char **azParent; /* UUIDs of parents. One for each P card argument */
int nCChild; /* Number of cluster children */
int nCChildAlloc; /* Number of closts allocated in azCChild[] */
char **azCChild; /* UUIDs of referenced objects in a cluster. M cards */
int nTag; /* Number of T Cards */
|
| ︙ | ︙ | |||
85 86 87 88 89 90 91 | }; #endif /* ** A cache of parsed manifests. This reduces the number of ** calls to manifest_parse() when doing a rebuild. */ | | < | | > | | | | | | > | > | > | > > | | | | | | | | | | | | | | | | | | > | > | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 124 125 126 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 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 254 255 256 257 258 259 260 261 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 |
};
#endif
/*
** A cache of parsed manifests. This reduces the number of
** calls to manifest_parse() when doing a rebuild.
*/
#define MX_MANIFEST_CACHE 6
static struct {
int nxAge;
int aAge[MX_MANIFEST_CACHE];
Manifest *apManifest[MX_MANIFEST_CACHE];
} manifestCache;
/*
** Clear the memory allocated in a manifest object
*/
void manifest_destroy(Manifest *p){
if( p ){
blob_reset(&p->content);
free(p->aFile);
free(p->azParent);
free(p->azCChild);
free(p->aTag);
free(p->aField);
if( p->pBaseline ) manifest_destroy(p->pBaseline);
fossil_free(p);
}
}
/*
** Add an element to the manifest cache using LRU replacement.
*/
void manifest_cache_insert(Manifest *p){
while( p ){
int i;
Manifest *pBaseline = p->pBaseline;
p->pBaseline = 0;
for(i=0; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.apManifest[i]==0 ) break;
}
if( i>=MX_MANIFEST_CACHE ){
int oldest = 0;
int oldestAge = manifestCache.aAge[0];
for(i=1; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.aAge[i]<oldestAge ){
oldest = i;
oldestAge = manifestCache.aAge[i];
}
}
manifest_destroy(manifestCache.apManifest[oldest]);
i = oldest;
}
manifestCache.aAge[i] = ++manifestCache.nxAge;
manifestCache.apManifest[i] = p;
p = pBaseline;
}
}
/*
** Try to extract a line from the manifest cache. Return 1 if found.
** Return 0 if not found.
*/
static Manifest *manifest_cache_find(int rid){
int i;
Manifest *p;
for(i=0; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.apManifest[i] && manifestCache.apManifest[i]->rid==rid ){
p = manifestCache.apManifest[i];
manifestCache.apManifest[i] = 0;
return p;
}
}
return 0;
}
/*
** Clear the manifest cache.
*/
void manifest_cache_clear(void){
int i;
for(i=0; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.apManifest[i] ){
manifest_destroy(manifestCache.apManifest[i]);
}
}
memset(&manifestCache, 0, sizeof(manifestCache));
}
#ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
# define md5sum_init(X)
# define md5sum_step_text(X,Y)
#endif
/*
** Remove the PGP signature from the artifact, if there is one.
*/
static void remove_pgp_signature(char **pz, int *pn){
char *z = *pz;
int n = *pn;
int i;
if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
for(i=34; i<n && (z[i-1]!='\n' || z[i-2]!='\n'); i++){}
if( i>=n ) return;
z += i;
n -= i;
*pz = z;
for(i=n-1; i>=0; i--){
if( z[i]=='\n' && memcmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
n = i+1;
break;
}
}
*pn = n;
return;
}
/*
** Verify the Z-card checksum on the artifact, if there is such a
** checksum. Return 0 if there is no Z-card. Return 1 if the Z-card
** exists and is correct. Return 2 if the Z-card exists and has the wrong
** value.
**
** 0123456789 123456789 123456789 123456789
** Z aea84f4f863865a8d59d0384e4d2a41c
*/
static int verify_z_card(const char *z, int n){
if( n<35 ) return 0;
if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0;
md5sum_init();
md5sum_step_text(z, n-35);
if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){
return 1;
}else{
return 2;
}
}
/*
** A structure used for rapid parsing of the Manifest file
*/
typedef struct ManifestText ManifestText;
struct ManifestText {
char *z; /* The first character of the next token */
char *zEnd; /* One character beyond the end of the manifest */
int atEol; /* True if z points to the start of a new line */
};
/*
** Return a pointer to the next token. The token is zero-terminated.
** Return NULL if there are no more tokens on the current line.
*/
static char *next_token(ManifestText *p, int *pLen){
char *z;
char *zStart;
int c;
if( p->atEol ) return 0;
zStart = z = p->z;
while( (c=(*z))!=' ' && c!='\n' ){ z++; }
*z = 0;
p->z = &z[1];
p->atEol = c=='\n';
if( pLen ) *pLen = z - zStart;
return zStart;
}
/*
** Return the card-type for the next card. Or, return 0 if there are no
** more cards or if we are not at the end of the current card.
*/
static char next_card(ManifestText *p){
char c;
if( !p->atEol || p->z>=p->zEnd ) return 0;
c = p->z[0];
if( p->z[1]==' ' ){
p->z += 2;
p->atEol = 0;
}else if( p->z[1]=='\n' ){
p->z += 2;
p->atEol = 1;
}else{
c = 0;
}
return c;
}
/*
** Parse a blob into a Manifest object. The Manifest object
** takes over the input blob and will free it when the
** Manifest object is freed. Zeros are inserted into the blob
** as string terminators so that blob should not be used again.
**
|
| ︙ | ︙ | |||
193 194 195 196 197 198 199 | ** The file consists of zero or more cards, one card per line. ** (Except: the content of the W card can extend of multiple lines.) ** Each card is divided into tokens by a single space character. ** The first token is a single upper-case letter which is the card type. ** The card type determines the other parameters to the card. ** Cards must occur in lexicographical order. */ | | | | > > > > > | > > | > > > > | > > > > > > > > > > > > > > > > > | < > | | < | > < < < < < < < < < < < < < < < < < < | | | > > | < < < < | < | > > > > > > > > > > > > > > > < | | < < < | < < < | > < < | < < < < | > | < | | < < < < < | < | < > > > > > | | | < < < < | | | < | | 302 303 304 305 306 307 308 309 310 311 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 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 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 475 476 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 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
** The file consists of zero or more cards, one card per line.
** (Except: the content of the W card can extend of multiple lines.)
** Each card is divided into tokens by a single space character.
** The first token is a single upper-case letter which is the card type.
** The card type determines the other parameters to the card.
** Cards must occur in lexicographical order.
*/
static Manifest *manifest_parse(Blob *pContent, int rid){
Manifest *p;
int seenZ = 0;
int i, lineNo=0;
ManifestText x;
char cPrevType = 0;
char cType;
char *z;
int n;
char *zUuid;
int sz;
/* Every control artifact ends with a '\n' character. Exit early
** if that is not the case for this artifact.
*/
z = blob_buffer(pContent);
n = blob_size(pContent);
if( n<=0 || z[n-1]!='\n' ){
blob_reset(pContent);
return 0;
}
/* Strip off the PGP signature if there is one. Then verify the
** Z-card.
*/
remove_pgp_signature(&z, &n);
if( verify_z_card(z, n)==0 ){
blob_reset(pContent);
return 0;
}
/* Verify that the first few characters of the artifact look like
** a control artifact.
*/
if( n<10 || z[0]<'A' || z[0]>'Z' || z[1]!=' ' ){
blob_reset(pContent);
return 0;
}
/* Allocate a Manifest object to hold the parsed control artifact.
*/
p = fossil_malloc( sizeof(*p) );
memset(p, 0, sizeof(*p));
memcpy(&p->content, pContent, sizeof(p->content));
p->rid = rid;
blob_zero(pContent);
pContent = &p->content;
/* Begin parsing, card by card.
*/
x.z = z;
x.zEnd = &z[n];
x.atEol = 1;
while( (cType = next_card(&x))!=0 && cType>=cPrevType ){
lineNo++;
switch( cType ){
/*
** A <filename> <target> ?<source>?
**
** Identifies an attachment to either a wiki page or a ticket.
** <source> is the artifact that is the attachment. <source>
** is omitted to delete an attachment. <target> is the name of
** a wiki page or ticket to which that attachment is connected.
*/
case 'A': {
char *zName, *zTarget, *zSrc;
int nTarget, nSrc;
zName = next_token(&x, 0);
zTarget = next_token(&x, &nTarget);
zSrc = next_token(&x, &nSrc);
if( zName==0 || zTarget==0 ) goto manifest_syntax_error;
if( p->zAttachName!=0 ) goto manifest_syntax_error;
defossilize(zName);
if( !file_is_simple_pathname(zName) ){
goto manifest_syntax_error;
}
defossilize(zTarget);
if( (nTarget!=UUID_SIZE || !validate16(zTarget, UUID_SIZE))
&& !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
goto manifest_syntax_error;
}
if( zSrc && (nSrc!=UUID_SIZE || !validate16(zSrc, UUID_SIZE)) ){
goto manifest_syntax_error;
}
p->zAttachName = (char*)file_tail(zName);
p->zAttachSrc = zSrc;
p->zAttachTarget = zTarget;
break;
}
/*
** B <uuid>
**
** A B-line gives the UUID for the baselinen of a delta-manifest.
*/
case 'B': {
if( p->zBaseline ) goto manifest_syntax_error;
p->zBaseline = next_token(&x, &sz);
if( p->zBaseline==0 ) goto manifest_syntax_error;
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(p->zBaseline, UUID_SIZE) ) goto manifest_syntax_error;
break;
}
/*
** C <comment>
**
** Comment text is fossil-encoded. There may be no more than
** one C line. C lines are required for manifests and are
** disallowed on all other control files.
*/
case 'C': {
if( p->zComment!=0 ) goto manifest_syntax_error;
p->zComment = next_token(&x, 0);
if( p->zComment==0 ) goto manifest_syntax_error;
defossilize(p->zComment);
break;
}
/*
** D <timestamp>
**
** The timestamp should be ISO 8601. YYYY-MM-DDtHH:MM:SS
** There can be no more than 1 D line. D lines are required
** for all control files except for clusters.
*/
case 'D': {
if( p->rDate>0.0 ) goto manifest_syntax_error;
p->rDate = db_double(0.0, "SELECT julianday(%Q)", next_token(&x,0));
if( p->rDate<=0.0 ) goto manifest_syntax_error;
break;
}
/*
** E <timestamp> <uuid>
**
** An "event" card that contains the timestamp of the event in the
** format YYYY-MM-DDtHH:MM:SS and a unique identifier for the event.
** The event timestamp is distinct from the D timestamp. The D
** timestamp is when the artifact was created whereas the E timestamp
** is when the specific event is said to occur.
*/
case 'E': {
if( p->rEventDate>0.0 ) goto manifest_syntax_error;
p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
if( p->rEventDate<=0.0 ) goto manifest_syntax_error;
p->zEventId = next_token(&x, &sz);
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(p->zEventId, UUID_SIZE) ) goto manifest_syntax_error;
break;
}
/*
** F <filename> ?<uuid>? ?<permissions>? ?<old-name>?
**
** Identifies a file in a manifest. Multiple F lines are
** allowed in a manifest. F lines are not allowed in any
** other control file. The filename and old-name are fossil-encoded.
*/
case 'F': {
char *zName, *zPerm, *zPriorName;
zName = next_token(&x,0);
if( zName==0 ) goto manifest_syntax_error;
defossilize(zName);
if( !file_is_simple_pathname(zName) ){
goto manifest_syntax_error;
}
zUuid = next_token(&x, &sz);
if( p->zBaseline==0 || zUuid!=0 ){
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
}
zPerm = next_token(&x,0);
zPriorName = next_token(&x,0);
if( zPriorName ){
defossilize(zPriorName);
if( !file_is_simple_pathname(zPriorName) ){
goto manifest_syntax_error;
}
}
if( p->nFile>=p->nFileAlloc ){
p->nFileAlloc = p->nFileAlloc*2 + 10;
p->aFile = fossil_realloc(p->aFile,
p->nFileAlloc*sizeof(p->aFile[0]) );
}
i = p->nFile++;
p->aFile[i].zName = zName;
p->aFile[i].zUuid = zUuid;
p->aFile[i].zPerm = zPerm;
p->aFile[i].zPrior = zPriorName;
if( i>0 && strcmp(p->aFile[i-1].zName, zName)>=0 ){
goto manifest_syntax_error;
}
break;
}
/*
** J <name> ?<value>?
**
** Specifies a name value pair for ticket. If the first character
** of <name> is "+" then the <value> is appended to any preexisting
** value. If <value> is omitted then it is understood to be an
** empty string.
*/
case 'J': {
char *zName, *zValue;
zName = next_token(&x,0);
zValue = next_token(&x,0);
if( zName==0 ) goto manifest_syntax_error;
if( zValue==0 ) zValue = "";
defossilize(zValue);
if( p->nField>=p->nFieldAlloc ){
p->nFieldAlloc = p->nFieldAlloc*2 + 10;
p->aField = fossil_realloc(p->aField,
p->nFieldAlloc*sizeof(p->aField[0]) );
}
i = p->nField++;
|
| ︙ | ︙ | |||
424 425 426 427 428 429 430 |
/*
** K <uuid>
**
** A K-line gives the UUID for the ticket which this control file
** is amending.
*/
case 'K': {
| < < | | | | < < < | | < | < | < | | 536 537 538 539 540 541 542 543 544 545 546 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 |
/*
** K <uuid>
**
** A K-line gives the UUID for the ticket which this control file
** is amending.
*/
case 'K': {
if( p->zTicketUuid!=0 ) goto manifest_syntax_error;
p->zTicketUuid = next_token(&x, &sz);
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(p->zTicketUuid, UUID_SIZE) ) goto manifest_syntax_error;
break;
}
/*
** L <wikititle>
**
** The wiki page title is fossil-encoded. There may be no more than
** one L line.
*/
case 'L': {
if( p->zWikiTitle!=0 ) goto manifest_syntax_error;
p->zWikiTitle = next_token(&x,0);
if( p->zWikiTitle==0 ) goto manifest_syntax_error;
defossilize(p->zWikiTitle);
if( !wiki_name_is_wellformed((const unsigned char *)p->zWikiTitle) ){
goto manifest_syntax_error;
}
break;
}
/*
** M <uuid>
**
** An M-line identifies another artifact by its UUID. M-lines
** occur in clusters only.
*/
case 'M': {
zUuid = next_token(&x, &sz);
if( zUuid==0 ) goto manifest_syntax_error;
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nCChild>=p->nCChildAlloc ){
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
p->azCChild = fossil_realloc(p->azCChild
, p->nCChildAlloc*sizeof(p->azCChild[0]) );
}
i = p->nCChild++;
|
| ︙ | ︙ | |||
488 489 490 491 492 493 494 |
** P <uuid> ...
**
** Specify one or more other artifacts where are the parents of
** this artifact. The first parent is the primary parent. All
** others are parents by merge.
*/
case 'P': {
| < | < | < < | < | < | < | | < | | < < < < | < < | < | | | 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 |
** P <uuid> ...
**
** Specify one or more other artifacts where are the parents of
** this artifact. The first parent is the primary parent. All
** others are parents by merge.
*/
case 'P': {
while( (zUuid = next_token(&x, &sz))!=0 ){
if( sz!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nParent>=p->nParentAlloc ){
p->nParentAlloc = p->nParentAlloc*2 + 5;
p->azParent = fossil_realloc(p->azParent,
p->nParentAlloc*sizeof(char*));
}
i = p->nParent++;
p->azParent[i] = zUuid;
}
break;
}
/*
** R <md5sum>
**
** Specify the MD5 checksum over the name and content of all files
** in the manifest.
*/
case 'R': {
if( p->zRepoCksum!=0 ) goto manifest_syntax_error;
p->zRepoCksum = next_token(&x, &sz);
if( sz!=32 ) goto manifest_syntax_error;
if( !validate16(p->zRepoCksum, 32) ) goto manifest_syntax_error;
break;
}
/*
** T (+|*|-)<tagname> <uuid> ?<value>?
**
** Create or cancel a tag or property. The tagname is fossil-encoded.
** The first character of the name must be either "+" to create a
** singleton tag, "*" to create a propagating tag, or "-" to create
** anti-tag that undoes a prior "+" or blocks propagation of of
** a "*".
**
** The tag is applied to <uuid>. If <uuid> is "*" then the tag is
** applied to the current manifest. If <value> is provided then
** the tag is really a property with the given value.
**
** Tags are not allowed in clusters. Multiple T lines are allowed.
*/
case 'T': {
char *zName, *zValue;
zName = next_token(&x, 0);
if( zName==0 ) goto manifest_syntax_error;
zUuid = next_token(&x, &sz);
if( zUuid==0 ) goto manifest_syntax_error;
zValue = next_token(&x, 0);
if( zValue ) defossilize(zValue);
if( sz==UUID_SIZE && validate16(zUuid, UUID_SIZE) ){
/* A valid uuid */
}else if( sz==1 && zUuid[0]=='*' ){
zUuid = 0;
}else{
goto manifest_syntax_error;
}
defossilize(zName);
if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' ){
goto manifest_syntax_error;
|
| ︙ | ︙ | |||
591 592 593 594 595 596 597 |
** U ?<login>?
**
** Identify the user who created this control file by their
** login. Only one U line is allowed. Prohibited in clusters.
** If the user name is omitted, take that to be "anonymous".
*/
case 'U': {
| < | > < < > | < | | | > > > < | < | | | | > < < < < | < | | < < < < < < | | | 680 681 682 683 684 685 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 |
** U ?<login>?
**
** Identify the user who created this control file by their
** login. Only one U line is allowed. Prohibited in clusters.
** If the user name is omitted, take that to be "anonymous".
*/
case 'U': {
if( p->zUser!=0 ) goto manifest_syntax_error;
p->zUser = next_token(&x, 0);
if( p->zUser==0 ){
p->zUser = "anonymous";
}else{
defossilize(p->zUser);
}
break;
}
/*
** W <size>
**
** The next <size> bytes of the file contain the text of the wiki
** page. There is always an extra \n before the start of the next
** record.
*/
case 'W': {
char *zSize;
int size, c;
Blob wiki;
zSize = next_token(&x, 0);
if( zSize==0 ) goto manifest_syntax_error;
if( x.atEol==0 ) goto manifest_syntax_error;
for(size=0; (c = zSize[0])>='0' && c<='9'; zSize++){
size = size*10 + c - '0';
}
if( size<0 ) goto manifest_syntax_error;
if( p->zWiki!=0 ) goto manifest_syntax_error;
blob_zero(&wiki);
if( (&x.z[size+1])>=x.zEnd ) goto manifest_syntax_error;
p->zWiki = x.z;
x.z += size;
if( x.z[0]!='\n' ) goto manifest_syntax_error;
x.z[0] = 0;
x.z++;
break;
}
/*
** Z <md5sum>
**
** MD5 checksum on this control file. The checksum is over all
** lines (other than PGP-signature lines) prior to the current
** line. This must be the last record.
**
** This card is required for all control file types except for
** Manifest. It is not required for manifest only for historical
** compatibility reasons.
*/
case 'Z': {
zUuid = next_token(&x, &sz);
if( sz!=32 ) goto manifest_syntax_error;
if( !validate16(zUuid, 32) ) goto manifest_syntax_error;
seenZ = 1;
break;
}
default: {
goto manifest_syntax_error;
}
}
}
if( x.z<x.zEnd ) goto manifest_syntax_error;
if( p->nFile>0 || p->zRepoCksum!=0 || p->zBaseline ){
if( p->nCChild>0 ) goto manifest_syntax_error;
if( p->rDate<=0.0 ) goto manifest_syntax_error;
if( p->nField>0 ) goto manifest_syntax_error;
if( p->zTicketUuid ) goto manifest_syntax_error;
if( p->zWiki ) goto manifest_syntax_error;
if( p->zWikiTitle ) goto manifest_syntax_error;
if( p->zEventId ) goto manifest_syntax_error;
|
| ︙ | ︙ | |||
752 753 754 755 756 757 758 |
if( p->nField>0 ) goto manifest_syntax_error;
if( p->zTicketUuid ) goto manifest_syntax_error;
if( p->zWikiTitle ) goto manifest_syntax_error;
if( p->zTicketUuid ) goto manifest_syntax_error;
p->type = CFTYPE_MANIFEST;
}
md5sum_init();
| | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 |
if( p->nField>0 ) goto manifest_syntax_error;
if( p->zTicketUuid ) goto manifest_syntax_error;
if( p->zWikiTitle ) goto manifest_syntax_error;
if( p->zTicketUuid ) goto manifest_syntax_error;
p->type = CFTYPE_MANIFEST;
}
md5sum_init();
return p;
manifest_syntax_error:
/*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
md5sum_init();
manifest_destroy(p);
return 0;
}
/*
** Get a manifest given the rid for the control artifact. Return
** a pointer to the manifest on success or NULL if there is a failure.
*/
Manifest *manifest_get(int rid, int cfType){
Blob content;
Manifest *p;
p = manifest_cache_find(rid);
if( p ){
if( cfType!=CFTYPE_ANY && cfType!=p->type ){
manifest_cache_insert(p);
p = 0;
}
return p;
}
content_get(rid, &content);
p = manifest_parse(&content, rid);
if( p && cfType!=CFTYPE_ANY && cfType!=p->type ){
manifest_destroy(p);
p = 0;
}
return p;
}
/*
** Given a checkin name, load and parse the manifest for that checkin.
** Throw a fatal error if anything goes wrong.
*/
Manifest *manifest_get_by_name(const char *zName, int *pRid){
int rid;
Manifest *p;
rid = name_to_rid(zName);
if( !is_a_version(rid) ){
fossil_fatal("no such checkin: %s", zName);
}
if( pRid ) *pRid = rid;
p = manifest_get(rid, CFTYPE_MANIFEST);
if( p==0 ){
fossil_fatal("cannot parse manifest for checkin: %s", zName);
}
return p;
}
/*
** COMMAND: test-parse-manifest
**
** Usage: %fossil test-parse-manifest FILENAME ?N?
**
** Parse the manifest and discarded. Use for testing only.
*/
void manifest_test_parse_cmd(void){
Manifest *p;
Blob b;
int i;
int n = 1;
if( g.argc!=3 && g.argc!=4 ){
usage("FILENAME");
}
db_must_be_within_tree();
blob_read_from_file(&b, g.argv[2]);
if( g.argc>3 ) n = atoi(g.argv[3]);
for(i=0; i<n; i++){
Blob b2;
blob_copy(&b2, &b);
p = manifest_parse(&b2, 0);
manifest_destroy(p);
}
}
/*
** Fetch the baseline associated with the delta-manifest p.
** Print a fatal-error and quit if unable to load the baseline.
*/
static void fetch_baseline(Manifest *p){
if( p->zBaseline!=0 && p->pBaseline==0 ){
int rid = uuid_to_rid(p->zBaseline, 0);
p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST);
if( p->pBaseline==0 ){
fossil_fatal("cannot access baseline manifest %S", p->zBaseline);
}
}
}
/*
** Rewind a manifest-file iterator back to the beginning of the manifest.
*/
void manifest_file_rewind(Manifest *p){
p->iFile = 0;
fetch_baseline(p);
if( p->pBaseline ){
p->pBaseline->iFile = 0;
}
}
/*
** Advance to the next manifest-file.
**
** Return NULL for end-of-records or if there is an error. If an error
** occurs and pErr!=0 then store 1 in *pErr.
*/
ManifestFile *manifest_file_next(
Manifest *p,
int *pErr
){
ManifestFile *pOut = 0;
if( pErr ) *pErr = 0;
if( p->pBaseline==0 ){
/* Manifest p is a baseline-manifest. Just scan down the list
** of files. */
if( p->iFile<p->nFile ) pOut = &p->aFile[p->iFile++];
}else{
/* Manifest p is a delta-manifest. Scan the baseline but amend the
** file list in the baseline with changes described by p.
*/
Manifest *pB = p->pBaseline;
int cmp;
while(1){
if( pB->iFile>=pB->nFile ){
/* We have used all entries out of the baseline. Return the next
** entry from the delta. */
if( p->iFile<p->nFile ) pOut = &p->aFile[p->iFile++];
break;
}else if( p->iFile>=p->nFile ){
/* We have used all entries from the delta. Return the next
** entry from the baseline. */
if( pB->iFile<pB->nFile ) pOut = &pB->aFile[pB->iFile++];
break;
}else if( (cmp = strcmp(pB->aFile[pB->iFile].zName,
p->aFile[p->iFile].zName)) < 0 ){
/* The next baseline entry comes before the next delta entry.
** So return the baseline entry. */
pOut = &pB->aFile[pB->iFile++];
break;
}else if( cmp>0 ){
/* The next delta entry comes before the next baseline
** entry so return the delta entry */
pOut = &p->aFile[p->iFile++];
break;
}else if( p->aFile[p->iFile].zUuid ){
/* The next delta entry is a replacement for the next baseline
** entry. Skip the baseline entry and return the delta entry */
pB->iFile++;
pOut = &p->aFile[p->iFile++];
break;
}else{
/* The next delta entry is a delete of the next baseline
** entry. Skip them both. Repeat the loop to find the next
** non-delete entry. */
pB->iFile++;
p->iFile++;
continue;
}
}
}
return pOut;
}
/*
** Translate a filename into a filename-id (fnid). Create a new fnid
** if no previously exists.
*/
static int filename_to_fnid(const char *zFilename){
|
| ︙ | ︙ | |||
816 817 818 819 820 821 822 | /* ** Add a single entry to the mlink table. Also add the filename to ** the filename table if it is not there already. */ static void add_one_mlink( int mid, /* The record ID of the manifest */ | | | | | | | | > > | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > | > > > > > < | > > > | > > > | | | | | | > > | | < < < < < < < < < | < < | < | < > | < < | < < | < < < > | > > > | | < < | | | | < < > | | > > | | < | < < < < < < < | < < | | 1026 1027 1028 1029 1030 1031 1032 1033 1034 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 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
/*
** Add a single entry to the mlink table. Also add the filename to
** the filename table if it is not there already.
*/
static void add_one_mlink(
int mid, /* The record ID of the manifest */
const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */
const char *zToUuid, /* UUID for the mlink.fid. "" to delele */
const char *zFilename, /* Filename */
const char *zPrior /* Previous filename. NULL if unchanged */
){
int fnid, pfnid, pid, fid;
static Stmt s1;
fnid = filename_to_fnid(zFilename);
if( zPrior==0 ){
pfnid = 0;
}else{
pfnid = filename_to_fnid(zPrior);
}
if( zFromUuid==0 || zFromUuid[0]==0 ){
pid = 0;
}else{
pid = uuid_to_rid(zFromUuid, 1);
}
if( zToUuid==0 || zToUuid[0]==0 ){
fid = 0;
}else{
fid = uuid_to_rid(zToUuid, 1);
}
db_static_prepare(&s1,
"INSERT INTO mlink(mid,pid,fid,fnid,pfnid)"
"VALUES(:m,:p,:f,:n,:pfn)"
);
db_bind_int(&s1, ":m", mid);
db_bind_int(&s1, ":p", pid);
db_bind_int(&s1, ":f", fid);
db_bind_int(&s1, ":n", fnid);
db_bind_int(&s1, ":pfn", pfnid);
db_exec(&s1);
if( pid && fid ){
content_deltify(pid, fid, 0);
}
}
/*
** Do a binary search to find a file in the p->aFile[] array.
**
** As an optimization, guess that the file we seek is at index p->iFile.
** That will usually be the case. If it is not found there, then do the
** actual binary search.
**
** Update p->iFile to be the index of the file that is found.
*/
static ManifestFile *manifest_file_seek_base(Manifest *p, const char *zName){
int lwr, upr;
int c;
int i;
lwr = 0;
upr = p->nFile - 1;
if( p->iFile>=lwr && p->iFile<upr ){
c = strcmp(p->aFile[p->iFile+1].zName, zName);
if( c==0 ){
return &p->aFile[++p->iFile];
}else if( c>0 ){
upr = p->iFile;
}else{
lwr = p->iFile+1;
}
}
while( lwr<=upr ){
i = (lwr+upr)/2;
c = strcmp(p->aFile[i].zName, zName);
if( c<0 ){
lwr = i+1;
}else if( c>0 ){
upr = i-1;
}else{
p->iFile = i;
return &p->aFile[i];
}
}
return 0;
}
/*
** Locate a file named zName in the aFile[] array of the given manifest.
** Return a pointer to the appropriate ManifestFile object. Return NULL
** if not found.
**
** This routine works even if p is a delta-manifest. The pointer
** returned might be to the baseline.
**
** We assume that filenames are in sorted order and use a binary search.
*/
ManifestFile *manifest_file_seek(Manifest *p, const char *zName){
ManifestFile *pFile;
pFile = manifest_file_seek_base(p, zName);
if( pFile && pFile->zUuid==0 ) return 0;
if( pFile==0 && p->zBaseline ){
fetch_baseline(p);
pFile = manifest_file_seek_base(p->pBaseline, zName);
}
return pFile;
}
/*
** This strcmp() function handles NULL arguments. NULLs sort first.
*/
static int strcmp_null(const char *zOne, const char *zTwo){
if( zOne==0 ){
if( zTwo==0 ) return 0;
return -1;
}else if( zTwo==0 ){
return +1;
}else{
return strcmp(zOne, zTwo);
}
}
/*
** Add mlink table entries associated with manifest cid. The
** parent manifest is pid.
**
** A single mlink entry is added for every file that changed content
** and/or name going from pid to cid.
**
** Deleted files have mlink.fid=0.
** Added files have mlink.pid=0.
** Edited files have both mlink.pid!=0 and mlink.fid!=0
*/
static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){
Blob otherContent;
int otherRid;
int i, rc;
ManifestFile *pChildFile, *pParentFile;
Manifest **ppOther;
static Stmt eq;
db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid");
db_bind_int(&eq, ":mid", cid);
rc = db_step(&eq);
db_reset(&eq);
if( rc==SQLITE_ROW ) return;
assert( pParent==0 || pChild==0 );
if( pParent==0 ){
ppOther = &pParent;
otherRid = pid;
}else{
ppOther = &pChild;
otherRid = cid;
}
if( (*ppOther = manifest_cache_find(otherRid))==0 ){
content_get(otherRid, &otherContent);
if( blob_size(&otherContent)==0 ) return;
*ppOther = manifest_parse(&otherContent, otherRid);
if( *ppOther==0 ) return;
}
if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){
content_deltify(pid, cid, 0);
}
for(i=0, pChildFile=pChild->aFile; i<pChild->nFile; i++, pChildFile++){
if( pChildFile->zPrior ){
pParentFile = manifest_file_seek(pParent, pChildFile->zPrior);
if( pParentFile ){
add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid,
pChildFile->zName, pChildFile->zPrior);
}
}else{
pParentFile = manifest_file_seek(pParent, pChildFile->zName);
if( pParentFile==0 ){
if( pChildFile->zUuid ){
add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0);
}
}else if( strcmp_null(pChildFile->zUuid, pParentFile->zUuid)!=0 ){
add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid,
pChildFile->zName, 0);
}
}
}
if( pParent->zBaseline && pChild->zBaseline ){
for(i=0, pParentFile=pParent->aFile; i<pParent->nFile; i++, pParentFile++){
if( pParentFile->zUuid ) continue;
pChildFile = manifest_file_seek(pChild, pParentFile->zName);
if( pChildFile ){
add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0);
}
}
}
manifest_cache_insert(*ppOther);
}
/*
** True if manifest_crosslink_begin() has been called but
** manifest_crosslink_end() is still pending.
*/
static int manifest_crosslink_busy = 0;
|
| ︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 |
** Historical note: This routine original processed manifests only.
** Processing for other control artifacts was added later. The name
** of the routine, "manifest_crosslink", and the name of this source
** file, is a legacy of its original use.
*/
int manifest_crosslink(int rid, Blob *pContent){
int i;
| | | | | | | | | | | | | | | | > > > > > > > > > | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < | 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 |
** Historical note: This routine original processed manifests only.
** Processing for other control artifacts was added later. The name
** of the routine, "manifest_crosslink", and the name of this source
** file, is a legacy of its original use.
*/
int manifest_crosslink(int rid, Blob *pContent){
int i;
Manifest *p;
Stmt q;
int parentid = 0;
if( (p = manifest_cache_find(rid))!=0 ){
blob_reset(pContent);
}else if( (p = manifest_parse(pContent, rid))==0 ){
return 0;
}
if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
manifest_destroy(p);
return 0;
}
db_begin_transaction();
if( p->type==CFTYPE_MANIFEST ){
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
char *zCom;
for(i=0; i<p->nParent; i++){
int pid = uuid_to_rid(p->azParent[i], 1);
db_multi_exec("INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)"
"VALUES(%d, %d, %d, %.17g)", pid, rid, i==0, p->rDate);
if( i==0 ){
add_mlink(pid, 0, rid, p);
parentid = pid;
}
}
db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid);
while( db_step(&q)==SQLITE_ROW ){
int cid = db_column_int(&q, 0);
add_mlink(rid, p, cid, 0);
}
db_finalize(&q);
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment,"
"bgcolor,euser,ecomment)"
"VALUES('ci',"
" coalesce("
" (SELECT julianday(value) FROM tagxref WHERE tagid=%d AND rid=%d),"
" %.17g"
" ),"
" %d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>0),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
TAG_DATE, rid, p->rDate,
rid, p->zUser, p->zComment,
TAG_BGCOLOR, rid,
TAG_USER, rid,
TAG_COMMENT, rid
);
zCom = db_text(0, "SELECT coalesce(ecomment, comment) FROM event"
" WHERE rowid=last_insert_rowid()");
wiki_extract_links(zCom, rid, 0, p->rDate, 1, WIKI_INLINE);
free(zCom);
/* If this is a delta-manifest, record the fact that this repository
** contains delta manifests, to free the "commit" logic to generate
** new delta manifests.
*/
if( p->zBaseline!=0 ){
static int once = 0;
if( !once ){
db_set_int("seen-delta-manifest", 1, 0);
once = 0;
}
}
}
}
if( p->type==CFTYPE_CLUSTER ){
tag_insert("cluster", 1, 0, rid, p->rDate, rid);
for(i=0; i<p->nCChild; i++){
int mid;
mid = uuid_to_rid(p->azCChild[i], 1);
if( mid>0 ){
db_multi_exec("DELETE FROM unclustered WHERE rid=%d", mid);
}
}
}
if( p->type==CFTYPE_CONTROL
|| p->type==CFTYPE_MANIFEST
|| p->type==CFTYPE_EVENT
){
for(i=0; i<p->nTag; i++){
int tid;
int type;
if( p->aTag[i].zUuid ){
tid = uuid_to_rid(p->aTag[i].zUuid, 1);
}else{
tid = rid;
}
if( tid ){
switch( p->aTag[i].zName[0] ){
case '-': type = 0; break; /* Cancel prior occurances */
case '+': type = 1; break; /* Apply to target only */
case '*': type = 2; break; /* Propagate to descendants */
default:
fossil_fatal("unknown tag type in manifest: %s", p->aTag);
return 0;
}
tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue,
rid, p->rDate, tid);
}
}
if( parentid ){
tag_propagate_all(parentid);
}
}
if( p->type==CFTYPE_WIKI ){
char *zTag = mprintf("wiki-%s", p->zWikiTitle);
int tagid = tag_findid(zTag, 1);
int prior;
char *zComment;
int nWiki;
char zLength[40];
while( fossil_isspace(p->zWiki[0]) ) p->zWiki++;
nWiki = strlen(p->zWiki);
sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki);
tag_insert(zTag, 1, zLength, rid, p->rDate, rid);
free(zTag);
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
" ORDER BY mtime DESC",
tagid, p->rDate
);
if( prior ){
content_deltify(prior, rid, 0);
}
if( nWiki>0 ){
zComment = mprintf("Changes to wiki page [%h]", p->zWikiTitle);
}else{
zComment = mprintf("Deleted wiki page [%h]", p->zWikiTitle);
}
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment,"
" bgcolor,euser,ecomment)"
"VALUES('w',%.17g,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
p->rDate, rid, p->zUser, zComment,
TAG_BGCOLOR, rid,
TAG_BGCOLOR, rid,
TAG_USER, rid,
TAG_COMMENT, rid
);
free(zComment);
}
if( p->type==CFTYPE_EVENT ){
char *zTag = mprintf("event-%s", p->zEventId);
int tagid = tag_findid(zTag, 1);
int prior, subsequent;
int nWiki;
char zLength[40];
while( fossil_isspace(p->zWiki[0]) ) p->zWiki++;
nWiki = strlen(p->zWiki);
sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki);
tag_insert(zTag, 1, zLength, rid, p->rDate, rid);
free(zTag);
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
" ORDER BY mtime DESC",
tagid, p->rDate
);
if( prior ){
content_deltify(prior, rid, 0);
db_multi_exec(
"DELETE FROM event"
" WHERE type='e'"
" AND tagid=%d"
" AND objid IN (SELECT rid FROM tagxref WHERE tagid=%d)",
tagid, tagid
);
}
subsequent = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime>%.17g"
" ORDER BY mtime",
tagid, p->rDate
);
if( subsequent ){
content_deltify(rid, subsequent, 0);
}else{
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,tagid,user,comment,bgcolor)"
"VALUES('e',%.17g,%d,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
p->rEventDate, rid, tagid, p->zUser, p->zComment,
TAG_BGCOLOR, rid
);
}
}
if( p->type==CFTYPE_TICKET ){
char *zTag;
assert( manifest_crosslink_busy==1 );
zTag = mprintf("tkt-%s", p->zTicketUuid);
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
free(zTag);
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
p->zTicketUuid);
}
if( p->type==CFTYPE_ATTACHMENT ){
db_multi_exec(
"INSERT INTO attachment(attachid, mtime, src, target,"
"filename, comment, user)"
"VALUES(%d,%.17g,%Q,%Q,%Q,%Q,%Q);",
rid, p->rDate, p->zAttachSrc, p->zAttachTarget, p->zAttachName,
(p->zComment ? p->zComment : ""), p->zUser
);
db_multi_exec(
"UPDATE attachment SET isLatest = (mtime=="
"(SELECT max(mtime) FROM attachment"
" WHERE target=%Q AND filename=%Q))"
" WHERE target=%Q AND filename=%Q",
p->zAttachTarget, p->zAttachName,
p->zAttachTarget, p->zAttachName
);
if( strlen(p->zAttachTarget)!=UUID_SIZE
|| !validate16(p->zAttachTarget, UUID_SIZE)
){
char *zComment;
if( p->zAttachSrc && p->zAttachSrc[0] ){
zComment = mprintf("Add attachment \"%h\" to wiki page [%h]",
p->zAttachName, p->zAttachTarget);
}else{
zComment = mprintf("Delete attachment \"%h\" from wiki page [%h]",
p->zAttachName, p->zAttachTarget);
}
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment)"
"VALUES('w',%.17g,%d,%Q,%Q)",
p->rDate, rid, p->zUser, zComment
);
free(zComment);
}else{
char *zComment;
if( p->zAttachSrc && p->zAttachSrc[0] ){
zComment = mprintf("Add attachment \"%h\" to ticket [%.10s]",
p->zAttachName, p->zAttachTarget);
}else{
zComment = mprintf("Delete attachment \"%h\" from ticket [%.10s]",
p->zAttachName, p->zAttachTarget);
}
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment)"
"VALUES('t',%.17g,%d,%Q,%Q)",
p->rDate, rid, p->zUser, zComment
);
free(zComment);
}
}
db_end_transaction(0);
if( p->type==CFTYPE_MANIFEST ){
manifest_cache_insert(p);
}else{
manifest_destroy(p);
}
return 1;
}
|
Changes to src/md5.c.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 46 | int isInit; uint32 buf[4]; uint32 bits[2]; unsigned char in[64]; }; typedef struct Context MD5Context; /* | > > > > | > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
int isInit;
uint32 buf[4];
uint32 bits[2];
unsigned char in[64];
};
typedef struct Context MD5Context;
#if defined(__i386__) || defined(__x86_64__) || defined(_WIN32)
# define byteReverse(A,B)
#else
/*
* Convert an array of integers to little-endian.
* Note: this code is a no-op on little-endian machines.
*/
static void byteReverse (unsigned char *buf, unsigned longs){
uint32 t;
do {
t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
((unsigned)buf[1]<<8 | buf[0]);
*(uint32 *)buf = t;
buf += 4;
} while (--longs);
}
#endif
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
|
| ︙ | ︙ | |||
312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
/*
** Add the content of a blob to the incremental MD5 checksum.
*/
void md5sum_step_blob(Blob *p){
md5sum_step_text(blob_buffer(p), blob_size(p));
}
/*
** Finish the incremental MD5 checksum. Store the result in blob pOut
** if pOut!=0. Also return a pointer to the result.
**
** This resets the incremental checksum preparing for the next round
** of computation. The return pointer points to a static buffer that
| > > > > > > > > > > > > > > > > > > > > | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
/*
** Add the content of a blob to the incremental MD5 checksum.
*/
void md5sum_step_blob(Blob *p){
md5sum_step_text(blob_buffer(p), blob_size(p));
}
/*
** For trouble-shooting only:
**
** Report the current state of the incremental checksum.
*/
const char *md5sum_current_state(void){
unsigned int cksum = 0;
unsigned int *pFirst, *pLast;
static char zResult[12];
pFirst = (unsigned int*)&incrCtx;
pLast = (unsigned int*)((&incrCtx)+1);
while( pFirst<pLast ){
cksum += *pFirst;
pFirst++;
}
sqlite3_snprintf(sizeof(zResult), zResult, "%08x", cksum);
return zResult;
}
/*
** Finish the incremental MD5 checksum. Store the result in blob pOut
** if pOut!=0. Also return a pointer to the result.
**
** This resets the incremental checksum preparing for the next round
** of computation. The return pointer points to a static buffer that
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
static int totalSize; /* Total number of artifacts to process */
static int processCnt; /* Number processed so far */
static int ttyOutput; /* Do progress output */
static Bag bagDone; /* Bag of records rebuilt */
static char *zFNameFormat; /* Format string for filenames on deconstruct */
static int prefixLength; /* Length of directory prefix for deconstruct */
/*
** Called after each artifact is processed
*/
static void rebuild_step_done(rid){
/* assert( bag_find(&bagDone, rid)==0 ); */
bag_insert(&bagDone, rid);
if( ttyOutput ){
processCnt++;
if (!g.fQuiet) {
| > > > > > > > > > > > > > > > | < | 80 81 82 83 84 85 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 |
static int totalSize; /* Total number of artifacts to process */
static int processCnt; /* Number processed so far */
static int ttyOutput; /* Do progress output */
static Bag bagDone; /* Bag of records rebuilt */
static char *zFNameFormat; /* Format string for filenames on deconstruct */
static int prefixLength; /* Length of directory prefix for deconstruct */
/*
** 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;
}
}
/*
** Called after each artifact is processed
*/
static void rebuild_step_done(rid){
/* assert( bag_find(&bagDone, rid)==0 ); */
bag_insert(&bagDone, rid);
if( ttyOutput ){
processCnt++;
if (!g.fQuiet) {
percent_complete((processCnt*1000)/totalSize);
}
}
}
/*
** Rebuild cross-referencing information for the artifact
** rid with content pBase and all of its descendants. This
|
| ︙ | ︙ | |||
165 166 167 168 169 170 171 |
}
blob_reset(pUse);
rebuild_step_done(rid);
/* Call all children recursively */
rid = 0;
for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){
| | | > | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
}
blob_reset(pUse);
rebuild_step_done(rid);
/* Call all children recursively */
rid = 0;
for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){
static Stmt q2;
int sz;
db_static_prepare(&q2, "SELECT content, size FROM blob WHERE rid=:rid");
db_bind_int(&q2, ":rid", cid);
if( db_step(&q2)==SQLITE_ROW && (sz = db_column_int(&q2,1))>=0 ){
Blob delta, next;
db_ephemeral_blob(&q2, 0, &delta);
blob_uncompress(&delta, &delta);
blob_delta_apply(pBase, &delta, &next);
blob_reset(&delta);
db_reset(&q2);
if( i<nChild ){
rebuild_step(cid, sz, &next);
}else{
/* Tail recursion */
rid = cid;
size = sz;
blob_reset(pBase);
*pBase = next;
}
}else{
db_reset(&q2);
blob_reset(pBase);
}
}
bag_clear(&children);
}
}
|
| ︙ | ︙ | |||
235 236 237 238 239 240 241 |
int errCnt = 0;
char *zTable;
bag_init(&bagDone);
ttyOutput = doOut;
processCnt = 0;
if (!g.fQuiet) {
| | < | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
int errCnt = 0;
char *zTable;
bag_init(&bagDone);
ttyOutput = doOut;
processCnt = 0;
if (!g.fQuiet) {
percent_complete(0);
}
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master /*scan*/"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
|
| ︙ | ︙ |
Changes to src/sha1.c.
1 | /* | | < < < < < < < < < < < < < < < < > > > > > | > | | < | < < | < < | < < < < < | > | | < < < < < < < < > | < > > > | | < < < < < < < < > < < | < < | < < < | < < < | < < < < < < < | < < | | < < < < < < < < | < < < < < | < < | < < | < > > > > > > > < | | < < < < < | < < < < < | | | > > < < > | | | < < < | < | < | < < | | < | | | < | | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > | < > | > | | < < > | | < | | > | < > | < > | < > | | | | > > > > < | | > | < < | < < | < < < < | < | | < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < | < < < < | < < < < | | | | | | | < | < < < < < < > | < | < < < < < | < | < | > > > < | < < | < < < < < | < < < | | < < < < | | | > | | < | | | | < < < | < < < < < < < < < | < < < < < < < | < < < | | < < < | | > > | < < < < < | | | < < < | < < < | | < | | | < | < < < > | < < | < < < < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 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 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 124 125 126 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
/*
** This implementation of SHA1.
*/
#include <sys/types.h>
#include "config.h"
#include "sha1.h"
/*
** The SHA1 implementation below is adapted from:
**
** $NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $
** $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $
**
** SHA-1 in C
** By Steve Reid <steve@edmweb.com>
** 100% Public Domain
*/
typedef struct SHA1Context SHA1Context;
struct SHA1Context {
unsigned int state[5];
unsigned int count[2];
unsigned char buffer[64];
};
/*
* blk0() and blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
*
* blk0le() for little-endian and blk0be() for big-endian.
*/
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
#define blk0le(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#define blk0be(i) block->l[i]
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
/*
* (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
*
* Rl0() for little-endian and Rb0() for big-endian. Endianness is
* determined at run-time.
*/
#define Rl0(v,w,x,y,z,i) \
z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define Rb0(v,w,x,y,z,i) \
z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) \
z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) \
z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) \
z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) \
z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
typedef union {
unsigned char c[64];
unsigned int l[16];
} CHAR64LONG16;
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
void SHA1Transform(unsigned int state[5], const unsigned char buffer[64])
{
unsigned int a, b, c, d, e;
CHAR64LONG16 *block;
static int one = 1;
CHAR64LONG16 workspace;
block = &workspace;
(void)memcpy(block, buffer, 64);
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
if( 1 == *(unsigned char*)&one ){
Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3);
Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7);
Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11);
Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15);
}else{
Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3);
Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7);
Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11);
Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15);
}
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
/*
* SHA1Init - Initialize new context
*/
static void SHA1Init(SHA1Context *context){
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;
}
/*
* Run your data through this.
*/
static void SHA1Update(
SHA1Context *context,
const unsigned char *data,
unsigned int len
){
unsigned int i, j;
j = context->count[0];
if ((context->count[0] += len << 3) < j)
context->count[1] += (len>>29)+1;
j = (j >> 3) & 63;
if ((j + len) > 63) {
(void)memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->buffer);
for ( ; i + 63 < len; i += 64)
SHA1Transform(context->state, &data[i]);
j = 0;
} else {
i = 0;
}
(void)memcpy(&context->buffer[j], &data[i], len - i);
}
/*
* Add padding and return the message digest.
*/
static void SHA1Final(SHA1Context *context, unsigned char digest[20]){
unsigned int i;
unsigned char finalcount[8];
for (i = 0; i < 8; i++) {
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
SHA1Update(context, (const unsigned char *)"\200", 1);
while ((context->count[0] & 504) != 448)
SHA1Update(context, (const unsigned char *)"\0", 1);
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
if (digest) {
for (i = 0; i < 20; i++)
digest[i] = (unsigned char)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
}
/*
** Convert a digest into base-16. digest should be declared as
** "unsigned char digest[20]" in the calling function. The SHA1
** digest is stored in the first 20 bytes. zBuf should
|
| ︙ | ︙ | |||
439 440 441 442 443 444 445 |
static int incrInit = 0;
/*
** Add more text to the incremental SHA1 checksum.
*/
void sha1sum_step_text(const char *zText, int nBytes){
if( !incrInit ){
| | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
static int incrInit = 0;
/*
** Add more text to the incremental SHA1 checksum.
*/
void sha1sum_step_text(const char *zText, int nBytes){
if( !incrInit ){
SHA1Init(&incrCtx);
incrInit = 1;
}
if( nBytes<=0 ){
if( nBytes==0 ) return;
nBytes = strlen(zText);
}
SHA1Update(&incrCtx, (unsigned char*)zText, nBytes);
}
/*
** Add the content of a blob to the incremental SHA1 checksum.
*/
void sha1sum_step_blob(Blob *p){
sha1sum_step_text(blob_buffer(p), blob_size(p));
|
| ︙ | ︙ | |||
468 469 470 471 472 473 474 |
** of computation. The return pointer points to a static buffer that
** is overwritten by subsequent calls to this function.
*/
char *sha1sum_finish(Blob *pOut){
unsigned char zResult[20];
static char zOut[41];
sha1sum_step_text(0,0);
| | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
** of computation. The return pointer points to a static buffer that
** is overwritten by subsequent calls to this function.
*/
char *sha1sum_finish(Blob *pOut){
unsigned char zResult[20];
static char zOut[41];
sha1sum_step_text(0,0);
SHA1Final(&incrCtx, zResult);
incrInit = 0;
DigestToBase16(zResult, zOut);
if( pOut ){
blob_zero(pOut);
blob_append(pOut, zOut, 40);
}
return zOut;
|
| ︙ | ︙ | |||
495 496 497 498 499 500 501 |
unsigned char zResult[20];
char zBuf[10240];
in = fopen(zFilename,"rb");
if( in==0 ){
return 1;
}
| | | | | | | | | | | 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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
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);
if( n<=0 ) break;
SHA1Update(&ctx, (unsigned char*)zBuf, (unsigned)n);
}
fclose(in);
blob_zero(pCksum);
blob_resize(pCksum, 40);
SHA1Final(&ctx, zResult);
DigestToBase16(zResult, blob_buffer(pCksum));
return 0;
}
/*
** Compute the SHA1 checksum of a blob in memory. Store the resulting
** checksum in the blob pCksum. pCksum is assumed to be either
** uninitialized or the same blob as pIn.
**
** Return the number of errors.
*/
int sha1sum_blob(const Blob *pIn, Blob *pCksum){
SHA1Context ctx;
unsigned char zResult[20];
SHA1Init(&ctx);
SHA1Update(&ctx, (unsigned char*)blob_buffer(pIn), blob_size(pIn));
if( pIn==pCksum ){
blob_reset(pCksum);
}else{
blob_zero(pCksum);
}
blob_resize(pCksum, 40);
SHA1Final(&ctx, zResult);
DigestToBase16(zResult, blob_buffer(pCksum));
return 0;
}
/*
** Compute the SHA1 checksum of a zero-terminated string. The
** result is held in memory obtained from mprintf().
*/
char *sha1sum(const char *zIn){
SHA1Context ctx;
unsigned char zResult[20];
char zDigest[41];
SHA1Init(&ctx);
SHA1Update(&ctx, (unsigned const char*)zIn, strlen(zIn));
SHA1Final(&ctx, zResult);
DigestToBase16(zResult, zDigest);
return mprintf("%s", zDigest);
}
/*
** Convert a cleartext password for a specific user into a SHA1 hash.
**
|
| ︙ | ︙ | |||
573 574 575 576 577 578 579 |
*/
char *sha1_shared_secret(const char *zPw, const char *zLogin){
static char *zProjectId = 0;
SHA1Context ctx;
unsigned char zResult[20];
char zDigest[41];
| | | | | | | | | 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 |
*/
char *sha1_shared_secret(const char *zPw, const char *zLogin){
static char *zProjectId = 0;
SHA1Context ctx;
unsigned char zResult[20];
char zDigest[41];
SHA1Init(&ctx);
if( zProjectId==0 ){
zProjectId = db_get("project-code", 0);
/* On the first xfer request of a clone, the project-code is not yet
** known. Use the cleartext password, since that is all we have.
*/
if( zProjectId==0 ){
return mprintf("%s", zPw);
}
}
SHA1Update(&ctx, (unsigned char*)zProjectId, strlen(zProjectId));
SHA1Update(&ctx, (unsigned char*)"/", 1);
SHA1Update(&ctx, (unsigned char*)zLogin, strlen(zLogin));
SHA1Update(&ctx, (unsigned char*)"/", 1);
SHA1Update(&ctx, (unsigned const char*)zPw, strlen(zPw));
SHA1Final(&ctx, zResult);
DigestToBase16(zResult, zDigest);
return mprintf("%s", zDigest);
}
/*
** COMMAND: sha1sum
** %fossil sha1sum FILE...
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
212 213 214 215 216 217 218 |
/*
** Rebuild an entire entry in the TICKET table
*/
void ticket_rebuild_entry(const char *zTktUuid){
char *zTag = mprintf("tkt-%s", zTktUuid);
int tagid = tag_findid(zTag, 1);
Stmt q;
| | < | | | | | > | 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 |
/*
** Rebuild an entire entry in the TICKET table
*/
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);
if( pTicket ){
ticket_insert(pTicket, createFlag, rid);
manifest_ticket_event(rid, pTicket, createFlag, tagid);
manifest_destroy(pTicket);
}
createFlag = 0;
}
db_finalize(&q);
}
/*
** Create the subscript interpreter and load the "common" code.
|
| ︙ | ︙ | |||
751 752 753 754 755 756 757 |
" FROM attachment, blob"
" WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
" AND blob.rid=attachid"
" ORDER BY 1 DESC",
tagid, tagid
);
while( db_step(&q)==SQLITE_ROW ){
| < | | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
" FROM attachment, blob"
" WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
" AND blob.rid=attachid"
" ORDER BY 1 DESC",
tagid, tagid
);
while( db_step(&q)==SQLITE_ROW ){
Manifest *pTicket;
char zShort[12];
const char *zDate = db_column_text(&q, 0);
int rid = db_column_int(&q, 1);
const char *zChngUuid = db_column_text(&q, 2);
const char *zFile = db_column_text(&q, 4);
memcpy(zShort, zChngUuid, 10);
zShort[10] = 0;
|
| ︙ | ︙ | |||
775 776 777 778 779 780 781 |
@ <p>Add attachment "%h(zFile)"
}
@ [<a href="%s(g.zTop)/artifact/%T(zChngUuid)">%s(zShort)</a>]
@ (rid %d(rid)) by
hyperlink_to_user(zUser,zDate," on");
hyperlink_to_date(zDate, ".</p>");
}else{
| | | | | | | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
@ <p>Add attachment "%h(zFile)"
}
@ [<a href="%s(g.zTop)/artifact/%T(zChngUuid)">%s(zShort)</a>]
@ (rid %d(rid)) by
hyperlink_to_user(zUser,zDate," on");
hyperlink_to_date(zDate, ".</p>");
}else{
pTicket = manifest_get(rid, CFTYPE_TICKET);
if( pTicket ){
@
@ <p>Ticket change
@ [<a href="%s(g.zTop)/artifact/%T(zChngUuid)">%s(zShort)</a>]
@ (rid %d(rid)) by
hyperlink_to_user(pTicket->zUser,zDate," on");
hyperlink_to_date(zDate, ":");
@ </p>
ticket_output_change_artifact(pTicket);
}
manifest_destroy(pTicket);
}
}
db_finalize(&q);
style_footer();
}
/*
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
*/
if( nochangeFlag ){
db_end_transaction(1); /* With --nochange, rollback changes */
}else{
if( g.argc<=3 ){
/* All files updated. Shift the current checkout to the target. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
manifest_to_disk(tid);
db_lset_int("checkout", tid);
}else{
/* A subset of files have been checked out. Keep the current
** checkout unchanged. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
}
| > | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
*/
if( nochangeFlag ){
db_end_transaction(1); /* With --nochange, rollback changes */
}else{
if( g.argc<=3 ){
/* All files updated. Shift the current checkout to the target. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
checkout_set_all_exe(vid);
manifest_to_disk(tid);
db_lset_int("checkout", tid);
}else{
/* A subset of files have been checked out. Keep the current
** checkout unchanged. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
}
|
| ︙ | ︙ | |||
300 301 302 303 304 305 306 |
*/
int historical_version_of_file(
const char *revision, /* The checkin containing the file */
const char *file, /* Full treename of the file */
Blob *content, /* Put the content here */
int errCode /* Error code if file not found. Panic if 0. */
){
| < | > | | | | > | | | | | 301 302 303 304 305 306 307 308 309 310 311 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 |
*/
int historical_version_of_file(
const char *revision, /* The checkin containing the file */
const char *file, /* Full treename of the file */
Blob *content, /* Put the content here */
int errCode /* Error code if file not found. Panic if 0. */
){
Manifest *pManifest;
ManifestFile *pFile;
int rid=0;
if( revision ){
rid = name_to_rid(revision);
}else{
rid = db_lget_int("checkout", 0);
}
if( !is_a_version(rid) ){
if( errCode>0 ) return errCode;
fossil_fatal("no such checkin: %s", revision);
}
pManifest = manifest_get(rid, CFTYPE_MANIFEST);
if( pManifest ){
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
if( strcmp(pFile->zName, file)==0 ){
rid = uuid_to_rid(pFile->zUuid, 0);
manifest_destroy(pManifest);
return content_get(rid, content);
}
}
manifest_destroy(pManifest);
if( errCode<=0 ){
fossil_fatal("file %s does not exist in checkin: %s", file, revision);
}
}else if( errCode<=0 ){
fossil_panic("could not parse manifest for checkin: %s", revision);
}
return errCode;
|
| ︙ | ︙ | |||
384 385 386 387 388 389 390 391 392 393 |
blob_reset(&fname);
}
}else{
int vid;
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, 0);
db_multi_exec(
"INSERT INTO torevert "
"SELECT pathname"
" FROM vfile "
| > | | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
blob_reset(&fname);
}
}else{
int vid;
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, 0);
db_multi_exec(
"DELETE FROM vmerge;"
"INSERT INTO torevert "
"SELECT pathname"
" FROM vfile "
" WHERE chnged OR deleted OR rid=0 OR pathname!=origname;"
);
}
blob_zero(&record);
db_prepare(&q, "SELECT name FROM torevert");
while( db_step(&q)==SQLITE_ROW ){
zFile = db_column_text(&q, 0);
if( zRevision!=0 ){
|
| ︙ | ︙ |
Changes to src/vfile.c.
| ︙ | ︙ | |||
83 84 85 86 87 88 89 |
fossil_panic("bad object id: %d", rid);
}
}
}
}
/*
| | < < < < < | < > > | < > > | < < < | < < < < < < < < < < | | < | | | | | < < < > | 83 84 85 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 124 |
fossil_panic("bad object id: %d", rid);
}
}
}
}
/*
** Build a catalog of all files in a checkin.
*/
void vfile_build(int vid){
int rid;
Stmt ins;
Manifest *p;
ManifestFile *pFile;
db_begin_transaction();
vfile_verify_not_phantom(vid, 0, 0);
p = manifest_get(vid, CFTYPE_MANIFEST);
if( p==0 ) return;
db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
db_prepare(&ins,
"INSERT INTO vfile(vid,rid,mrid,pathname) "
" VALUES(:vid,:id,:id,:name)");
db_bind_int(&ins, ":vid", vid);
manifest_file_rewind(p);
while( (pFile = manifest_file_next(p,0))!=0 ){
rid = uuid_to_rid(pFile->zUuid, 0);
vfile_verify_not_phantom(rid, pFile->zName, pFile->zUuid);
db_bind_int(&ins, ":id", rid);
db_bind_text(&ins, ":name", pFile->zName);
db_step(&ins);
db_reset(&ins);
}
db_finalize(&ins);
manifest_destroy(p);
db_end_transaction(0);
}
/*
** Check the file signature of the disk image for every VFILE of vid.
**
** Set the VFILE.CHNGED field on every file that has changed. Also
|
| ︙ | ︙ | |||
367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
md5sum_step_text(" 0\n", -1);
continue;
}
fseek(in, 0L, SEEK_END);
sprintf(zBuf, " %ld\n", ftell(in));
fseek(in, 0L, SEEK_SET);
md5sum_step_text(zBuf, -1);
for(;;){
int n;
n = fread(zBuf, 1, sizeof(zBuf), in);
if( n<=0 ) break;
md5sum_step_text(zBuf, n);
}
fclose(in);
| > | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
md5sum_step_text(" 0\n", -1);
continue;
}
fseek(in, 0L, SEEK_END);
sprintf(zBuf, " %ld\n", ftell(in));
fseek(in, 0L, SEEK_SET);
md5sum_step_text(zBuf, -1);
/*printf("%s %s %s",md5sum_current_state(),zName,zBuf); fflush(stdout);*/
for(;;){
int n;
n = fread(zBuf, 1, sizeof(zBuf), in);
if( n<=0 ) break;
md5sum_step_text(zBuf, n);
}
fclose(in);
|
| ︙ | ︙ | |||
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
int rid = db_column_int(&q, 1);
md5sum_step_text(zName, -1);
content_get(rid, &file);
sprintf(zBuf, " %d\n", blob_size(&file));
md5sum_step_text(zBuf, -1);
md5sum_step_blob(&file);
blob_reset(&file);
}
db_finalize(&q);
md5sum_finish(pOut);
}
/*
** Compute an aggregate MD5 checksum over the repository image of every
** file in manifest vid. The file names are part of the checksum.
** Return the resulting checksum in blob pOut.
**
** If pManOut is not NULL then fill it with the checksum found in the
** "R" card near the end of the manifest.
*/
void vfile_aggregate_checksum_manifest(int vid, Blob *pOut, Blob *pManOut){
| > | | | > | | | > | | | | | | 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 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 |
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
int rid = db_column_int(&q, 1);
md5sum_step_text(zName, -1);
content_get(rid, &file);
sprintf(zBuf, " %d\n", blob_size(&file));
md5sum_step_text(zBuf, -1);
/*printf("%s %s %s",md5sum_current_state(),zName,zBuf); fflush(stdout);*/
md5sum_step_blob(&file);
blob_reset(&file);
}
db_finalize(&q);
md5sum_finish(pOut);
}
/*
** Compute an aggregate MD5 checksum over the repository image of every
** file in manifest vid. The file names are part of the checksum.
** Return the resulting checksum in blob pOut.
**
** If pManOut is not NULL then fill it with the checksum found in the
** "R" card near the end of the manifest.
*/
void vfile_aggregate_checksum_manifest(int vid, Blob *pOut, Blob *pManOut){
int fid;
Blob file;
Manifest *pManifest;
ManifestFile *pFile;
char zBuf[100];
blob_zero(pOut);
if( pManOut ){
blob_zero(pManOut);
}
db_must_be_within_tree();
pManifest = manifest_get(vid, CFTYPE_MANIFEST);
if( pManifest==0 ){
fossil_panic("manifest file (%d) is malformed", vid);
}
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
fid = uuid_to_rid(pFile->zUuid, 0);
md5sum_step_text(pFile->zName, -1);
content_get(fid, &file);
sprintf(zBuf, " %d\n", blob_size(&file));
md5sum_step_text(zBuf, -1);
md5sum_step_blob(&file);
blob_reset(&file);
}
if( pManOut ){
if( pManifest->zRepoCksum ){
blob_append(pManOut, pManifest->zRepoCksum, -1);
}else{
blob_zero(pManOut);
}
}
manifest_destroy(pManifest);
md5sum_finish(pOut);
}
/*
** COMMAND: test-agg-cksum
*/
void test_agg_cksum_cmd(void){
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
125 126 127 128 129 130 131 |
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
int rid = 0;
int isSandbox;
Blob wiki;
| | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
int rid = 0;
int isSandbox;
Blob wiki;
Manifest *pWiki = 0;
const char *zPageName;
char *zBody = mprintf("%s","<i>Empty Page</i>");
Stmt q;
int cnt = 0;
login_check_credentials();
if( !g.okRdWiki ){ login_needed(); return; }
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 |
zTag = mprintf("wiki-%s", zPageName);
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" ORDER BY mtime DESC", zTag
);
free(zTag);
| < < < < | < | | | < | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
zTag = mprintf("wiki-%s", zPageName);
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" ORDER BY mtime DESC", zTag
);
free(zTag);
pWiki = manifest_get(rid, CFTYPE_WIKI);
if( pWiki ){
while( fossil_isspace(pWiki->zWiki[0]) ) pWiki->zWiki++;
if( pWiki->zWiki[0] ) zBody = pWiki->zWiki;
}
}
if( !g.isHome ){
if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
style_submenu_element("Edit", "Edit Wiki Page", "%s/wikiedit?name=%T",
g.zTop, zPageName);
}
|
| ︙ | ︙ | |||
247 248 249 250 251 252 253 |
@ </li>
}
if( cnt ){
@ </ul>
}
db_finalize(&q);
| < | < | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
@ </li>
}
if( cnt ){
@ </ul>
}
db_finalize(&q);
manifest_destroy(pWiki);
style_footer();
}
/*
** WEBPAGE: wikiedit
** URL: /wikiedit?name=PAGENAME
*/
void wikiedit_page(void){
char *zTag;
int rid = 0;
int isSandbox;
Blob wiki;
Manifest *pWiki = 0;
const char *zPageName;
char *zHtmlPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
if( zBody ){
|
| ︙ | ︙ | |||
296 297 298 299 300 301 302 |
" ORDER BY mtime DESC", zTag
);
free(zTag);
if( (rid && !g.okWrWiki) || (!rid && !g.okNewWiki) ){
login_needed();
return;
}
| < < < < | < < | < | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
" ORDER BY mtime DESC", zTag
);
free(zTag);
if( (rid && !g.okWrWiki) || (!rid && !g.okNewWiki) ){
login_needed();
return;
}
if( zBody==0 && (pWiki = manifest_get(rid, CFTYPE_WIKI))!=0 ){
zBody = pWiki->zWiki;
}
}
if( P("submit")!=0 && zBody!=0 ){
char *zDate;
Blob cksum;
int nrid;
blob_zero(&wiki);
|
| ︙ | ︙ | |||
375 376 377 378 379 380 381 | @ <textarea name="w" class="wikiedit" cols="80" @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> @ <br /> @ <input type="submit" name="preview" value="Preview Your Changes" /> @ <input type="submit" name="submit" value="Apply These Changes" /> @ <input type="submit" name="cancel" value="Cancel" /> @ </div></form> | < | < | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | @ <textarea name="w" class="wikiedit" cols="80" @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> @ <br /> @ <input type="submit" name="preview" value="Preview Your Changes" /> @ <input type="submit" name="submit" value="Apply These Changes" /> @ <input type="submit" name="cancel" value="Cancel" /> @ </div></form> manifest_destroy(pWiki); style_footer(); } /* ** WEBPAGE: wikinew ** URL /wikinew ** |
| ︙ | ︙ | |||
475 476 477 478 479 480 481 |
return;
}
if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){
char *zDate;
Blob cksum;
int nrid;
Blob body;
| < | | < | | > < | 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 484 485 486 |
return;
}
if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){
char *zDate;
Blob cksum;
int nrid;
Blob body;
Blob wiki;
Manifest *pWiki = 0;
blob_zero(&body);
if( isSandbox ){
blob_appendf(&body, db_get("sandbox",""));
appendRemark(&body);
db_set("sandbox", blob_str(&body), 0);
}else{
login_verify_csrf_secret();
pWiki = manifest_get(rid, CFTYPE_WIKI);
if( pWiki ){
blob_append(&body, pWiki->zWiki, -1);
manifest_destroy(pWiki);
}
blob_zero(&wiki);
db_begin_transaction();
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&wiki, "D %s\n", zDate);
blob_appendf(&wiki, "L %F\n", zPageName);
if( rid ){
|
| ︙ | ︙ | |||
610 611 612 613 614 615 616 |
**
** Show the difference between two wiki pages.
*/
void wdiff_page(void){
char *zTitle;
int rid1, rid2;
const char *zPageName;
| < | | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
**
** Show the difference between two wiki pages.
*/
void wdiff_page(void){
char *zTitle;
int rid1, rid2;
const char *zPageName;
Manifest *pW1, *pW2 = 0;
Blob w1, w2, d;
login_check_credentials();
rid1 = atoi(PD("a","0"));
if( !g.okHistory ){ login_needed(); return; }
if( rid1==0 ) fossil_redirect_home();
rid2 = atoi(PD("b","0"));
|
| ︙ | ︙ | |||
633 634 635 636 637 638 639 |
"SELECT objid FROM event JOIN tagxref ON objid=rid AND tagxref.tagid="
"(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
" WHERE event.mtime<(SELECT mtime FROM event WHERE objid=%d)"
" ORDER BY event.mtime DESC LIMIT 1",
zPageName, rid1
);
}
| | < | | | < < < | < > > | 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 |
"SELECT objid FROM event JOIN tagxref ON objid=rid AND tagxref.tagid="
"(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
" WHERE event.mtime<(SELECT mtime FROM event WHERE objid=%d)"
" ORDER BY event.mtime DESC LIMIT 1",
zPageName, rid1
);
}
pW1 = manifest_get(rid1, CFTYPE_WIKI);
if( pW1==0 ) fossil_redirect_home();
blob_init(&w1, pW1->zWiki, -1);
blob_zero(&w2);
if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI))!=0 ){
blob_init(&w2, pW2->zWiki, -1);
}
blob_zero(&d);
text_diff(&w2, &w1, &d, 5, 1);
@ <pre>
@ %h(blob_str(&d))
@ </pre>
manifest_destroy(pW1);
manifest_destroy(pW2);
style_footer();
}
/*
** WEBPAGE: wcontent
**
** all=1 Show deleted pages
|
| ︙ | ︙ | |||
912 913 914 915 916 917 918 |
if( n==0 ){
goto wiki_cmd_usage;
}
if( strncmp(g.argv[2],"export",n)==0 ){
char const *zPageName; /* Name of the wiki page to export */
char const *zFile; /* Name of the output file (0=stdout) */
| | | | | > < < | < < | < | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
if( n==0 ){
goto wiki_cmd_usage;
}
if( strncmp(g.argv[2],"export",n)==0 ){
char const *zPageName; /* Name of the wiki page to export */
char const *zFile; /* Name of the output file (0=stdout) */
int rid; /* Artifact ID of the wiki page */
int i; /* Loop counter */
char *zBody = 0; /* Wiki page content */
Manifest *pWiki = 0; /* Parsed wiki page content */
if( (g.argc!=4) && (g.argc!=5) ){
usage("export PAGENAME ?FILE?");
}
zPageName = g.argv[3];
rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x"
" WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
" ORDER BY x.mtime DESC LIMIT 1",
zPageName
);
if( (pWiki = manifest_get(rid, CFTYPE_WIKI))!=0 ){
zBody = pWiki->zWiki;
}
if( zBody==0 ){
fossil_fatal("wiki page [%s] not found",zPageName);
}
for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){}
zFile = (g.argc==4) ? 0 : g.argv[4];
if( zFile ){
|
| ︙ | ︙ | |||
953 954 955 956 957 958 959 |
}
if( ! zF ){
fossil_fatal("wiki export could not open output file for writing.");
}
fprintf(zF,"%.*s\n", i, zBody);
if( doClose ) fclose(zF);
}else{
| | > | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
}
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;
Blob content;
if( g.argc!=4 && g.argc!=5 ){
|
| ︙ | ︙ |
Changes to src/zip.c.
| ︙ | ︙ | |||
311 312 313 314 315 316 317 |
** added to as part of the zip file. It may be 0 or an empty string,
** in which case it is ignored. The intention is to create a zip which
** politely expands into a subdir instead of filling your current dir
** with source files. For example, pass a UUID or "ProjectName".
**
*/
void zip_of_baseline(int rid, Blob *pZip, const char *zDir){
| < | | > < < > | | > | | | | | | | | | | | | > | > | | < < > | 311 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 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 |
** added to as part of the zip file. It may be 0 or an empty string,
** in which case it is ignored. The intention is to create a zip which
** politely expands into a subdir instead of filling your current dir
** with source files. For example, pass a UUID or "ProjectName".
**
*/
void zip_of_baseline(int rid, Blob *pZip, const char *zDir){
Blob mfile, hash, file;
Manifest *pManifest;
ManifestFile *pFile;
Blob filename;
int nPrefix;
content_get(rid, &mfile);
if( blob_size(&mfile)==0 ){
blob_zero(pZip);
return;
}
blob_zero(&hash);
blob_zero(&filename);
zip_open();
if( zDir && zDir[0] ){
blob_appendf(&filename, "%s/", zDir);
}
nPrefix = blob_size(&filename);
pManifest = manifest_get(rid, CFTYPE_MANIFEST);
if( pManifest ){
char *zName;
zip_set_timedate(pManifest->rDate);
if( db_get_boolean("manifest", 0) ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
zip_add_folders(zName);
zip_add_file(zName, &mfile);
sha1sum_blob(&mfile, &hash);
blob_reset(&mfile);
blob_append(&hash, "\n", 1);
blob_resize(&filename, nPrefix);
blob_append(&filename, "manifest.uuid", -1);
zName = blob_str(&filename);
zip_add_file(zName, &hash);
blob_reset(&hash);
}
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
int fid = uuid_to_rid(pFile->zUuid, 0);
if( fid ){
content_get(fid, &file);
blob_resize(&filename, nPrefix);
blob_append(&filename, pFile->zName, -1);
zName = blob_str(&filename);
zip_add_folders(zName);
zip_add_file(zName, &file);
blob_reset(&file);
}
}
}else{
blob_reset(&mfile);
}
manifest_destroy(pManifest);
blob_reset(&filename);
zip_close(pZip);
}
/*
** COMMAND: zip
**
|
| ︙ | ︙ |
Changes to www/fileformat.wiki.
| ︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | No card may be duplicated. The entire manifest may be PGP clear-signed, but otherwise it may contain no additional text or data beyond what is described here. Allowed cards in the manifest are as follows: <blockquote> <b>C</b> <i>checkin-comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br> <b>F</b> <i>filename</i> <i>SHA1-hash</i> <i>permissions</i> <i>old-name</i><br> <b>P</b> <i>SHA1-hash</i>+<br> <b>R</b> <i>repository-checksum</i><br> <b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name <b>*</b> ?value?</i><br> <b>U</b> <i>user-login</i><br> <b>Z</b> <i>manifest-checksum</i> </blockquote> A manifest must have exactly one C-card. The sole argument to the C-card is a check-in comment that describes the check-in that the manifest defines. The check-in comment is text. The following escape sequences are applied to the text: A space (ASCII 0x20) is represented as "\s" (ASCII 0x5C, 0x73). A newline (ASCII 0x0a) is "\n" (ASCII 0x6C, x6E). A backslash | > > > > > > > > > | 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 124 | No card may be duplicated. The entire manifest may be PGP clear-signed, but otherwise it may contain no additional text or data beyond what is described here. Allowed cards in the manifest are as follows: <blockquote> <b>B</b> <i>baseline-manifest</i><br> <b>C</b> <i>checkin-comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br> <b>F</b> <i>filename</i> <i>SHA1-hash</i> <i>permissions</i> <i>old-name</i><br> <b>P</b> <i>SHA1-hash</i>+<br> <b>R</b> <i>repository-checksum</i><br> <b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name <b>*</b> ?value?</i><br> <b>U</b> <i>user-login</i><br> <b>Z</b> <i>manifest-checksum</i> </blockquote> A manifest may optionally have a single B-card. The B-card specifies another manifest that serves as the "baseline" for this manifest. A manifest that has a B-card is called a delta-manifest and a manifest that omits the B-card is a baseline-manifest. The other manifest identified by the argument of the B-card must be a baseline-manifest. A baseline-manifest records the complete contents of a checkin. A delta-manifest records only changes from its baseline. A manifest must have exactly one C-card. The sole argument to the C-card is a check-in comment that describes the check-in that the manifest defines. The check-in comment is text. The following escape sequences are applied to the text: A space (ASCII 0x20) is represented as "\s" (ASCII 0x5C, 0x73). A newline (ASCII 0x0a) is "\n" (ASCII 0x6C, x6E). A backslash |
| ︙ | ︙ | |||
123 124 125 126 127 128 129 | date and time should be in coordinated universal time (UTC). The format is: <blockquote> <i>YYYY</i><b>-</b><i>MM</i><b>-</b><i>DD</i><b>T</b><i>HH</i><b>:</b><i>MM</i><b>:</b><i>SS</i> </blockquote> | | < | > > > | | > | 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 | date and time should be in coordinated universal time (UTC). The format is: <blockquote> <i>YYYY</i><b>-</b><i>MM</i><b>-</b><i>DD</i><b>T</b><i>HH</i><b>:</b><i>MM</i><b>:</b><i>SS</i> </blockquote> A manifest has zero or more F-cards. Each F-card identifies a file that is part of the check-in. There are one, two, three, or four arguments. The first argument is the pathname of the file in the check-in relative to the root of the project file hierarchy. No ".." or "." directories are allowed within the filename. Space characters are escaped as in C-card comment text. Backslash characters and newlines are not allowed within filenames. The directory separator character is a forward slash (ASCII 0x2F). The second argument to the F-card is the full 40-character lower-case hexadecimal SHA1 hash of the content artifact. The second argument is required for baseline manifests but is optional for delta manifests. When the second argument to the F-card is omitted, it means that the file has been deleted relative to the baseline. The optional 3rd argument defines any special access permissions associated with the file. The only special code currently defined is "x" which means that the file is executable. All files are always readable and writable. This can be expressed by "w" permission if desired but is optional. The file format might be extended with new permission letters in the future. The optional 4th argument is the name of the same file as it existed in the parent check-in. If the name of the file is unchanged from its parent, then the 4th argument is omitted. A manifest has zero or one P-cards. Most manifests have one P-card. The P-card has a varying number of arguments that defines other manifests from which the current manifest |
| ︙ | ︙ | |||
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | <td> </td> <td> </td> <td> </td> <td> </td> <td align=center><b>X</b></td> <td> </td> </tr> <tr> <td><b>C</b> <i>comment-text</i></td> <td align=center><b>X</b></td> <td> </td> <td> </td> <td> </td> <td> </td> | > > > > > > > > > > | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | <td> </td> <td> </td> <td> </td> <td> </td> <td align=center><b>X</b></td> <td> </td> </tr> <tr> <td><b>B</b> <i>baseline</i></td> <td align=center><b>X</b></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><b>C</b> <i>comment-text</i></td> <td align=center><b>X</b></td> <td> </td> <td> </td> <td> </td> <td> </td> |
| ︙ | ︙ |