Fossil

Check-in [ec9480fc]
Login

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

Overview
Comment:Rename sfile x column to pathname to match vfile and to make room for new columns I plan to add
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-changes
Files: files | file ages | folders
SHA1: ec9480fcba01677547bb84cd3b0b50f75cdf303d
User & Date: andygoth 2016-11-06 06:39:19
Context
2016-11-06
07:57
Begin expanding status_report() to support being the backend for the ls command. The work is not yet complete. First we must debug a mysterious abort in SQLite. Test case: run "./fossil changes -differ" with at least one changed file. check-in: 9d5de8d7 user: andygoth tags: andygoth-changes
06:39
Rename sfile x column to pathname to match vfile and to make room for new columns I plan to add check-in: ec9480fc user: andygoth tags: andygoth-changes
05:15
Use clearer method of differentiating between the status and changes commands check-in: 4d33d958 user: andygoth tags: andygoth-changes
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/add.c.

   224    224       zRepo = blob_str(&repoName);
   225    225     }
   226    226     if( filenames_are_case_sensitive() ){
   227    227       xCmp = fossil_strcmp;
   228    228     }else{
   229    229       xCmp = fossil_stricmp;
   230    230     }
   231         -  db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
          231  +  db_prepare(&loop, "SELECT pathname FROM sfile ORDER BY pathname");
   232    232     while( db_step(&loop)==SQLITE_ROW ){
   233    233       const char *zToAdd = db_column_text(&loop, 0);
   234    234       if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
   235    235       for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
   236    236         if( xCmp(zToAdd, zReserved)==0 ) break;
   237    237       }
   238    238       if( zReserved ) continue;
................................................................................
   305    305     }
   306    306     if( zIgnoreFlag==0 ){
   307    307       zIgnoreFlag = db_get("ignore-glob", 0);
   308    308     }
   309    309     if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
   310    310     vid = db_lget_int("checkout",0);
   311    311     db_begin_transaction();
   312         -  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
          312  +  db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
   313    313                   filename_collation());
   314    314     pClean = glob_create(zCleanFlag);
   315    315     pIgnore = glob_create(zIgnoreFlag);
   316    316     nRoot = strlen(g.zLocalRoot);
   317    317   
   318    318     /* Load the names of all files that are to be added into sfile temp table */
   319    319     for(i=2; i<g.argc; i++){
................................................................................
   347    347             forceFlag = 1;
   348    348           }else if( cReply!='y' && cReply!='Y' ){
   349    349             blob_reset(&fullName);
   350    350             continue;
   351    351           }
   352    352         }
   353    353         db_multi_exec(
   354         -         "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
          354  +         "INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)",
   355    355            zTreeName
   356    356         );
   357    357       }
   358    358       blob_reset(&fullName);
   359    359     }
   360    360     glob_free(pIgnore);
   361    361     glob_free(pClean);
