Fossil

Check-in [be993c47]
Login

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

Overview
Comment:Fix db_open_local() fonction so it find the local checkout database on "/". It was working inconsistently depending what was the current directory.

** Even if fossil is not the right tool to version files on the root of the system, I found it very usefull to track what file change on my system

Tested on Linux and MinGW (Windows 8.1)

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | checkout_on_root_fix
Files: files | file ages | folders
SHA1:be993c47d5dd6d319d6317f917446f6691106d63
User & Date: mgagnon 2014-01-08 04:42:46
Original Comment: Fix db_open_local() fonction so it find the local checkout database on "/". It was working inconsistently depending what was the current directory.

** Even if fossil is not the right tool to version files on the root of the system, I found it very usefull to track what file change on my system

Tested on Linux only for now..

Context
2014-01-08
04:59
Remove traces.

Waiting approval to merge on trunk.. check-in: 84abd455 user: mgagnon tags: checkout_on_root_fix

04:42
Fix db_open_local() fonction so it find the local checkout database on "/". It was working inconsistently depending what was the current directory.

** Even if fossil is not the right tool to version files on the root of the system, I found it very usefull to track what file change on my system

Tested on Linux and MinGW (Windows 8.1) check-in: be993c47 user: mgagnon tags: checkout_on_root_fix

00:58
Remove no longer necessary cursor='pointer'. check-in: 927cacb3 user: joel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

932
933
934
935
936
937
938

939
940
941
942
943
944
945
946
947


948
949
950
951
952
953
954
955
956
957
958



959
960
961
962
963
964
965
966
967
968



969
970
971
972
973
974
975
** to the root of the repository tree and this routine returns 1.  If
** no database is found, then this routine return 0.
**
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the _FOSSIL_ or .fslckout file
** is found, it is attached to the open database connection too.
*/

int db_open_local(const char *zDbName){
  int i, n;
  char zPwd[2000];
  static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".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 ){
    for(i=0; i<count(aDbName); 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);



        g.localOpen = 1;
        db_open_config(0);
        db_open_repository(zDbName);
        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;
}

/*







>








|
>
>






|




>
>
>







|
|

>
>
>







932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
** to the root of the repository tree and this routine returns 1.  If
** no database is found, then this routine return 0.
**
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the _FOSSIL_ or .fslckout file
** is found, it is attached to the open database connection too.
*/
/* #define DBG_CHECKOUT_ON_ROOT_FIX 1 */
int db_open_local(const char *zDbName){
  int i, n;
  char zPwd[2000];
  static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };

  if( g.localOpen) return 1;
  file_getcwd(zPwd, sizeof(zPwd)-20);
  n = strlen(zPwd);
#ifdef DBG_CHECKOUT_ON_ROOT_FIX
  fossil_trace("---> DEBUG: zPwd: %s, n: %d\n", zPwd, n);
#endif
  while( n>0 ){
    for(i=0; i<count(aDbName); 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>0 && zPwd[n-1]=='/' ){
          n--;
          zPwd[n] = 0;
        }
        g.zLocalRoot = mprintf("%s/", zPwd);
#ifdef DBG_CHECKOUT_ON_ROOT_FIX
        fossil_trace("---> DEBUG: g.zLocalRoot: %s\n", g.zLocalRoot);
#endif
        g.localOpen = 1;
        db_open_config(0);
        db_open_repository(zDbName);
        return 1;
      }
    }
    n--;
    while( n>1 && zPwd[n]!='/' ){ n--; }
    while( n>1 && zPwd[n-1]=='/' ){ n--; }
    zPwd[n] = 0;
#ifdef DBG_CHECKOUT_ON_ROOT_FIX
    fossil_trace("---> DEBUG: next zPwd: %s, n: %d\n", zPwd, n);
#endif
  }

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

/*