Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enhance the new TH1 artifact command with more flexible lookup semantics. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
00e4fedd85751b3fe08a188990b6dbeb |
| User & Date: | mistachkin 2014-06-16 18:49:10.342 |
Context
|
2014-06-17
| ||
| 11:51 | Add the ".eqp" dot-command to the ".help" output in the command-line shell. Fix CSV import issue, reported via the mailing list, in the shell when the file to be imported ends with an empty line. ... (check-in: 3467da7901 user: jan.nijtmans tags: trunk) | |
|
2014-06-16
| ||
| 20:01 | Merge updates from trunk. ... (check-in: 3c9cca2bd8 user: mistachkin tags: autoadjust) | |
| 18:49 | Enhance the new TH1 artifact command with more flexible lookup semantics. ... (check-in: 00e4fedd85 user: mistachkin tags: trunk) | |
| 18:34 | Fix memory leak in the new TH1 artifact command. ... (check-in: 74099a5c8d user: mistachkin tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | @ <hr /> content_get(rid, &content); @ <blockquote><pre> hexdump(&content); @ </pre></blockquote> style_footer(); } /* ** Look for "ci" and "filename" query parameters. If found, try to ** use them to extract the record ID of an artifact for the file. */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 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 |
@ <hr />
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
style_footer();
}
/*
** Attempt to lookup the specified checkin and file name into an rid.
*/
int artifact_from_ci_and_filename(
const char *zCI,
const char *zFilename
){
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
if( zCI==0 ) return 0;
if( zFilename==0 ) return 0;
cirid = name_to_rid(zCI);
pManifest = manifest_get(cirid, CFTYPE_MANIFEST, 0);
if( pManifest==0 ) return 0;
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
if( fossil_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;
}
/*
** 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_www(void){
const char *zFilename;
const char *zCI;
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
zCI = P("ci");
|
| ︙ | ︙ | |||
1671 1672 1673 1674 1675 1676 1677 |
int renderAsWiki = 0;
int renderAsHtml = 0;
int objType;
int asText;
const char *zUuid;
if( P("ci") && P("filename") ){
| | | 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
int renderAsWiki = 0;
int renderAsHtml = 0;
int objType;
int asText;
const char *zUuid;
if( P("ci") && P("filename") ){
rid = artifact_from_ci_and_filename_www();
}
if( rid==0 ){
rid = name_to_rid_www("name");
}
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
783 784 785 786 787 788 789 |
}else{
Th_SetResult(interp, "repository unavailable", -1);
return TH_ERROR;
}
}
/*
| | | | > > > | > | 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 808 809 810 811 812 813 814 815 816 817 818 819 820 |
}else{
Th_SetResult(interp, "repository unavailable", -1);
return TH_ERROR;
}
}
/*
** TH1 command: artifact ID ?FILENAME?
**
** Attempts to locate the specified artifact and return its contents. An
** error is generated if the repository is not open or the artifact cannot
** be found.
*/
static int artifactCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
if( argc!=2 && argc!=3 ){
return Th_WrongNumArgs(interp, "artifact ID ?FILENAME?");
}
if( Th_IsRepositoryOpen() ){
int rid;
Blob content;
if( argc==3 ){
rid = artifact_from_ci_and_filename(argv[1], argv[2]);
}else{
rid = name_to_rid(argv[1]);
}
if( rid!=0 && content_get(rid, &content) ){
Th_SetResult(interp, blob_str(&content), blob_size(&content));
blob_reset(&content);
return TH_OK;
}else{
Th_SetResult(interp, "artifact not found", -1);
return TH_ERROR;
|
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
633 634 635 636 637 638 639 |
fossil test-th-eval "setParameter test4 value4; setParameter test4 value5; getParameter test4 defValue4"
test th1-set-parameter-7 {$RESULT eq {value5}}
###############################################################################
fossil test-th-eval "artifact"
test th1-artifact-1 {$RESULT eq \
| | > > > > > > > > > > > > > > > > > > > > | 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 |
fossil test-th-eval "setParameter test4 value4; setParameter test4 value5; getParameter test4 defValue4"
test th1-set-parameter-7 {$RESULT eq {value5}}
###############################################################################
fossil test-th-eval "artifact"
test th1-artifact-1 {$RESULT eq \
{TH_ERROR: wrong # args: should be "artifact ID ?FILENAME?"}}
###############################################################################
fossil test-th-eval "artifact tip"
test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact tip"
test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
###############################################################################
fossil test-th-eval "artifact 0000000000"
test th1-artifact-4 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact 0000000000"
test th1-artifact-5 {$RESULT eq {TH_ERROR: artifact not found}}
###############################################################################
fossil test-th-eval "artifact tip test/th1.test"
test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact tip test/th1.test"
test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]}
###############################################################################
fossil test-th-eval "artifact 0000000000 test/th1.test"
test th1-artifact-8 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact 0000000000 test/th1.test"
test th1-artifact-9 {$RESULT eq {TH_ERROR: artifact not found}}
|