Fossil

Check-in [518e1f8d]
Login

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

Overview
Comment:Start a branch with fix to make work consistently a local checkout directly on root ("/").
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mgagnon_fix
Files: files | file ages | folders
SHA1:518e1f8d7fcb74bb165c4cc30921ff8c803dcb42
User & Date: mgagnon 2011-11-11 12:13:47
Original User & Date: meeks 2011-11-11 12:13:47
Context
2011-12-08
02:05
merge with latest trunk check-in: 4d392366 user: mgagnon tags: mgagnon_fix
2011-11-11
12:13
Start a branch with fix to make work consistently a local checkout directly on root ("/"). check-in: 518e1f8d user: mgagnon tags: mgagnon_fix
2011-11-05
03:45
Fix some more compiler warnings seen with MSVC. check-in: 24e298ed user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848

849



850
851
852
853
854
855
856



857

858
859
860
861
862
863



864
865
866
867
868
869
870
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the _FOSSIL_ or .fos file
** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
  int i, n;
  char zPwd[2000];
  static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
  
  if( g.localOpen) return 1;
  file_getcwd(zPwd, sizeof(zPwd)-20);
  n = strlen(zPwd);
  if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
  while( n>0 ){
    if( file_access(zPwd, W_OK) ) break;
    for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){

      sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);



      if( isValidLocalDb(zPwd) ){
        /* Found a valid checkout database file */
        zPwd[n] = 0;
        while( n>1 && zPwd[n-1]=='/' ){
          n--;
          zPwd[n] = 0;
        }



        g.zLocalRoot = mprintf("%s/", zPwd);

        return 1;
      }
    }
    n--;
    while( n>0 && zPwd[n]!='/' ){ n--; }
    while( n>0 && zPwd[n-1]=='/' ){ n--; }



    zPwd[n] = 0;
  }

  /* A checkout database file could not be found */
  return 0;
}








|




<



>
|
>
>
>







>
>
>

>






>
>
>







833
834
835
836
837
838
839
840
841
842
843
844

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the _FOSSIL_ or .fos file
** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
  int i, n;
  char zPwd[2000];
  static const char *aDbName[] = { "_FOSSIL_", ".fos" };
  
  if( g.localOpen) return 1;
  file_getcwd(zPwd, sizeof(zPwd)-20);
  n = strlen(zPwd);

  while( n>0 ){
    if( file_access(zPwd, W_OK) ) break;
    for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
      if( zPwd[n-1] == '/'){
        sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
      }else{
        sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
      }
      if( isValidLocalDb(zPwd) ){
        /* Found a valid checkout database file */
        zPwd[n] = 0;
        while( n>1 && zPwd[n-1]=='/' ){
          n--;
          zPwd[n] = 0;
        }
      if( zPwd[n-1] == '/'){
        g.zLocalRoot = mprintf("%s", zPwd);
      }else{
        g.zLocalRoot = mprintf("%s/", zPwd);
      }
        return 1;
      }
    }
    n--;
    while( n>0 && zPwd[n]!='/' ){ n--; }
    while( n>0 && zPwd[n-1]=='/' ){ n--; }
    if(n==0 && zPwd[0]=='/'){
      n=1;
    }
    zPwd[n] = 0;
  }

  /* A checkout database file could not be found */
  return 0;
}