Fossil SCM

The argument to the "fossil ui" command is allowed to be a directory name instead of a repository filename. If a directory, repository associated with the checkout at that directory is used.

drh 2021-06-30 13:56 trunk merge
Commit 9ec744ed79ab5134dc7f215423ca3036226843bcc9703a1917bd59bea8b36454
1 file changed +32 -1
+32 -1
--- src/main.c
+++ src/main.c
@@ -2812,10 +2812,15 @@
28122812
** list of glob patterns given by --files and that have known suffixes
28132813
** such as ".txt" or ".html" or ".jpeg" and do not match the pattern
28142814
** "*.fossil*" will be served as static content. With the "ui" command,
28152815
** the REPOSITORY can only be a directory if the --notfound option is
28162816
** also present.
2817
+**
2818
+** If the REPOSITORY is a directory name which is the root of a
2819
+** checkout, it will chdir to that directory and, unless overridden by
2820
+** the --page option, select the current checkout version in the
2821
+** timeline by default.
28172822
**
28182823
** For the special case REPOSITORY name of "/", the list global configuration
28192824
** database is consulted for a list of all known repositories. The --repolist
28202825
** option is implied by this special case. See also the "fossil all ui"
28212826
** command.
@@ -2886,10 +2891,11 @@
28862891
const char *zAltBase; /* Argument to the --baseurl option */
28872892
const char *zFileGlob; /* Static content must match this */
28882893
char *zIpAddr = 0; /* Bind to this IP address */
28892894
int fCreate = 0; /* The --create flag */
28902895
const char *zInitPage = 0; /* Start on this page. --page option */
2896
+ int findServerArg = 2; /* argv index for find_server_repository() */
28912897
28922898
#if defined(_WIN32)
28932899
const char *zStopperFile; /* Name of file used to terminate server */
28942900
zStopperFile = find_option("stopper", 0, 1);
28952901
#endif
@@ -2942,16 +2948,41 @@
29422948
}
29432949
/* We should be done with options.. */
29442950
verify_all_options();
29452951
29462952
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2953
+ if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
2954
+ /* If REPOSITORY arg is the root of a checkout,
2955
+ ** chdir to that checkout so that the current version
2956
+ ** gets highlighted in the timeline by default. */
2957
+ const char * zArg = g.argv[2];
2958
+ char * zCkoutDb = mprintf("%//.fslckout", zArg);
2959
+ if(file_size(zCkoutDb, ExtFILE)<=0){
2960
+ fossil_free(zCkoutDb);
2961
+ zCkoutDb = mprintf("%//_FOSSIL_", zArg);
2962
+ if(file_size(zCkoutDb, ExtFILE)<=0){
2963
+ fossil_free(zCkoutDb);
2964
+ zCkoutDb = 0;
2965
+ }
2966
+ }
2967
+ if(zCkoutDb!=0){
2968
+ fossil_free(zCkoutDb);
2969
+ if(0!=file_chdir(zArg, 0)){
2970
+ fossil_fatal("Cannot chdir to %s", zArg);
2971
+ }
2972
+ findServerArg = 99;
2973
+ fCreate = 0;
2974
+ g.argv[2] = 0;
2975
+ --g.argc;
2976
+ }
2977
+ }
29472978
if( isUiCmd ){
29482979
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
29492980
g.useLocalauth = 1;
29502981
allowRepoList = 1;
29512982
}
2952
- find_server_repository(2, fCreate);
2983
+ find_server_repository(findServerArg, fCreate);
29532984
if( zInitPage==0 ){
29542985
if( isUiCmd && g.localOpen ){
29552986
zInitPage = "timeline?c=current";
29562987
}else{
29572988
zInitPage = "";
29582989
--- src/main.c
+++ src/main.c
@@ -2812,10 +2812,15 @@
2812 ** list of glob patterns given by --files and that have known suffixes
2813 ** such as ".txt" or ".html" or ".jpeg" and do not match the pattern
2814 ** "*.fossil*" will be served as static content. With the "ui" command,
2815 ** the REPOSITORY can only be a directory if the --notfound option is
2816 ** also present.
 
 
 
 
 
2817 **
2818 ** For the special case REPOSITORY name of "/", the list global configuration
2819 ** database is consulted for a list of all known repositories. The --repolist
2820 ** option is implied by this special case. See also the "fossil all ui"
2821 ** command.
@@ -2886,10 +2891,11 @@
2886 const char *zAltBase; /* Argument to the --baseurl option */
2887 const char *zFileGlob; /* Static content must match this */
2888 char *zIpAddr = 0; /* Bind to this IP address */
2889 int fCreate = 0; /* The --create flag */
2890 const char *zInitPage = 0; /* Start on this page. --page option */
 
2891
2892 #if defined(_WIN32)
2893 const char *zStopperFile; /* Name of file used to terminate server */
2894 zStopperFile = find_option("stopper", 0, 1);
2895 #endif
@@ -2942,16 +2948,41 @@
2942 }
2943 /* We should be done with options.. */
2944 verify_all_options();
2945
2946 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2947 if( isUiCmd ){
2948 flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
2949 g.useLocalauth = 1;
2950 allowRepoList = 1;
2951 }
2952 find_server_repository(2, fCreate);
2953 if( zInitPage==0 ){
2954 if( isUiCmd && g.localOpen ){
2955 zInitPage = "timeline?c=current";
2956 }else{
2957 zInitPage = "";
2958
--- src/main.c
+++ src/main.c
@@ -2812,10 +2812,15 @@
2812 ** list of glob patterns given by --files and that have known suffixes
2813 ** such as ".txt" or ".html" or ".jpeg" and do not match the pattern
2814 ** "*.fossil*" will be served as static content. With the "ui" command,
2815 ** the REPOSITORY can only be a directory if the --notfound option is
2816 ** also present.
2817 **
2818 ** If the REPOSITORY is a directory name which is the root of a
2819 ** checkout, it will chdir to that directory and, unless overridden by
2820 ** the --page option, select the current checkout version in the
2821 ** timeline by default.
2822 **
2823 ** For the special case REPOSITORY name of "/", the list global configuration
2824 ** database is consulted for a list of all known repositories. The --repolist
2825 ** option is implied by this special case. See also the "fossil all ui"
2826 ** command.
@@ -2886,10 +2891,11 @@
2891 const char *zAltBase; /* Argument to the --baseurl option */
2892 const char *zFileGlob; /* Static content must match this */
2893 char *zIpAddr = 0; /* Bind to this IP address */
2894 int fCreate = 0; /* The --create flag */
2895 const char *zInitPage = 0; /* Start on this page. --page option */
2896 int findServerArg = 2; /* argv index for find_server_repository() */
2897
2898 #if defined(_WIN32)
2899 const char *zStopperFile; /* Name of file used to terminate server */
2900 zStopperFile = find_option("stopper", 0, 1);
2901 #endif
@@ -2942,16 +2948,41 @@
2948 }
2949 /* We should be done with options.. */
2950 verify_all_options();
2951
2952 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2953 if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
2954 /* If REPOSITORY arg is the root of a checkout,
2955 ** chdir to that checkout so that the current version
2956 ** gets highlighted in the timeline by default. */
2957 const char * zArg = g.argv[2];
2958 char * zCkoutDb = mprintf("%//.fslckout", zArg);
2959 if(file_size(zCkoutDb, ExtFILE)<=0){
2960 fossil_free(zCkoutDb);
2961 zCkoutDb = mprintf("%//_FOSSIL_", zArg);
2962 if(file_size(zCkoutDb, ExtFILE)<=0){
2963 fossil_free(zCkoutDb);
2964 zCkoutDb = 0;
2965 }
2966 }
2967 if(zCkoutDb!=0){
2968 fossil_free(zCkoutDb);
2969 if(0!=file_chdir(zArg, 0)){
2970 fossil_fatal("Cannot chdir to %s", zArg);
2971 }
2972 findServerArg = 99;
2973 fCreate = 0;
2974 g.argv[2] = 0;
2975 --g.argc;
2976 }
2977 }
2978 if( isUiCmd ){
2979 flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
2980 g.useLocalauth = 1;
2981 allowRepoList = 1;
2982 }
2983 find_server_repository(findServerArg, fCreate);
2984 if( zInitPage==0 ){
2985 if( isUiCmd && g.localOpen ){
2986 zInitPage = "timeline?c=current";
2987 }else{
2988 zInitPage = "";
2989

Keyboard Shortcuts

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