Fossil SCM
Minor refactoring of [41f0838cbeac] in prep for expanding the tag command to handle non-checkin artifacts.
Commit
b051ada90d4a6694c2d76cade4b691bac5fa96ff48861ecd6d7e6faa4c707498
Parent
24ccc48160bdc45…
2 files changed
+1
-1
+39
-15
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -509,11 +509,11 @@ | ||
| 509 | 509 | style_finish_page(); |
| 510 | 510 | return; |
| 511 | 511 | } |
| 512 | 512 | zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 513 | 513 | style_header("Tags and Properties"); |
| 514 | - zType = whatis_rid_type(rid); | |
| 514 | + zType = whatis_rid_type_label(rid); | |
| 515 | 515 | if(!zType) zType = "Artifact"; |
| 516 | 516 | @ <h1>Tags and Properties for %s(zType) \ |
| 517 | 517 | @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> |
| 518 | 518 | db_prepare(&q, |
| 519 | 519 | "SELECT tag.tagid, tagname, " |
| 520 | 520 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -509,11 +509,11 @@ | |
| 509 | style_finish_page(); |
| 510 | return; |
| 511 | } |
| 512 | zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 513 | style_header("Tags and Properties"); |
| 514 | zType = whatis_rid_type(rid); |
| 515 | if(!zType) zType = "Artifact"; |
| 516 | @ <h1>Tags and Properties for %s(zType) \ |
| 517 | @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> |
| 518 | db_prepare(&q, |
| 519 | "SELECT tag.tagid, tagname, " |
| 520 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -509,11 +509,11 @@ | |
| 509 | style_finish_page(); |
| 510 | return; |
| 511 | } |
| 512 | zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 513 | style_header("Tags and Properties"); |
| 514 | zType = whatis_rid_type_label(rid); |
| 515 | if(!zType) zType = "Artifact"; |
| 516 | @ <h1>Tags and Properties for %s(zType) \ |
| 517 | @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> |
| 518 | db_prepare(&q, |
| 519 | "SELECT tag.tagid, tagname, " |
| 520 |
+39
-15
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -740,36 +740,60 @@ | ||
| 740 | 740 | return rid; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /* |
| 744 | 744 | ** Given an RID of a structural artifact, which is assumed to be |
| 745 | -** valid, this function returns a brief string (in static memory) | |
| 746 | -** describing the record type. Returns NULL if rid does not refer to | |
| 747 | -** an artifact record (as determined by reading the event table). The | |
| 748 | -** returned string is intended to be used in headers which can refer | |
| 749 | -** to different artifact types. It is not "definitive," in that it | |
| 750 | -** does not distinguish between closely-related types like wiki | |
| 751 | -** creation, edit, and removal. | |
| 745 | +** valid, this function returns one of the CFTYPE_xxx values | |
| 746 | +** describing the record type, or 0 if the RID does not refer to an | |
| 747 | +** artifact record (as determined by reading the event table). | |
| 748 | +** | |
| 749 | +** Note that this function neve returns CFTYPE_ATTACHMENT or | |
| 750 | +** CFTYPE_CLUSTER because those are not used in the event table. Thus | |
| 751 | +** it cannot be used to distinguish those artifact types from | |
| 752 | +** non-artifact file content. | |
| 752 | 753 | */ |
| 753 | -char const * whatis_rid_type(int rid){ | |
| 754 | +int whatis_rid_type(int rid){ | |
| 754 | 755 | Stmt q = empty_Stmt; |
| 755 | - char const * zType = 0; | |
| 756 | + int type = 0; | |
| 756 | 757 | /* Check for entries on the timeline that reference this object */ |
| 757 | 758 | db_prepare(&q, |
| 758 | 759 | "SELECT type FROM event WHERE objid=%d", rid); |
| 759 | 760 | if( db_step(&q)==SQLITE_ROW ){ |
| 760 | 761 | switch( db_column_text(&q,0)[0] ){ |
| 761 | - case 'c': zType = "Check-in"; break; | |
| 762 | - case 'w': zType = "Wiki-edit"; break; | |
| 763 | - case 'e': zType = "Technote"; break; | |
| 764 | - case 'f': zType = "Forum-post"; break; | |
| 765 | - case 't': zType = "Ticket-change"; break; | |
| 766 | - case 'g': zType = "Tag-change"; break; | |
| 762 | + case 'c': type = CFTYPE_MANIFEST; break; | |
| 763 | + case 'w': type = CFTYPE_WIKI; break; | |
| 764 | + case 'e': type = CFTYPE_EVENT; break; | |
| 765 | + case 'f': type = CFTYPE_FORUM; break; | |
| 766 | + case 't': type = CFTYPE_TICKET; break; | |
| 767 | + case 'g': type = CFTYPE_CONTROL; break; | |
| 767 | 768 | default: break; |
| 768 | 769 | } |
| 769 | 770 | } |
| 770 | 771 | db_finalize(&q); |
| 772 | + return type; | |
| 773 | +} | |
| 774 | + | |
| 775 | +/* | |
| 776 | +** A proxy for whatis_rid_type() which returns a brief string (in | |
| 777 | +** static memory) describing the record type. Returns NULL if rid does | |
| 778 | +** not refer to an artifact record (as determined by reading the event | |
| 779 | +** table). The returned string is intended to be used in headers which | |
| 780 | +** can refer to different artifact types. It is not "definitive," in | |
| 781 | +** that it does not distinguish between closely-related types like | |
| 782 | +** wiki creation, edit, and removal. | |
| 783 | +*/ | |
| 784 | +char const * whatis_rid_type_label(int rid){ | |
| 785 | + char const * zType = 0; | |
| 786 | + switch( whatis_rid_type(rid) ){ | |
| 787 | + case CFTYPE_MANIFEST: zType = "Check-in"; break; | |
| 788 | + case CFTYPE_WIKI: zType = "Wiki-edit"; break; | |
| 789 | + case CFTYPE_EVENT: zType = "Technote"; break; | |
| 790 | + case CFTYPE_FORUM: zType = "Forum-post"; break; | |
| 791 | + case CFTYPE_TICKET: zType = "Ticket-change"; break; | |
| 792 | + case CFTYPE_CONTROL: zType = "Tag-change"; break; | |
| 793 | + default: break; | |
| 794 | + } | |
| 771 | 795 | return zType; |
| 772 | 796 | } |
| 773 | 797 | |
| 774 | 798 | /* |
| 775 | 799 | ** Generate a description of artifact "rid" |
| 776 | 800 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -740,36 +740,60 @@ | |
| 740 | return rid; |
| 741 | } |
| 742 | |
| 743 | /* |
| 744 | ** Given an RID of a structural artifact, which is assumed to be |
| 745 | ** valid, this function returns a brief string (in static memory) |
| 746 | ** describing the record type. Returns NULL if rid does not refer to |
| 747 | ** an artifact record (as determined by reading the event table). The |
| 748 | ** returned string is intended to be used in headers which can refer |
| 749 | ** to different artifact types. It is not "definitive," in that it |
| 750 | ** does not distinguish between closely-related types like wiki |
| 751 | ** creation, edit, and removal. |
| 752 | */ |
| 753 | char const * whatis_rid_type(int rid){ |
| 754 | Stmt q = empty_Stmt; |
| 755 | char const * zType = 0; |
| 756 | /* Check for entries on the timeline that reference this object */ |
| 757 | db_prepare(&q, |
| 758 | "SELECT type FROM event WHERE objid=%d", rid); |
| 759 | if( db_step(&q)==SQLITE_ROW ){ |
| 760 | switch( db_column_text(&q,0)[0] ){ |
| 761 | case 'c': zType = "Check-in"; break; |
| 762 | case 'w': zType = "Wiki-edit"; break; |
| 763 | case 'e': zType = "Technote"; break; |
| 764 | case 'f': zType = "Forum-post"; break; |
| 765 | case 't': zType = "Ticket-change"; break; |
| 766 | case 'g': zType = "Tag-change"; break; |
| 767 | default: break; |
| 768 | } |
| 769 | } |
| 770 | db_finalize(&q); |
| 771 | return zType; |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | ** Generate a description of artifact "rid" |
| 776 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -740,36 +740,60 @@ | |
| 740 | return rid; |
| 741 | } |
| 742 | |
| 743 | /* |
| 744 | ** Given an RID of a structural artifact, which is assumed to be |
| 745 | ** valid, this function returns one of the CFTYPE_xxx values |
| 746 | ** describing the record type, or 0 if the RID does not refer to an |
| 747 | ** artifact record (as determined by reading the event table). |
| 748 | ** |
| 749 | ** Note that this function neve returns CFTYPE_ATTACHMENT or |
| 750 | ** CFTYPE_CLUSTER because those are not used in the event table. Thus |
| 751 | ** it cannot be used to distinguish those artifact types from |
| 752 | ** non-artifact file content. |
| 753 | */ |
| 754 | int whatis_rid_type(int rid){ |
| 755 | Stmt q = empty_Stmt; |
| 756 | int type = 0; |
| 757 | /* Check for entries on the timeline that reference this object */ |
| 758 | db_prepare(&q, |
| 759 | "SELECT type FROM event WHERE objid=%d", rid); |
| 760 | if( db_step(&q)==SQLITE_ROW ){ |
| 761 | switch( db_column_text(&q,0)[0] ){ |
| 762 | case 'c': type = CFTYPE_MANIFEST; break; |
| 763 | case 'w': type = CFTYPE_WIKI; break; |
| 764 | case 'e': type = CFTYPE_EVENT; break; |
| 765 | case 'f': type = CFTYPE_FORUM; break; |
| 766 | case 't': type = CFTYPE_TICKET; break; |
| 767 | case 'g': type = CFTYPE_CONTROL; break; |
| 768 | default: break; |
| 769 | } |
| 770 | } |
| 771 | db_finalize(&q); |
| 772 | return type; |
| 773 | } |
| 774 | |
| 775 | /* |
| 776 | ** A proxy for whatis_rid_type() which returns a brief string (in |
| 777 | ** static memory) describing the record type. Returns NULL if rid does |
| 778 | ** not refer to an artifact record (as determined by reading the event |
| 779 | ** table). The returned string is intended to be used in headers which |
| 780 | ** can refer to different artifact types. It is not "definitive," in |
| 781 | ** that it does not distinguish between closely-related types like |
| 782 | ** wiki creation, edit, and removal. |
| 783 | */ |
| 784 | char const * whatis_rid_type_label(int rid){ |
| 785 | char const * zType = 0; |
| 786 | switch( whatis_rid_type(rid) ){ |
| 787 | case CFTYPE_MANIFEST: zType = "Check-in"; break; |
| 788 | case CFTYPE_WIKI: zType = "Wiki-edit"; break; |
| 789 | case CFTYPE_EVENT: zType = "Technote"; break; |
| 790 | case CFTYPE_FORUM: zType = "Forum-post"; break; |
| 791 | case CFTYPE_TICKET: zType = "Ticket-change"; break; |
| 792 | case CFTYPE_CONTROL: zType = "Tag-change"; break; |
| 793 | default: break; |
| 794 | } |
| 795 | return zType; |
| 796 | } |
| 797 | |
| 798 | /* |
| 799 | ** Generate a description of artifact "rid" |
| 800 |