Fossil

Check-in [bf66d61582]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Per /chat #6763: if the ui command is passed the root dir of a checkout, chdir to that checkout to show the current checkout in the timeline by default. There may be a better/simpler way to implement this, thus this impl is in a branch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ui-checkout-chdir
Files: files | file ages | folders
SHA3-256: bf66d61582e040827c853bac2b62b5fbe8fb97dc9d107e95aa1f32339166154e
User & Date: stephan 2021-06-29 05:44:10.483
References
2021-06-30
18:46
Refactored [bf66d61582] to move the dir-has-a-checkout-db check into the new dir_has_ckout_db() routine. check-in: 3946ff81b0 user: stephan tags: trunk
Context
2021-06-30
13:56
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. check-in: 9ec744ed79 user: drh tags: trunk
2021-06-29
05:44
Per /chat #6763: if the ui command is passed the root dir of a checkout, chdir to that checkout to show the current checkout in the timeline by default. There may be a better/simpler way to implement this, thus this impl is in a branch. Closed-Leaf check-in: bf66d61582 user: stephan tags: ui-checkout-chdir
05:05
Fixed a && which was supposed to be a & in the new patch code. Caught by gcc. check-in: 1fd6961005 user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
2810
2811
2812
2813
2814
2815
2816





2817
2818
2819
2820
2821
2822
2823
** alphanumerics.  Any pathname that does not satisfy these constraints
** results in a 404 error.  Files in REPOSITORY that match the comma-separated
** list of glob patterns given by --files and that have known suffixes
** such as ".txt" or ".html" or ".jpeg" and do not match the pattern
** "*.fossil*" will be served as static content.  With the "ui" command,
** the REPOSITORY can only be a directory if the --notfound option is
** also present.





**
** For the special case REPOSITORY name of "/", the list global configuration
** database is consulted for a list of all known repositories.  The --repolist
** option is implied by this special case.  See also the "fossil all ui"
** command.
**
** By default, the "ui" command provides full administrative access without







>
>
>
>
>







2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
** alphanumerics.  Any pathname that does not satisfy these constraints
** results in a 404 error.  Files in REPOSITORY that match the comma-separated
** list of glob patterns given by --files and that have known suffixes
** such as ".txt" or ".html" or ".jpeg" and do not match the pattern
** "*.fossil*" will be served as static content.  With the "ui" command,
** the REPOSITORY can only be a directory if the --notfound option is
** also present.
**
** If the REPOSITORY is a directory name which is the root of a
** checkout, it will chdir to that directory and, unless overridden by
** the --page option, select the current checkout version in the
** timeline by default.
**
** For the special case REPOSITORY name of "/", the list global configuration
** database is consulted for a list of all known repositories.  The --repolist
** option is implied by this special case.  See also the "fossil all ui"
** command.
**
** By default, the "ui" command provides full administrative access without
2884
2885
2886
2887
2888
2889
2890

2891
2892
2893
2894
2895
2896
2897
#endif
  int allowRepoList;         /* List repositories on URL "/" */
  const char *zAltBase;      /* Argument to the --baseurl option */
  const char *zFileGlob;     /* Static content must match this */
  char *zIpAddr = 0;         /* Bind to this IP address */
  int fCreate = 0;           /* The --create flag */
  const char *zInitPage = 0; /* Start on this page.  --page option */


#if defined(_WIN32)
  const char *zStopperFile;    /* Name of file used to terminate server */
  zStopperFile = find_option("stopper", 0, 1);
#endif

  if( g.zErrlog==0 ){







>







2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
#endif
  int allowRepoList;         /* List repositories on URL "/" */
  const char *zAltBase;      /* Argument to the --baseurl option */
  const char *zFileGlob;     /* Static content must match this */
  char *zIpAddr = 0;         /* Bind to this IP address */
  int fCreate = 0;           /* The --create flag */
  const char *zInitPage = 0; /* Start on this page.  --page option */
  int findServerArg = 2;     /* argv index for find_server_repository() */

#if defined(_WIN32)
  const char *zStopperFile;    /* Name of file used to terminate server */
  zStopperFile = find_option("stopper", 0, 1);
#endif

  if( g.zErrlog==0 ){
2940
2941
2942
2943
2944
2945
2946

























2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
  if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
    fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
  }
  /* We should be done with options.. */
  verify_all_options();

  if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");

























  if( isUiCmd ){
    flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
    g.useLocalauth = 1;
    allowRepoList = 1;
  }
  find_server_repository(2, fCreate);
  if( zInitPage==0 ){
    if( isUiCmd && g.localOpen ){
      zInitPage = "timeline?c=current";
    }else{
      zInitPage = "";
    }
  }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|







2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
  if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
    fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
  }
  /* We should be done with options.. */
  verify_all_options();

  if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
  if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
    /* If REPOSITORY arg is the root of a checkout,
    ** chdir to that checkout so that the current version
    ** gets highlighted in the timeline by default. */
    const char * zArg = g.argv[2];
    char * zCkoutDb = mprintf("%//.fslckout", zArg);
    if(file_size(zCkoutDb, ExtFILE)<=0){
      fossil_free(zCkoutDb);
      zCkoutDb = mprintf("%//_FOSSIL_", zArg);
      if(file_size(zCkoutDb, ExtFILE)<=0){
        fossil_free(zCkoutDb);
        zCkoutDb = 0;
      }
    }
    if(zCkoutDb!=0){
      fossil_free(zCkoutDb);
      if(0!=file_chdir(zArg, 0)){
        fossil_fatal("Cannot chdir to %s", zArg);
      }
      findServerArg = 99;
      fCreate = 0;
      g.argv[2] = 0;
      --g.argc;
    }
  }
  if( isUiCmd ){
    flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
    g.useLocalauth = 1;
    allowRepoList = 1;
  }
  find_server_repository(findServerArg, fCreate);
  if( zInitPage==0 ){
    if( isUiCmd && g.localOpen ){
      zInitPage = "timeline?c=current";
    }else{
      zInitPage = "";
    }
  }