................................................................................
   472    472     }else{
   473    473   #if FOSSIL_ENABLE_LEGACY_MV_RM
   474    474       removeFiles = db_get_boolean("mv-rm-files",0);
   475    475   #else
   476    476       removeFiles = FOSSIL_MV_RM_FILE;
   477    477   #endif
   478    478     }
   479         -  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
          479  +  db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
   480    480                   filename_collation());
   481    481     for(i=2; i<g.argc; i++){
   482    482       Blob treeName;
   483    483       char *zTreeName;
   484    484   
   485    485       file_tree_name(g.argv[i], &treeName, 0, 1);
   486    486       zTreeName = blob_str(&treeName);
................................................................................
   492    492          "    AND NOT deleted",
   493    493          zTreeName, filename_collation(), zTreeName,
   494    494          filename_collation(), zTreeName, filename_collation()
   495    495       );
   496    496       blob_reset(&treeName);
   497    497     }
   498    498   
   499         -  db_prepare(&loop, "SELECT x FROM sfile");
          499  +  db_prepare(&loop, "SELECT pathname FROM sfile");
   500    500     while( db_step(&loop)==SQLITE_ROW ){
   501    501       fossil_print("DELETED %s\n", db_column_text(&loop, 0));
   502    502       if( removeFiles ) add_file_to_remove(db_column_text(&loop, 0));
   503    503     }
   504    504     db_finalize(&loop);
   505    505     if( !dryRunFlag ){
   506    506       db_multi_exec(
................................................................................
   668    668   
   669    669     /* step 1:
   670    670     ** Populate the temp table "sfile" with the names of all unmanaged
   671    671     ** files currently in the check-out, except for files that match the
   672    672     ** --ignore or ignore-glob patterns and dot-files.  Then add all of
   673    673     ** the files in the sfile temp table to the set of managed files.
   674    674     */
   675         -  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
          675  +  db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
   676    676                   filename_collation());
   677    677     n = strlen(g.zLocalRoot);
   678    678     blob_init(&path, g.zLocalRoot, n-1);
   679    679     /* now we read the complete file structure into a temp table */
   680    680     pClean = glob_create(zCleanFlag);
   681    681     pIgnore = glob_create(zIgnoreFlag);
   682    682     vfile_scan(&path, blob_size(&path), scanFlags, pClean, pIgnore);

Changes to src/checkin.c.

    71     71   ){
    72     72     Blob name;   /* Name of a candidate file or directory */
    73     73     char *zName; /* Name of a candidate file or directory */
    74     74     int isDir;   /* 1 for a directory, 0 if doesn't exist, 2 for anything else */
    75     75     int i;       /* Loop counter */
    76     76     int nRoot;   /* length of g.zLocalRoot */
    77     77   
    78         -  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
           78  +  db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
    79     79                   filename_collation());
    80     80     nRoot = (int)strlen(g.zLocalRoot);
    81     81     if( argc==0 ){
    82     82       blob_init(&name, g.zLocalRoot, nRoot - 1);
    83     83       vfile_scan(&name, blob_size(&name), scanFlags, pIgnore, 0);
    84     84       blob_reset(&name);
    85     85     }else{
................................................................................
    91     91           vfile_scan(&name, nRoot-1, scanFlags, pIgnore, 0);
    92     92         }else if( isDir==0 ){
    93     93           fossil_warning("not found: %s", &zName[nRoot]);
    94     94         }else if( file_access(zName, R_OK) ){
    95     95           fossil_fatal("cannot open %s", &zName[nRoot]);
    96     96         }else{
    97     97           db_multi_exec(
    98         -           "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
           98  +           "INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)",
    99     99              &zName[nRoot]
   100    100           );
   101    101         }
   102    102         blob_reset(&name);
   103    103       }
   104    104     }
   105    105   }
