Changes On Branch bens-expr
Not logged in

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

Changes In Branch bens-expr Excluding Merge-Ins

This is equivalent to a diff from 4b3425401f to b21f47e967

2011-05-21
16:52
Add (verisionable) empty-dirs setting Closed-Leaf check-in: b21f47e967 user: ben tags: bens-expr
16:45
Print an "Internal Error" if the update command is unable to find a version to update to. check-in: 88e9f24aff user: drh tags: trunk
16:18
Slightly hacky way of putting versioned properties in .fossil-settings dir. Version ignore-glob, binary-glob, crnl-glob and manifest. Glob splitting allows line breaks as well as spaces and commas. check-in: 56b75c768a user: ben tags: bens-expr
15:38
Create new branch named "bens-expr" check-in: d73b1b5042 user: ben tags: bens-expr
2011-05-20
15:31
Abstract the getcwd() system library routine into file_getcwd() with appropriate translations on windows. check-in: 4b3425401f user: drh tags: trunk
14:17
Convert the return value of getcwd() from MBCS into UTF8 before using it. check-in: ef04076777 user: drh tags: trunk

Changes to Makefile.

    57     57   TCLSH = tclsh
    58     58   
    59     59   # You should not need to change anything below this line
    60     60   ###############################################################################
    61     61   #
    62     62   # Automatic platform-specific options.
    63     63   HOST_OS!= uname -s
           64  +# Some makes use a different syntax
           65  +HOST_OS_ALT :sh = uname -s
    64     66   
    65     67   LIB.SunOS= -lsocket -lnsl
    66     68   LIB += $(LIB.$(HOST_OS))
           69  +LIB += $(LIB.$(HOST_OS_ALT))
    67     70   
    68     71   TCC.DragonFly += -DUSE_PREAD
    69     72   TCC.FreeBSD += -DUSE_PREAD
    70     73   TCC.NetBSD += -DUSE_PREAD
    71     74   TCC.OpenBSD += -DUSE_PREAD
    72     75   TCC += $(TCC.$(HOST_OS))
    73     76   
    74     77   include $(SRCDIR)/main.mk

Changes to src/add.c.

    58     58     static const char *azManifest[] = {
    59     59        "manifest",
    60     60        "manifest.uuid",
    61     61     };
    62     62   
    63     63     if( N>=0 && N<count(azName) ) return azName[N];
    64     64     if( N>=count(azName) && N<count(azName)+count(azManifest)
    65         -      && db_get_boolean("manifest",0) ){
           65  +      && db_get_versionable_setting_boolean("manifest",0) ){
    66     66       return azManifest[N-count(azName)];
    67     67     }
    68     68     return 0;
    69     69   }
    70     70   
    71     71   /*
    72     72   ** Return a list of all reserved filenames as an SQL list.
................................................................................
   183    183     const char *zIgnoreFlag;   /* The --ignore option or ignore-glob setting */
   184    184     Glob *pIgnore;             /* Ignore everything matching this glob pattern */
   185    185   
   186    186     zIgnoreFlag = find_option("ignore",0,1);
   187    187     includeDotFiles = find_option("dotfiles",0,0)!=0;
   188    188     db_must_be_within_tree();
   189    189     if( zIgnoreFlag==0 ){
   190         -    zIgnoreFlag = db_get("ignore-glob", 0);
          190  +    zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0);
   191    191     }
   192    192     vid = db_lget_int("checkout",0);
   193    193     if( vid==0 ){
   194    194       fossil_panic("no checkout to add to");
   195    195     }
   196    196     db_begin_transaction();
   197    197     db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
................................................................................
   335    335     int vid;
   336    336     int nAdd = 0;
   337    337     int nDelete = 0;
   338    338     Glob *pIgnore;
   339    339   
   340    340     db_must_be_within_tree();
   341    341     if( zIgnoreFlag==0 ){
   342         -    zIgnoreFlag = db_get("ignore-glob", 0);
          342  +    zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0);
   343    343     }
   344    344     vid = db_lget_int("checkout",0);
   345    345     if( vid==0 ){
   346    346       fossil_panic("no checkout to add to");
   347    347     }
   348    348     db_begin_transaction();
   349    349   

