Fossil SCM
Add the /ckout page.
Commit
d35d201840d9bef23ec4b9984d20728edad8f354ced759a5fd6183500fc55871
Parent
de6f88a6f00fa85…
1 file changed
+107
+107
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -602,10 +602,117 @@ | ||
| 602 | 602 | www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL, |
| 603 | 603 | 0, 0, 0, rid, 0, 0); |
| 604 | 604 | db_finalize(&q); |
| 605 | 605 | style_finish_page(); |
| 606 | 606 | } |
| 607 | + | |
| 608 | +/* | |
| 609 | +** WEBPAGE: ckout | |
| 610 | +** | |
| 611 | +** Show information about the current checkout. This page only functions | |
| 612 | +** if the web server is run on a loopback interface (in other words, was | |
| 613 | +** started using "fossil ui" or similar) from with on open check-out. | |
| 614 | +*/ | |
| 615 | +void ckout_page(void){ | |
| 616 | + const char *zName = P("name"); | |
| 617 | + int vid; | |
| 618 | + char *zHostname; | |
| 619 | + char *zCwd; | |
| 620 | + int diffType; /* 0: no diff, 1: unified, 2: side-by-side */ | |
| 621 | + DiffConfig DCfg,*pCfg; /* Diff details */ | |
| 622 | + Stmt q; | |
| 623 | + | |
| 624 | + if( zName || !db_open_local(0) || !cgi_is_loopback(g.zIpAddr) ){ | |
| 625 | + webpage_notfound_error(0 /*works-like:""*/); | |
| 626 | + return; | |
| 627 | + } | |
| 628 | + diffType = preferred_diff_type(); | |
| 629 | + pCfg = construct_diff_flags(diffType, &DCfg); | |
| 630 | + vid = db_lget_int("checkout", 0); | |
| 631 | + vfile_check_signature(vid, CKSIG_ENOTFILE); | |
| 632 | + style_set_current_feature("vinfo"); | |
| 633 | + zHostname = fossil_hostname(); | |
| 634 | + zCwd = file_getcwd(0,0); | |
| 635 | + if( zHostname ){ | |
| 636 | + style_header("Checkout at %s:%s", zHostname, zCwd); | |
| 637 | + }else{ | |
| 638 | + style_header("Checkout at %s", zCwd); | |
| 639 | + } | |
| 640 | + render_checkin_context(vid, 0, 0, 0); | |
| 641 | + db_prepare(&q, | |
| 642 | + /* 0 1 2 3 4 5 6 */ | |
| 643 | + "SELECT pathname, deleted, chnged , rid==0, rid, islink, uuid" | |
| 644 | + " FROM vfile LEFT JOIN blob USING(rid)" | |
| 645 | + " WHERE vid=%d" | |
| 646 | + " AND (deleted OR chnged OR rid==0)" | |
| 647 | + " ORDER BY pathname /*scan*/", | |
| 648 | + vid | |
| 649 | + ); | |
| 650 | + if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ | |
| 651 | + pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; | |
| 652 | + }else{ | |
| 653 | + pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; | |
| 654 | + } | |
| 655 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 656 | + const char *zTreename = db_column_text(&q,0); | |
| 657 | + int isDeleted = db_column_int(&q, 1); | |
| 658 | + int isChnged = db_column_int(&q,2); | |
| 659 | + int isNew = db_column_int(&q,3); | |
| 660 | + int srcid = db_column_int(&q, 4); | |
| 661 | + int isLink = db_column_int(&q, 5); | |
| 662 | + const char *zUuid = db_column_text(&q, 6); | |
| 663 | + int showDiff = 1; | |
| 664 | + | |
| 665 | + pCfg->diffFlags &= (~DIFF_FILE_MASK); | |
| 666 | + if( isDeleted ){ | |
| 667 | + @ <p>DELETED %h(zTreename)</p> | |
| 668 | + pCfg->diffFlags |= DIFF_FILE_DELETED; | |
| 669 | + showDiff = 0; | |
| 670 | + }else if( file_access(zTreename, F_OK) ){ | |
| 671 | + @ <p>MISSING %h(zTreename)</p> | |
| 672 | + showDiff = 0; | |
| 673 | + }else if( isNew ){ | |
| 674 | + @ <p>ADDED %h(zTreename)</p> | |
| 675 | + pCfg->diffFlags |= DIFF_FILE_ADDED; | |
| 676 | + srcid = 0; | |
| 677 | + showDiff = 0; | |
| 678 | + }else if( isChnged==3 ){ | |
| 679 | + @ <p>ADDED_BY_MERGE %h(zTreename)</p> | |
| 680 | + pCfg->diffFlags |= DIFF_FILE_ADDED; | |
| 681 | + srcid = 0; | |
| 682 | + showDiff = 0; | |
| 683 | + }else if( isChnged==5 ){ | |
| 684 | + @ <p>ADDED_BY_INTEGRATE %h(zTreename)</p> | |
| 685 | + pCfg->diffFlags |= DIFF_FILE_ADDED; | |
| 686 | + srcid = 0; | |
| 687 | + showDiff = 0; | |
| 688 | + }else{ | |
| 689 | + @ <p>CHANGED %h(zTreename)</p> | |
| 690 | + } | |
| 691 | + if( showDiff ){ | |
| 692 | + Blob old, new; | |
| 693 | + if( !isLink != !file_islink(zTreename) ){ | |
| 694 | + @ %s(DIFF_CANNOT_COMPUTE_SYMLINK) | |
| 695 | + continue; | |
| 696 | + } | |
| 697 | + if( srcid>0 ){ | |
| 698 | + content_get(srcid, &old); | |
| 699 | + pCfg->zLeftHash = zUuid; | |
| 700 | + }else{ | |
| 701 | + blob_zero(&old); | |
| 702 | + pCfg->zLeftHash = 0; | |
| 703 | + } | |
| 704 | + blob_read_from_file(&new, zTreename, ExtFILE); | |
| 705 | + text_diff(&old, &new, cgi_output_blob(), pCfg); | |
| 706 | + blob_reset(&old); | |
| 707 | + blob_reset(&new); | |
| 708 | + } | |
| 709 | + } | |
| 710 | + db_finalize(&q); | |
| 711 | + append_diff_javascript(diffType); | |
| 712 | + style_finish_page(); | |
| 713 | +} | |
| 607 | 714 | |
| 608 | 715 | /* |
| 609 | 716 | ** WEBPAGE: vinfo |
| 610 | 717 | ** WEBPAGE: ci |
| 611 | 718 | ** URL: /ci/ARTIFACTID |
| 612 | 719 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -602,10 +602,117 @@ | |
| 602 | www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL, |
| 603 | 0, 0, 0, rid, 0, 0); |
| 604 | db_finalize(&q); |
| 605 | style_finish_page(); |
| 606 | } |
| 607 | |
| 608 | /* |
| 609 | ** WEBPAGE: vinfo |
| 610 | ** WEBPAGE: ci |
| 611 | ** URL: /ci/ARTIFACTID |
| 612 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -602,10 +602,117 @@ | |
| 602 | www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL, |
| 603 | 0, 0, 0, rid, 0, 0); |
| 604 | db_finalize(&q); |
| 605 | style_finish_page(); |
| 606 | } |
| 607 | |
| 608 | /* |
| 609 | ** WEBPAGE: ckout |
| 610 | ** |
| 611 | ** Show information about the current checkout. This page only functions |
| 612 | ** if the web server is run on a loopback interface (in other words, was |
| 613 | ** started using "fossil ui" or similar) from with on open check-out. |
| 614 | */ |
| 615 | void ckout_page(void){ |
| 616 | const char *zName = P("name"); |
| 617 | int vid; |
| 618 | char *zHostname; |
| 619 | char *zCwd; |
| 620 | int diffType; /* 0: no diff, 1: unified, 2: side-by-side */ |
| 621 | DiffConfig DCfg,*pCfg; /* Diff details */ |
| 622 | Stmt q; |
| 623 | |
| 624 | if( zName || !db_open_local(0) || !cgi_is_loopback(g.zIpAddr) ){ |
| 625 | webpage_notfound_error(0 /*works-like:""*/); |
| 626 | return; |
| 627 | } |
| 628 | diffType = preferred_diff_type(); |
| 629 | pCfg = construct_diff_flags(diffType, &DCfg); |
| 630 | vid = db_lget_int("checkout", 0); |
| 631 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 632 | style_set_current_feature("vinfo"); |
| 633 | zHostname = fossil_hostname(); |
| 634 | zCwd = file_getcwd(0,0); |
| 635 | if( zHostname ){ |
| 636 | style_header("Checkout at %s:%s", zHostname, zCwd); |
| 637 | }else{ |
| 638 | style_header("Checkout at %s", zCwd); |
| 639 | } |
| 640 | render_checkin_context(vid, 0, 0, 0); |
| 641 | db_prepare(&q, |
| 642 | /* 0 1 2 3 4 5 6 */ |
| 643 | "SELECT pathname, deleted, chnged , rid==0, rid, islink, uuid" |
| 644 | " FROM vfile LEFT JOIN blob USING(rid)" |
| 645 | " WHERE vid=%d" |
| 646 | " AND (deleted OR chnged OR rid==0)" |
| 647 | " ORDER BY pathname /*scan*/", |
| 648 | vid |
| 649 | ); |
| 650 | if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 651 | pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
| 652 | }else{ |
| 653 | pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
| 654 | } |
| 655 | while( db_step(&q)==SQLITE_ROW ){ |
| 656 | const char *zTreename = db_column_text(&q,0); |
| 657 | int isDeleted = db_column_int(&q, 1); |
| 658 | int isChnged = db_column_int(&q,2); |
| 659 | int isNew = db_column_int(&q,3); |
| 660 | int srcid = db_column_int(&q, 4); |
| 661 | int isLink = db_column_int(&q, 5); |
| 662 | const char *zUuid = db_column_text(&q, 6); |
| 663 | int showDiff = 1; |
| 664 | |
| 665 | pCfg->diffFlags &= (~DIFF_FILE_MASK); |
| 666 | if( isDeleted ){ |
| 667 | @ <p>DELETED %h(zTreename)</p> |
| 668 | pCfg->diffFlags |= DIFF_FILE_DELETED; |
| 669 | showDiff = 0; |
| 670 | }else if( file_access(zTreename, F_OK) ){ |
| 671 | @ <p>MISSING %h(zTreename)</p> |
| 672 | showDiff = 0; |
| 673 | }else if( isNew ){ |
| 674 | @ <p>ADDED %h(zTreename)</p> |
| 675 | pCfg->diffFlags |= DIFF_FILE_ADDED; |
| 676 | srcid = 0; |
| 677 | showDiff = 0; |
| 678 | }else if( isChnged==3 ){ |
| 679 | @ <p>ADDED_BY_MERGE %h(zTreename)</p> |
| 680 | pCfg->diffFlags |= DIFF_FILE_ADDED; |
| 681 | srcid = 0; |
| 682 | showDiff = 0; |
| 683 | }else if( isChnged==5 ){ |
| 684 | @ <p>ADDED_BY_INTEGRATE %h(zTreename)</p> |
| 685 | pCfg->diffFlags |= DIFF_FILE_ADDED; |
| 686 | srcid = 0; |
| 687 | showDiff = 0; |
| 688 | }else{ |
| 689 | @ <p>CHANGED %h(zTreename)</p> |
| 690 | } |
| 691 | if( showDiff ){ |
| 692 | Blob old, new; |
| 693 | if( !isLink != !file_islink(zTreename) ){ |
| 694 | @ %s(DIFF_CANNOT_COMPUTE_SYMLINK) |
| 695 | continue; |
| 696 | } |
| 697 | if( srcid>0 ){ |
| 698 | content_get(srcid, &old); |
| 699 | pCfg->zLeftHash = zUuid; |
| 700 | }else{ |
| 701 | blob_zero(&old); |
| 702 | pCfg->zLeftHash = 0; |
| 703 | } |
| 704 | blob_read_from_file(&new, zTreename, ExtFILE); |
| 705 | text_diff(&old, &new, cgi_output_blob(), pCfg); |
| 706 | blob_reset(&old); |
| 707 | blob_reset(&new); |
| 708 | } |
| 709 | } |
| 710 | db_finalize(&q); |
| 711 | append_diff_javascript(diffType); |
| 712 | style_finish_page(); |
| 713 | } |
| 714 | |
| 715 | /* |
| 716 | ** WEBPAGE: vinfo |
| 717 | ** WEBPAGE: ci |
| 718 | ** URL: /ci/ARTIFACTID |
| 719 |