Fossil

Check-in [7a4bd5cf]
Login

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

Overview
Comment:Move manifest.symlinks read functionality into the new get_checkout_symlink_table() function in checkout.c
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | enhanced-symlink
Files: files | file ages | folders
SHA3-256:7a4bd5cf830693d03a2c11a64153d5680480dd80e7d544d28b344e1cbfe894a6
User & Date: andygoth 2017-10-14 21:32:55
Context
2017-10-14
21:37
Protect against symlink_perm table already existing, should get_checkout_symlink_table() have already been called check-in: 03ba3d9c user: andygoth tags: enhanced-symlink
21:32
Move manifest.symlinks read functionality into the new get_checkout_symlink_table() function in checkout.c check-in: 7a4bd5cf user: andygoth tags: enhanced-symlink
21:13
When committing on Windows with the "l" manifest flag set, update the symlink permission for selected files from the manifest.symlinks file if it exists check-in: 2808e225 user: andygoth tags: enhanced-symlink
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

1498
1499
1500
1501
1502
1503
1504


1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
....
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
  Stmt q;                     /* Various queries */
  Blob mcksum;                /* Manifest checksum */
  ManifestFile *pFile;        /* File from the baseline */
  int nFBcard = 0;            /* Number of B-cards and F-cards */
  int i;                      /* Loop counter */
  const char *zColor;         /* Modified value of p->zColor */



#ifdef _WIN32
  /* On Windows, if the "manifest" setting contains the "l" flag, get the
   * symlink status bits from the "manifest.symlinks" file. */
  int manifestSymlinks = db_get_manifest_setting() & MFESTFLG_SYMLINKS;
  if( manifestSymlinks ){
    char *zFile = mprintf("%smanifest.symlinks", g.zLocalRoot);
    if( file_wd_size(zFile)>=0 ){
      /* If the file exists, read its contents into a temporary table. */
      char *zLine, *zEnd;
      Blob content = BLOB_INITIALIZER;
      blob_read_from_file(&content, zFile);
      blob_append(&content, "\n", 2);
      db_multi_exec("CREATE TEMP TABLE symlink(filename TEXT PRIMARY KEY %s)",
                    filename_collation());
      zLine = blob_buffer(&content);
      while( *zLine ){
        /* Find end of line and replace with NUL. */
        for( zEnd = zLine; *zEnd!='\r' && *zEnd!='\n'; ++zEnd );
        *zEnd = 0;

        /* If not a blank line, insert filename into symlink table. */
        if( *zLine ){
          db_multi_exec("INSERT OR IGNORE INTO symlink VALUES(%Q)", zLine);
        }

        /* Find start of next line, or find terminating NUL at end of file. */
        for( zLine = zEnd+1; *zLine=='\r' || *zLine=='\n'; ++zLine );
      }
      blob_reset(&content);
    }else{
      /* If the file is nonexistent, pretend the "l" flag was not specified. */
      manifestSymlinks = 0;
    }
  }