Changes to src/checkin.c.

   222    222     int n;
   223    223     const char *zIgnoreFlag = find_option("ignore",0,1);
   224    224     int allFlag = find_option("dotfiles",0,0)!=0;
   225    225     int outputManifest;
   226    226     Glob *pIgnore;
   227    227   
   228    228     db_must_be_within_tree();
   229         -  outputManifest = db_get_boolean("manifest",0);
          229  +  outputManifest = db_get_versionable_setting_boolean("manifest",0);
   230    230     db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
   231    231     n = strlen(g.zLocalRoot);
   232    232     blob_init(&path, g.zLocalRoot, n-1);
   233    233     if( zIgnoreFlag==0 ){
   234         -    zIgnoreFlag = db_get("ignore-glob", 0);
          234  +    zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0);
   235    235     }
   236    236     pIgnore = glob_create(zIgnoreFlag);
   237    237     vfile_scan(&path, blob_size(&path), allFlag, pIgnore);
   238    238     glob_free(pIgnore);
   239    239     db_prepare(&q, 
   240    240         "SELECT x FROM sfile"
   241    241         " WHERE x NOT IN (%s)"
................................................................................
   281    281     Glob *pIgnore;
   282    282   
   283    283     allFlag = find_option("force","f",0)!=0;
   284    284     dotfilesFlag = find_option("dotfiles",0,0)!=0;
   285    285     zIgnoreFlag = find_option("ignore",0,1);
   286    286     db_must_be_within_tree();
   287    287     if( zIgnoreFlag==0 ){
   288         -    zIgnoreFlag = db_get("ignore-glob", 0);
          288  +    zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0);
   289    289     }
   290    290     db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
   291    291     n = strlen(g.zLocalRoot);
   292    292     blob_init(&path, g.zLocalRoot, n-1);
   293    293     pIgnore = glob_create(zIgnoreFlag);
   294    294     vfile_scan(&path, blob_size(&path), dotfilesFlag, pIgnore);
   295    295     glob_free(pIgnore);
