Fossil SCM

Improvements to /ckout with the exbase query parameter.

drh 2024-12-15 00:06 ckout-exbase
Commit 16799dba71d98106dcb3b688aadda4089d1cef97c188676648cdb1db6d1c457f
1 file changed +42 -30
+42 -30
--- src/info.c
+++ src/info.c
@@ -770,40 +770,42 @@
770770
771771
zFile = db_column_text(&q,0);
772772
zLhs = mprintf("%s/%s", zExBase, zFile);
773773
zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
774774
if( file_size(zLhs, ExtFILE)<0 ){
775
- blob_zero(&lhs);
775
+ @ <div class='file-change-line'><span>
776
+ @ Missing from external baseline: %h(zFile)
777
+ @ </span></div>
776778
}else{
777779
blob_read_from_file(&lhs, zLhs, ExtFILE);
778
- }
779
- blob_read_from_file(&rhs, zRhs, ExtFILE);
780
- if( blob_size(&lhs)!=blob_size(&rhs)
781
- || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
782
- ){
783
- char *zFullFN;
784
- char *zHexFN;
785
- int nFullFN;
786
- zFullFN = file_canonical_name_dup(zLhs);
787
- nFullFN = (int)strlen(zFullFN);
788
- zHexFN = fossil_malloc( nFullFN*2 + 5 );
789
- zHexFN[0] = 'x';
790
- encode16((const u8*)zFullFN, (u8*)(zHexFN+1), nFullFN);
791
- zHexFN[1+nFullFN*2] = 0;
792
- fossil_free(zFullFN);
793
- pCfg->zLeftHash = zHexFN;
794
- @ <div class='file-change-line'><span>
795
- @ Changes to %h(zFile)
796
- @ </span></div>
797
- if( pCfg ){
798
- text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
799
- }
800
- pCfg->zLeftHash = 0;
801
- fossil_free(zHexFN);
802
- }
803
- blob_reset(&lhs);
804
- blob_reset(&rhs);
780
+ blob_read_from_file(&rhs, zRhs, ExtFILE);
781
+ if( blob_size(&lhs)!=blob_size(&rhs)
782
+ || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
783
+ ){
784
+ @ <div class='file-change-line'><span>
785
+ @ Changes to %h(zFile)
786
+ @ </span></div>
787
+ if( pCfg ){
788
+ char *zFullFN;
789
+ char *zHexFN;
790
+ int nFullFN;
791
+ zFullFN = file_canonical_name_dup(zLhs);
792
+ nFullFN = (int)strlen(zFullFN);
793
+ zHexFN = fossil_malloc( nFullFN*2 + 5 );
794
+ zHexFN[0] = 'x';
795
+ encode16((const u8*)zFullFN, (u8*)(zHexFN+1), nFullFN);
796
+ zHexFN[1+nFullFN*2] = 0;
797
+ fossil_free(zFullFN);
798
+ pCfg->zLeftHash = zHexFN;
799
+ text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
800
+ pCfg->zLeftHash = 0;
801
+ fossil_free(zHexFN);
802
+ }
803
+ }
804
+ blob_reset(&lhs);
805
+ blob_reset(&rhs);
806
+ }
805807
fossil_free(zLhs);
806808
fossil_free(zRhs);
807809
}
808810
db_finalize(&q);
809811
append_diff_javascript(diffType);
@@ -817,10 +819,11 @@
817819
** started using "fossil ui" or similar) from with on open check-out.
818820
*/
819821
void ckout_page(void){
820822
int vid;
821823
const char *zHome; /* Home directory */
824
+ int nHome;
822825
const char *zExBase;
823826
char *zHostname;
824827
char *zCwd;
825828
826829
if( !db_open_local(0) || !cgi_is_loopback(g.zIpAddr) ){
@@ -835,14 +838,16 @@
835838
style_set_current_feature("vinfo");
836839
zHostname = fossil_hostname();
837840
zCwd = file_getcwd(0,0);
838841
zHome = fossil_getenv("HOME");
839842
if( zHome ){
840
- int nHome = (int)strlen(zHome);
843
+ nHome = (int)strlen(zHome);
841844
if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){
842845
zCwd = mprintf("~%s", zCwd+nHome);
843846
}
847
+ }else{
848
+ nHome = 0;
844849
}
845850
if( zHostname ){
846851
style_header("Checkout Status: %h on %h", zCwd, zHostname);
847852
}else{
848853
style_header("Checkout Status: %h", zCwd);
@@ -849,11 +854,18 @@
849854
}
850855
render_checkin_context(vid, 0, 0, 0);
851856
@ <hr>
852857
zExBase = P("exbase");
853858
if( zExBase && zExBase[0] ){
854
- ckout_external_base_diff(vid, zExBase);
859
+ char *zCBase = file_canonical_name_dup(zExBase);
860
+ if( nHome && strncmp(zCBase, zHome, nHome)==0 && zCBase[nHome]=='/' ){
861
+ @ <p>Using external baseline: ~%h(zCBase+nHome)</p>
862
+ }else{
863
+ @ <p>Using external baseline: %h(zCBase)</p>
864
+ }
865
+ ckout_external_base_diff(vid, zCBase);
866
+ fossil_free(zCBase);
855867
}else{
856868
ckout_normal_diff(vid);
857869
}
858870
style_finish_page();
859871
}
860872
--- src/info.c
+++ src/info.c
@@ -770,40 +770,42 @@
770
771 zFile = db_column_text(&q,0);
772 zLhs = mprintf("%s/%s", zExBase, zFile);
773 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
774 if( file_size(zLhs, ExtFILE)<0 ){
775 blob_zero(&lhs);
 
 
776 }else{
777 blob_read_from_file(&lhs, zLhs, ExtFILE);
778 }
779 blob_read_from_file(&rhs, zRhs, ExtFILE);
780 if( blob_size(&lhs)!=blob_size(&rhs)
781 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
782 ){
783 char *zFullFN;
784 char *zHexFN;
785 int nFullFN;
786 zFullFN = file_canonical_name_dup(zLhs);
787 nFullFN = (int)strlen(zFullFN);
788 zHexFN = fossil_malloc( nFullFN*2 + 5 );
789 zHexFN[0] = 'x';
790 encode16((const u8*)zFullFN, (u8*)(zHexFN+1), nFullFN);
791 zHexFN[1+nFullFN*2] = 0;
792 fossil_free(zFullFN);
793 pCfg->zLeftHash = zHexFN;
794 @ <div class='file-change-line'><span>
795 @ Changes to %h(zFile)
796 @ </span></div>
797 if( pCfg ){
798 text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
799 }
800 pCfg->zLeftHash = 0;
801 fossil_free(zHexFN);
802 }
803 blob_reset(&lhs);
804 blob_reset(&rhs);
805 fossil_free(zLhs);
806 fossil_free(zRhs);
807 }
808 db_finalize(&q);
809 append_diff_javascript(diffType);
@@ -817,10 +819,11 @@
817 ** started using "fossil ui" or similar) from with on open check-out.
818 */
819 void ckout_page(void){
820 int vid;
821 const char *zHome; /* Home directory */
 
822 const char *zExBase;
823 char *zHostname;
824 char *zCwd;
825
826 if( !db_open_local(0) || !cgi_is_loopback(g.zIpAddr) ){
@@ -835,14 +838,16 @@
835 style_set_current_feature("vinfo");
836 zHostname = fossil_hostname();
837 zCwd = file_getcwd(0,0);
838 zHome = fossil_getenv("HOME");
839 if( zHome ){
840 int nHome = (int)strlen(zHome);
841 if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){
842 zCwd = mprintf("~%s", zCwd+nHome);
843 }
 
 
844 }
845 if( zHostname ){
846 style_header("Checkout Status: %h on %h", zCwd, zHostname);
847 }else{
848 style_header("Checkout Status: %h", zCwd);
@@ -849,11 +854,18 @@
849 }
850 render_checkin_context(vid, 0, 0, 0);
851 @ <hr>
852 zExBase = P("exbase");
853 if( zExBase && zExBase[0] ){
854 ckout_external_base_diff(vid, zExBase);
 
 
 
 
 
 
 
855 }else{
856 ckout_normal_diff(vid);
857 }
858 style_finish_page();
859 }
860
--- src/info.c
+++ src/info.c
@@ -770,40 +770,42 @@
770
771 zFile = db_column_text(&q,0);
772 zLhs = mprintf("%s/%s", zExBase, zFile);
773 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
774 if( file_size(zLhs, ExtFILE)<0 ){
775 @ <div class='file-change-line'><span>
776 @ Missing from external baseline: %h(zFile)
777 @ </span></div>
778 }else{
779 blob_read_from_file(&lhs, zLhs, ExtFILE);
780 blob_read_from_file(&rhs, zRhs, ExtFILE);
781 if( blob_size(&lhs)!=blob_size(&rhs)
782 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
783 ){
784 @ <div class='file-change-line'><span>
785 @ Changes to %h(zFile)
786 @ </span></div>
787 if( pCfg ){
788 char *zFullFN;
789 char *zHexFN;
790 int nFullFN;
791 zFullFN = file_canonical_name_dup(zLhs);
792 nFullFN = (int)strlen(zFullFN);
793 zHexFN = fossil_malloc( nFullFN*2 + 5 );
794 zHexFN[0] = 'x';
795 encode16((const u8*)zFullFN, (u8*)(zHexFN+1), nFullFN);
796 zHexFN[1+nFullFN*2] = 0;
797 fossil_free(zFullFN);
798 pCfg->zLeftHash = zHexFN;
799 text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
800 pCfg->zLeftHash = 0;
801 fossil_free(zHexFN);
802 }
803 }
804 blob_reset(&lhs);
805 blob_reset(&rhs);
806 }
807 fossil_free(zLhs);
808 fossil_free(zRhs);
809 }
810 db_finalize(&q);
811 append_diff_javascript(diffType);
@@ -817,10 +819,11 @@
819 ** started using "fossil ui" or similar) from with on open check-out.
820 */
821 void ckout_page(void){
822 int vid;
823 const char *zHome; /* Home directory */
824 int nHome;
825 const char *zExBase;
826 char *zHostname;
827 char *zCwd;
828
829 if( !db_open_local(0) || !cgi_is_loopback(g.zIpAddr) ){
@@ -835,14 +838,16 @@
838 style_set_current_feature("vinfo");
839 zHostname = fossil_hostname();
840 zCwd = file_getcwd(0,0);
841 zHome = fossil_getenv("HOME");
842 if( zHome ){
843 nHome = (int)strlen(zHome);
844 if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){
845 zCwd = mprintf("~%s", zCwd+nHome);
846 }
847 }else{
848 nHome = 0;
849 }
850 if( zHostname ){
851 style_header("Checkout Status: %h on %h", zCwd, zHostname);
852 }else{
853 style_header("Checkout Status: %h", zCwd);
@@ -849,11 +854,18 @@
854 }
855 render_checkin_context(vid, 0, 0, 0);
856 @ <hr>
857 zExBase = P("exbase");
858 if( zExBase && zExBase[0] ){
859 char *zCBase = file_canonical_name_dup(zExBase);
860 if( nHome && strncmp(zCBase, zHome, nHome)==0 && zCBase[nHome]=='/' ){
861 @ <p>Using external baseline: ~%h(zCBase+nHome)</p>
862 }else{
863 @ <p>Using external baseline: %h(zCBase)</p>
864 }
865 ckout_external_base_diff(vid, zCBase);
866 fossil_free(zCBase);
867 }else{
868 ckout_normal_diff(vid);
869 }
870 style_finish_page();
871 }
872

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button