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.
Commit
9ec744ed79ab5134dc7f215423ca3036226843bcc9703a1917bd59bea8b36454
Parent
4f83d06275804a8…
1 file changed
+32
-1
+32
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2812,10 +2812,15 @@ | ||
| 2812 | 2812 | ** list of glob patterns given by --files and that have known suffixes |
| 2813 | 2813 | ** such as ".txt" or ".html" or ".jpeg" and do not match the pattern |
| 2814 | 2814 | ** "*.fossil*" will be served as static content. With the "ui" command, |
| 2815 | 2815 | ** the REPOSITORY can only be a directory if the --notfound option is |
| 2816 | 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. | |
| 2817 | 2822 | ** |
| 2818 | 2823 | ** For the special case REPOSITORY name of "/", the list global configuration |
| 2819 | 2824 | ** database is consulted for a list of all known repositories. The --repolist |
| 2820 | 2825 | ** option is implied by this special case. See also the "fossil all ui" |
| 2821 | 2826 | ** command. |
| @@ -2886,10 +2891,11 @@ | ||
| 2886 | 2891 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 2887 | 2892 | const char *zFileGlob; /* Static content must match this */ |
| 2888 | 2893 | char *zIpAddr = 0; /* Bind to this IP address */ |
| 2889 | 2894 | int fCreate = 0; /* The --create flag */ |
| 2890 | 2895 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 2896 | + int findServerArg = 2; /* argv index for find_server_repository() */ | |
| 2891 | 2897 | |
| 2892 | 2898 | #if defined(_WIN32) |
| 2893 | 2899 | const char *zStopperFile; /* Name of file used to terminate server */ |
| 2894 | 2900 | zStopperFile = find_option("stopper", 0, 1); |
| 2895 | 2901 | #endif |
| @@ -2942,16 +2948,41 @@ | ||
| 2942 | 2948 | } |
| 2943 | 2949 | /* We should be done with options.. */ |
| 2944 | 2950 | verify_all_options(); |
| 2945 | 2951 | |
| 2946 | 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 | + } | |
| 2947 | 2978 | if( isUiCmd ){ |
| 2948 | 2979 | flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST; |
| 2949 | 2980 | g.useLocalauth = 1; |
| 2950 | 2981 | allowRepoList = 1; |
| 2951 | 2982 | } |
| 2952 | - find_server_repository(2, fCreate); | |
| 2983 | + find_server_repository(findServerArg, fCreate); | |
| 2953 | 2984 | if( zInitPage==0 ){ |
| 2954 | 2985 | if( isUiCmd && g.localOpen ){ |
| 2955 | 2986 | zInitPage = "timeline?c=current"; |
| 2956 | 2987 | }else{ |
| 2957 | 2988 | zInitPage = ""; |
| 2958 | 2989 |
| --- 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 |