................................................................................
   829    829     }
   830    830     zDateOvrd = find_option("date-override",0,1);
   831    831     zUserOvrd = find_option("user-override",0,1);
   832    832     db_must_be_within_tree();
   833    833     noSign = db_get_boolean("omitsign", 0)|noSign;
   834    834     if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
   835    835     useCksum = db_get_boolean("repo-cksum", 1);
   836         -  outputManifest = db_get_boolean("manifest", 0);
          836  +  outputManifest = db_get_versionable_setting_boolean("manifest", 0);
   837    837     verify_all_options();
   838    838   
   839    839     /* So that older versions of Fossil (that do not understand delta-
   840    840     ** manifest) can continue to use this repository, do not create a new
   841    841     ** delta-manifest unless this repository already contains one or more
   842    842     ** delta-manifets, or unless the delta-manifest is explicitly requested
   843    843     ** by the --delta option.
................................................................................
   970    970     /* Step 1: Insert records for all modified files into the blob 
   971    971     ** table. If there were arguments passed to this command, only
   972    972     ** the identified fils are inserted (if they have been modified).
   973    973     */
   974    974     db_prepare(&q,
   975    975       "SELECT id, %Q || pathname, mrid, %s FROM vfile "
   976    976       "WHERE chnged==1 AND NOT deleted AND file_is_selected(id)",
   977         -    g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob",""))
          977  +    g.zLocalRoot, glob_expr("pathname", db_get_versionable_setting("crnl-glob",""))
   978    978     );
   979    979     while( db_step(&q)==SQLITE_ROW ){
   980    980       int id, rid;
   981    981       const char *zFullname;
   982    982       Blob content;
   983    983       int crnlOk;
   984    984   

Changes to src/checkout.c.

   139    139   ** the text of the manifest and the artifact ID of the manifest.
   140    140   */
   141    141   void manifest_to_disk(int vid){
   142    142     char *zManFile;
   143    143     Blob manifest;
   144    144     Blob hash;
   145    145   
   146         -  if( db_get_boolean("manifest",0) ){
          146  +  if( db_get_versionable_setting_boolean("manifest",0) ){
   147    147       blob_zero(&manifest);
   148    148       content_get(vid, &manifest);
   149    149       zManFile = mprintf("%smanifest", g.zLocalRoot);
   150    150       blob_write_to_file(&manifest, zManFile);
   151    151       free(zManFile);
   152    152       blob_zero(&hash);
   153    153       sha1sum_blob(&manifest, &hash);
................................................................................
   240    240     }
   241    241     db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
   242    242     if( !keepFlag ){
   243    243       vfile_to_disk(vid, 0, 1, promptFlag);
   244    244     }
   245    245     checkout_set_all_exe(vid);
   246    246     manifest_to_disk(vid);
          247  +  ensure_empty_dirs_created();
   247    248     db_lset_int("checkout", vid);
   248    249     undo_reset();
   249    250     db_multi_exec("DELETE FROM vmerge");
   250    251     if( !keepFlag && db_get_boolean("repo-cksum",1) ){
   251    252       vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
   252    253       vfile_aggregate_checksum_disk(vid, &cksum2);
   253    254       if( blob_compare(&cksum1, &cksum2) ){

Changes to src/configure.c.

    79     79     { "logo-mimetype",          CONFIGSET_SKIN },
    80     80     { "logo-image",             CONFIGSET_SKIN },
    81     81     { "project-name",           CONFIGSET_PROJ },
    82     82     { "project-description",    CONFIGSET_PROJ },
    83     83     { "manifest",               CONFIGSET_PROJ },
    84     84     { "ignore-glob",            CONFIGSET_PROJ },
    85     85     { "crnl-glob",              CONFIGSET_PROJ },
           86  +  { "empty-dirs",             CONFIGSET_PROJ },
    86     87     { "index-page",             CONFIGSET_SKIN },
    87     88     { "timeline-block-markup",  CONFIGSET_SKIN },
    88     89     { "timeline-max-comment",   CONFIGSET_SKIN },
    89     90     { "ticket-table",           CONFIGSET_TKT  },
    90     91     { "ticket-common",          CONFIGSET_TKT  },
    91     92     { "ticket-newpage",         CONFIGSET_TKT  },
    92     93     { "ticket-viewpage",        CONFIGSET_TKT  },

Changes to src/db.c.

  1388   1388   void db_swap_connections(void){
  1389   1389     if( !g.useAttach ){
  1390   1390       sqlite3 *dbTemp = g.db;
  1391   1391       g.db = g.dbConfig;
  1392   1392       g.dbConfig = dbTemp;
  1393   1393     }
  1394   1394   }
         1395  +
         1396  +/*
         1397  +** Get a potentially versioned setting - either from .fossil-settings/<name>
         1398  +*/
         1399  +char *db_get_versionable_setting(const char *zName, char *zDefault){
         1400  +  char *s = 0;
         1401  +  if( db_open_local() ){
         1402  +    /* See if there's a versioned setting */
         1403  +    Blob versionedPathname;
         1404  +    blob_zero(&versionedPathname);
         1405  +    blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", g.zLocalRoot, zName);
         1406  +    char *zVersionedPathname = blob_str(&versionedPathname);
         1407  +    if( file_size(zVersionedPathname) >= 0 ){
         1408  +      /* File exists, and contains the value for this setting. Load from the file. */
         1409  +      Blob setting;
         1410  +      blob_zero(&setting);
         1411  +      if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
         1412  +        s = strdup(blob_str(&setting));
         1413  +      }
         1414  +      blob_reset(&setting);
         1415  +    }
         1416  +    blob_reset(&versionedPathname);
         1417  +  }
         1418  +  if( s != 0 ){
         1419  +    return s;
         1420  +  }
         1421  +  /* Fall back to settings in the database */
         1422  +  return db_get(zName, zDefault);
         1423  +}
         1424  +int db_get_versionable_setting_boolean(const char *zName, int dflt){
         1425  +  char *zVal = db_get_versionable_setting(zName, dflt ? "on" : "off");
         1426  +  if( is_truth(zVal) ) return 1;
         1427  +  if( is_false(zVal) ) return 0;
         1428  +  return dflt;
         1429  +}
         1430  +
  1395   1431   
  1396   1432   /*
  1397   1433   ** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
  1398   1434   ** repository and local databases.
  1399   1435   */
  1400   1436   char *db_get(const char *zName, char *zDefault){
  1401   1437     char *z = 0;
................................................................................
  1650   1686     { "diff-command",  0,               16, ""                    },
  1651   1687     { "dont-push",     0,                0, "off"                 },
  1652   1688     { "editor",        0,               16, ""                    },
  1653   1689     { "gdiff-command", 0,               16, "gdiff"               },
  1654   1690     { "gmerge-command",0,               40, ""                    },
  1655   1691     { "https-login",   0,                0, "off"                 },
  1656   1692     { "ignore-glob",   0,               40, ""                    },
         1693  +  { "empty-dirs",    0,               40, ""                    },
  1657   1694     { "http-port",     0,               16, "8080"                },
  1658   1695     { "localauth",     0,                0, "off"                 },
  1659   1696     { "main-branch",   0,               40, "trunk"               },
  1660   1697     { "manifest",      0,                0, "off"                 },
  1661   1698     { "max-upload",    0,               25, "250000"              },
  1662   1699     { "mtime-changes", 0,                0, "on"                  },
  1663   1700     { "pgp-command",   0,               32, "gpg --clearsign -o " },

Changes to src/glob.c.

   108    108     if( zPatternList==0 || zPatternList[0]==0 ) return 0;
   109    109     nList = strlen(zPatternList);
   110    110     p = fossil_malloc( sizeof(*p) + nList+1 );
   111    111     memset(p, 0, sizeof(*p));
   112    112     z = (char*)&p[1];
   113    113     memcpy(z, zPatternList, nList+1);
   114    114     while( z[0] ){
   115         -    while( z[0]==',' || z[0]==' ' ) z++;  /* Skip leading spaces */
          115  +    while( z[0]==',' || z[0]==' ' || z[0]=='\n' || z[0]=='\r' ) z++;  /* Skip leading spaces and newlines */
   116    116       if( z[0]=='\'' || z[0]=='"' ){
   117    117         delimiter = z[0];
   118    118         z++;
   119    119       }else{
   120    120         delimiter = ',';
   121    121       }
   122    122       if( z[0]==0 ) break;
   123    123       p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) );
   124    124       p->azPattern[p->nPattern++] = z;
   125         -    for(i=0; z[i] && z[i]!=delimiter; i++){}
          125  +    for(i=0; z[i] && z[i]!=delimiter && z[i]!='\n' && z[i]!='\r'; i++){}
   126    126       if( delimiter==',' ){
   127         -      /* Remove trailing spaces on a comma-delimited pattern */
   128         -      for(j=i; j>1 && z[j-1]==' '; j--){}
          127  +      /* Remove trailing spaces / newlines on a comma-delimited pattern */
          128  +      for(j=i; j>1 && (z[j-1]==' ' || z[j-1]=='\n' || z[j-1]=='\r'); j--){}
   129    129         if( j<i ) z[j] = 0;
   130    130       }
   131    131       if( z[i]==0 ) break;
   132    132       z[i] = 0;
   133    133       z += i+1;
   134    134     }
   135    135     return p;

Changes to src/merge.c.

    89     89     zBinGlob = find_option("binary",0,1);
    90     90     nochangeFlag = find_option("nochange","n",0)!=0;
    91     91     zPivot = find_option("baseline",0,1);
    92     92     if( g.argc!=3 ){
    93     93       usage("VERSION");
    94     94     }
    95     95     db_must_be_within_tree();
    96         -  if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
           96  +  if( zBinGlob==0 ) zBinGlob = db_get_versionable_setting("binary-glob",0);
    97     97     vid = db_lget_int("checkout", 0);
    98     98     if( vid==0 ){
    99     99       fossil_fatal("nothing is checked out");
   100    100     }
   101    101     mid = name_to_rid(g.argv[2]);
   102    102     if( mid==0 || !is_a_version(mid) ){
   103    103       fossil_fatal("not a version: %s", g.argv[2]);

Changes to src/tar.c.

   213    213       blob_appendf(&filename, "%s/", zDir);
   214    214     }
   215    215     nPrefix = blob_size(&filename);
   216    216   
   217    217     pManifest = manifest_get(rid, CFTYPE_MANIFEST);
   218    218     if( pManifest ){
   219    219       mTime = (pManifest->rDate - 2440587.5)*86400.0;
   220         -    if( db_get_boolean("manifest", 0) ){
          220  +    if( db_get_versionable_setting_boolean("manifest", 0) ){
   221    221         blob_append(&filename, "manifest", -1);
   222    222         zName = blob_str(&filename);
   223    223         tar_add_file(zName, &mfile, 0, mTime);
   224    224         sha1sum_blob(&mfile, &hash);
   225    225         blob_reset(&mfile);
   226    226         blob_append(&hash, "\n", 1);
   227    227         blob_resize(&filename, nPrefix);

Changes to src/update.c.

   113    113     if( vid==0 ){
   114    114       fossil_fatal("cannot find current version");
   115    115     }
   116    116     if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
   117    117       fossil_fatal("cannot update an uncommitted merge");
   118    118     }
   119    119     if( !nochangeFlag && !internalUpdate ) autosync(AUTOSYNC_PULL);
          120  +  
          121  +  /* Create any empty directories now, as well as after the update, so changes in settings are reflected now */
          122  +  ensure_empty_dirs_created();
   120    123   
   121    124     if( internalUpdate ){
   122    125       tid = internalUpdate;
   123    126     }else if( g.argc>=3 ){
   124    127       if( strcmp(g.argv[2], "current")==0 ){
   125    128         /* If VERSION is "current", then use the same algorithm to find the
   126    129         ** target as if VERSION were omitted. */
................................................................................
   433    436     
   434    437     /*
   435    438     ** Clean up the mid and pid VFILE entries.  Then commit the changes.
   436    439     */
   437    440     if( nochangeFlag ){
   438    441       db_end_transaction(1);  /* With --nochange, rollback changes */
   439    442     }else{
          443  +    ensure_empty_dirs_created();
   440    444       if( g.argc<=3 ){
   441    445         /* All files updated.  Shift the current checkout to the target. */
   442    446         db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
   443    447         checkout_set_all_exe(vid);
   444    448         manifest_to_disk(tid);
   445    449         db_lset_int("checkout", tid);
   446    450       }else{
................................................................................
   448    452         ** checkout unchanged. */
   449    453         db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
   450    454       }
   451    455       if( !internalUpdate ) undo_finish();
   452    456       db_end_transaction(0);
   453    457     }
   454    458   }
          459  +
          460  +/*
          461  +** Make sure empty directories are created
          462  +*/
          463  +void ensure_empty_dirs_created()
          464  +{
          465  +  /* Make empty directories? */
          466  +  char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
          467  +  if( zEmptyDirs!=0 ){
          468  +    Blob dirsList, line;
          469  +    blob_zero(&dirsList);
          470  +    blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
          471  +    while( blob_line(&dirsList, &line) ){
          472  +      if( blob_buffer(&line)[0]=='#' ) continue;
          473  +      Blob dirName;
          474  +      int l = blob_token(&line, &dirName);
          475  +      if(l > 0) {
          476  +        /* Try and create the directory */
          477  +        if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
          478  +          fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
          479  +        }
          480  +      }
          481  +    }
          482  +  }
          483  +}
   455    484   
   456    485   
   457    486   /*
   458    487   ** Get the contents of a file within the checking "revision".  If
   459    488   ** revision==NULL then get the file content for the current checkout.
   460    489   */
   461    490   int historical_version_of_file(

Changes to src/user.c.

    17     17   **
    18     18   ** Commands and procedures used for creating, processing, editing, and
    19     19   ** querying information about users.
    20     20   */
    21     21   #include "config.h"
    22     22   #include "user.h"
    23     23   
           24  +#if defined(__sun__) || defined(sun)
           25  +  /* On Solaris, getpass() will only return up to 8 characters. getpassphrase() returns up to 257. */
           26  +  #define getpass getpassphrase
           27  +#endif
    24     28   
    25     29   /*
    26     30   ** Strip leading and trailing space from a string and add the string
    27     31   ** onto the end of a blob.
    28     32   */
    29     33   static void strip_string(Blob *pBlob, char *z){
    30     34     int i;

Changes to src/zip.c.

   335    335     }
   336    336     nPrefix = blob_size(&filename);
   337    337   
   338    338     pManifest = manifest_get(rid, CFTYPE_MANIFEST);
   339    339     if( pManifest ){
   340    340       char *zName;
   341    341       zip_set_timedate(pManifest->rDate);
   342         -    if( db_get_boolean("manifest", 0) ){
          342  +    if( db_get_versionable_setting_boolean("manifest", 0) ){
   343    343         blob_append(&filename, "manifest", -1);
   344    344         zName = blob_str(&filename);
   345    345         zip_add_folders(zName);
   346    346         zip_add_file(zName, &mfile, 0);
   347    347         sha1sum_blob(&mfile, &hash);
   348    348         blob_reset(&mfile);
   349    349         blob_append(&hash, "\n", 1);