#endif

  assert( pBaseline==0 || pBaseline->zBaseline==0 );
  assert( pBaseline==0 || zBaselineUuid!=0 );
  blob_zero(pOut);
  if( vid ){
    zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
................................................................................
    blob_resize(&filename, nBasename);
    blob_append(&filename, zName, -1);

    /* Potentially update the permissions of files selected to be checked in. */
#ifdef _WIN32
    /* For Windows, if the "manifest" setting contains the "l" flag and the
    ** "manifest.symlinks" file exists, use its contents to determine which
    ** files do and do not have the "symlink" permission.
    */
    if( isSelected && manifestSymlinks ){
      isLink = db_exists("SELECT 1 FROM symlink WHERE filename=%Q", zName);
    }
#else
    /* For unix, extract the "executable" and "symlink" permissions
    ** directly from the filesystem.  On windows, permissions are
    ** unchanged from the original.
    */
    if( isSelected ){







>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<







 







|


|







1498
1499
1500
1501
1502
1503
1504
1505
1506
1507






























1508


1509
1510
1511
1512
1513
1514
1515
....
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
  Stmt q;                     /* Various queries */
  Blob mcksum;                /* Manifest checksum */
  ManifestFile *pFile;        /* File from the baseline */
  int nFBcard = 0;            /* Number of B-cards and F-cards */
  int i;                      /* Loop counter */
  const char *zColor;         /* Modified value of p->zColor */

  /* On Windows, get symlink permission status from the "manifest.symlinks" file
   * if it exists and if the "manifest" setting contains the "l" flag. */
#ifdef _WIN32






























  int manifestSymlinks = get_checkout_symlink_table();


#endif

  assert( pBaseline==0 || pBaseline->zBaseline==0 );
  assert( pBaseline==0 || zBaselineUuid!=0 );
  blob_zero(pOut);
  if( vid ){
    zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
................................................................................
    blob_resize(&filename, nBasename);
    blob_append(&filename, zName, -1);

    /* Potentially update the permissions of files selected to be checked in. */
#ifdef _WIN32
    /* For Windows, if the "manifest" setting contains the "l" flag and the
    ** "manifest.symlinks" file exists, use its contents to determine which
    ** files do and do not have the symlink permission.
    */
    if( isSelected && manifestSymlinks ){
      isLink = db_exists("SELECT 1 FROM symlink_perm WHERE filename=%Q", zName);
    }
#else
    /* For unix, extract the "executable" and "symlink" permissions
    ** directly from the filesystem.  On windows, permissions are
    ** unchanged from the original.
    */
    if( isSelected ){

Changes to src/checkout.c.

245
246
247
248
249
250
251

























































252
253
254
255
256
257
258
  while( (pFile = manifest_file_next(pManifest, 0)) ){
    if( pFile->zPerm && strstr(pFile->zPerm, "l") ){
      blob_appendf(pOut, "%s\n", pFile->zName);
    }
  }
  manifest_destroy(pManifest);
}


























































/*
** COMMAND: checkout*
** COMMAND: co*
**
** Usage: %fossil checkout ?VERSION | --latest? ?OPTIONS?
**    or: %fossil co ?VERSION | --latest? ?OPTIONS?







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







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
  while( (pFile = manifest_file_next(pManifest, 0)) ){
    if( pFile->zPerm && strstr(pFile->zPerm, "l") ){
      blob_appendf(pOut, "%s\n", pFile->zName);
    }
  }
  manifest_destroy(pManifest);
}

#ifdef _WIN32
/*
** Create a temporary table called "symlink_perm" containing the names of all
** files considered to be symlinks.  This function only exists in Windows
** because Unix symlink status comes directly from the filesystem.  The return
** value is 1 if the table was created or 0 if symlink status is to be inherited
** from the baseline check-in manifest.  The latter case occurs when the file
** does not exist or when the "manifest" setting does not contain the "l" flag.
*/
int get_checkout_symlink_table(void){
  Blob content = BLOB_INITIALIZER;
  char *zFile, *zLine, *zEnd;

  /* If the "manifest" setting lacks the "l" flag, do no further processing.
   * Symlink status will be inherited from the previous check-in. */
  if( !(db_get_manifest_setting() & MFESTFLG_SYMLINKS) ){
    return 0;
  }

  /* If the "manifest.symlinks" file does not exist, act as if the "manifest"
   * setting didn't have "l".  The file will be regenerated with the next commit
   * or update, but for now, temporarily disable symlink status updating. */
  zFile = mprintf("%smanifest.symlinks", g.zLocalRoot);
  if( file_wd_size(zFile)<0 ){
    return 0;
  }

  /* Read "manifest.symlinks" into a blob to be analyzed.  Simplify processing
   * by forcing it to end with newline-NUL. */
  blob_read_from_file(&content, zFile);
  blob_append(&content, "\n", 2);
  zLine = blob_buffer(&content);

  /* Insert each non-empty line of "manifest.symlinks" into the "symlink_perm"
   * temporary table. */
  db_multi_exec("CREATE TEMP TABLE symlink_perm(filename TEXT PRIMARY KEY %s)",
                filename_collation());
  while( *zLine ){
    /* Find end of line and replace with NUL. */
    for( zEnd = zLine; *zEnd!='\r' && *zEnd!='\n'; ++zEnd );
    *zEnd = 0;

    /* If not a blank line, insert filename into symlink table. */
    if( *zLine ){
      db_multi_exec("INSERT OR IGNORE INTO symlink_perm VALUES(%Q)", zLine);
    }

    /* Find start of next line, or find terminating NUL at end of file. */
    for( zLine = zEnd+1; *zLine=='\r' || *zLine=='\n'; ++zLine );
  }
  blob_reset(&content);

  /* Let the caller know the "symlink_perm" table was created and is valid. */
  return 1;
}
#endif

/*
** COMMAND: checkout*
** COMMAND: co*
**
** Usage: %fossil checkout ?VERSION | --latest? ?OPTIONS?
**    or: %fossil co ?VERSION | --latest? ?OPTIONS?