................................................................................
   157    157     }
   158    158   
   159    159     /* If C_EXTRA, add unmanaged files to the query result too. */
   160    160     if( flags & C_EXTRA ){
   161    161       if( blob_size(&sql) ){
   162    162         blob_append_sql(&sql, " UNION ALL");
   163    163       }
   164         -    blob_append_sql(&sql, " SELECT x AS pathname, 0, 0, 0, 0, 0, 0"
          164  +    blob_append_sql(&sql, " SELECT pathname, 0, 0, 0, 0, 0, 0"
   165    165                             " FROM sfile WHERE pathname NOT IN (%s)%s",
   166    166                             fossil_all_reserved_names(0), blob_sql_text(&where));
   167    167     }
   168    168   
   169    169     /* Append an ORDER BY clause then compile the query. */
   170    170     blob_append_sql(&sql, " ORDER BY pathname");
   171    171     db_prepare(&q, "%s", blob_sql_text(&sql));
................................................................................
   969    969     g.allowSymlinks = 1;  /* Find symlinks too */
   970    970     if( !dirsOnlyFlag ){
   971    971       Stmt q;
   972    972       Blob repo;
   973    973       if( !dryRunFlag && !disableUndo ) undo_begin();
   974    974       locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
   975    975       db_prepare(&q,
   976         -        "SELECT %Q || x FROM sfile"
   977         -        " WHERE x NOT IN (%s)"
          976  +        "SELECT %Q || pathname FROM sfile"
          977  +        " WHERE pathname NOT IN (%s)"
   978    978           " ORDER BY 1",
   979    979           g.zLocalRoot, fossil_all_reserved_names(0)
   980    980       );
   981    981       if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){
   982         -      db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
          982  +      db_multi_exec("DELETE FROM sfile WHERE pathname=%B", &repo);
   983    983       }
   984         -    db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
          984  +    db_multi_exec("DELETE FROM sfile WHERE pathname IN"
          985  +                  " (SELECT pathname FROM vfile)");
   985    986       while( db_step(&q)==SQLITE_ROW ){
   986    987         const char *zName = db_column_text(&q, 0);
   987    988         if( glob_match(pKeep, zName+nRoot) ){
   988    989           if( verboseFlag ){
   989    990             fossil_print("KEPT file \"%s\" not removed (due to --keep"
   990    991                          " or \"keep-glob\")\n", zName+nRoot);
   991    992           }

Changes to src/main.c.

  1195   1195   static int repo_list_page(void){
  1196   1196     Blob base;
  1197   1197     int n = 0;
  1198   1198   
  1199   1199     assert( g.db==0 );
  1200   1200     blob_init(&base, g.zRepositoryName, -1);
  1201   1201     sqlite3_open(":memory:", &g.db);
  1202         -  db_multi_exec("CREATE TABLE sfile(x TEXT);");
         1202  +  db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
  1203   1203     db_multi_exec("CREATE TABLE vfile(pathname);");
  1204   1204     vfile_scan(&base, blob_size(&base), 0, 0, 0);
  1205         -  db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*[^/].fossil'");
         1205  +  db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
  1206   1206     n = db_int(0, "SELECT count(*) FROM sfile");
  1207   1207     if( n>0 ){
  1208   1208       Stmt q;
  1209   1209       @ <html>
  1210   1210       @ <head>
  1211   1211       @ <base href="%s(g.zBaseURL)/" />
  1212   1212       @ <title>Repository List</title>
  1213   1213       @ </head>
  1214   1214       @ <body>
  1215   1215       @ <h1>Available Repositories:</h1>
  1216   1216       @ <ol>
  1217         -    db_prepare(&q, "SELECT x, substr(x,-7,-100000)||'/home'"
  1218         -                   " FROM sfile ORDER BY x COLLATE nocase;");
         1217  +    db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
         1218  +                   " FROM sfile ORDER BY pathname COLLATE nocase;");
  1219   1219       while( db_step(&q)==SQLITE_ROW ){
  1220   1220         const char *zName = db_column_text(&q, 0);
  1221   1221         const char *zUrl = db_column_text(&q, 1);
  1222   1222         @ <li><a href="%R/%h(zUrl)" target="_blank">%h(zName)</a></li>
  1223   1223       }
  1224   1224       @ </ol>
  1225   1225       @ </body>

Changes to src/stash.c.

   205    205     Stmt q;
   206    206     db_prepare(&q,
   207    207        "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
   208    208        "  FROM stashfile WHERE stashid=%d",
   209    209        stashid
   210    210     );
   211    211     vid = db_lget_int("checkout",0);
   212         -  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
          212  +  db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
   213    213                   filename_collation());
   214    214     while( db_step(&q)==SQLITE_ROW ){
   215    215       int rid = db_column_int(&q, 0);
   216    216       int isRemoved = db_column_int(&q, 1);
   217    217       int isExec = db_column_int(&q, 2);
   218    218       int isLink = db_column_int(&q, 3);
   219    219       const char *zOrig = db_column_text(&q, 4);
................................................................................
   220    220       const char *zNew = db_column_text(&q, 5);
   221    221       char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
   222    222       char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
   223    223       Blob delta;
   224    224       undo_save(zNew);
   225    225       blob_zero(&delta);
   226    226       if( rid==0 ){
   227         -      db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew);
          227  +      db_multi_exec("INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", zNew);
   228    228         db_ephemeral_blob(&q, 6, &delta);
   229    229         blob_write_to_file(&delta, zNPath);
   230    230         file_wd_setexe(zNPath, isExec);
   231    231       }else if( isRemoved ){
   232    232         fossil_print("DELETE %s\n", zOrig);
   233    233         file_delete(zOPath);
   234    234       }else{

Changes to src/vfile.c.

   496    496       if( glob_match(pIgnore2, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
   497    497       blob_resize(pPath, origSize);
   498    498     }
   499    499     if( skipAll ) return;
   500    500   
   501    501     if( depth==0 ){
   502    502       db_prepare(&ins,
   503         -       "INSERT OR IGNORE INTO sfile(x) SELECT :file"
          503  +       "INSERT OR IGNORE INTO sfile(pathname) SELECT :file"
   504    504          "  WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
   505    505          " pathname=:file %s)", filename_collation()
   506    506       );
   507    507     }
   508    508     depth++;
   509    509   
   510    510     zNative = fossil_utf8_to_path(blob_str(pPath), 1);