Fossil

Check-in [8d1ed47c]
Login

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

Overview
Comment:Add a test command to infer the hash policy from the length of path names on reconstruct (disabled by preprocessor directive).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reconstruct-sha3
Files: files | file ages | folders
SHA3-256: 8d1ed47cc6893493473b747a0f5743498b58c7c81294d7ad96ea7b354b4ee47b
User & Date: florian 2019-01-29 14:29:00
Wiki:reconstruct-sha3
Context
2019-02-05
15:43
Enhance the "reconstruct" command so that sets the correct hash policy for artifacts read from disk. check-in: 93bb3231 user: drh tags: trunk
2019-01-29
14:29
Add a test command to infer the hash policy from the length of path names on reconstruct (disabled by preprocessor directive). Closed-Leaf check-in: 8d1ed47c user: florian tags: reconstruct-sha3
14:09
Calculate hash lengths with skipped directory slashes. check-in: c47adb91 user: florian tags: reconstruct-sha3
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/rebuild.c.

  1072   1072   void recon_restore_hash_policy(){
  1073   1073     if( saved_eHashPolicy!=-1 ){
  1074   1074       g.eHashPolicy = saved_eHashPolicy;
  1075   1075       saved_eHashPolicy = -1;
  1076   1076     }
  1077   1077   }
  1078   1078   
         1079  +#if 0
         1080  +/*
         1081  +** COMMAND: test-hash-from-path*
         1082  +**
         1083  +** Usage: %fossil test-hash-from-path ?OPTIONS? DESTINATION UUID
         1084  +**
         1085  +** Generate a sample path name from DESTINATION and UUID, as the `deconstruct'
         1086  +** command would do.  Then try to guess the hash policy from the path name, as
         1087  +** the `reconstruct' command would do.
         1088  +**
         1089  +** No files or directories will be created.
         1090  +**
         1091  +** Options:
         1092  +**   -L|--prefixlength N     Set the length of the names of the DESTINATION
         1093  +**                           subdirectories to N.
         1094  +*/
         1095  +void test_hash_from_path_cmd(void) {
         1096  +  char *zDest;
         1097  +  char *zUuid;
         1098  +  char *zFile;
         1099  +  const char *zHashPolicy = "unknown";
         1100  +  const char *zPrefixOpt = find_option("prefixlength","L",1);
         1101  +  int iPrefixLength;
         1102  +  if( !zPrefixOpt ){
         1103  +    iPrefixLength = 2;
         1104  +  }else{
         1105  +    iPrefixLength = atoi(zPrefixOpt);
         1106  +    if( iPrefixLength<0 || iPrefixLength>9 ){
         1107  +      fossil_fatal("N(%s) is not a valid prefix length!",zPrefixOpt);
         1108  +    }
         1109  +  }
         1110  +  if( g.argc!=4 ){
         1111  +    usage ("?OPTIONS? DESTINATION UUID");
         1112  +  }
         1113  +  zDest = g.argv[2];
         1114  +  zUuid = g.argv[3];
         1115  +  if( iPrefixLength ){
         1116  +    zFNameFormat = mprintf("%s/%%.%ds/%%s",zDest,iPrefixLength);
         1117  +  }else{
         1118  +    zFNameFormat = mprintf("%s/%%s",zDest);
         1119  +  }
         1120  +  cchFNamePrefix = strlen(zDest);
         1121  +  zFile = mprintf(zFNameFormat /*works-like:"%s:%s"*/,
         1122  +                  zUuid, zUuid+iPrefixLength);
         1123  +  recon_set_hash_policy(cchFNamePrefix,zFile);
         1124  +  if( saved_eHashPolicy!=-1 ){
         1125  +    zHashPolicy = hpolicy_name();
         1126  +  }
         1127  +  recon_restore_hash_policy();
         1128  +  fossil_print(
         1129  +    "\nPath Name:   %s"
         1130  +    "\nHash Policy: %s\n",
         1131  +    zFile,zHashPolicy);
         1132  +  free(zFile);
         1133  +  free(zFNameFormat);
         1134  +  zFNameFormat = 0;
         1135  +  cchFNamePrefix = 0;
         1136  +}
         1137  +#endif
         1138  +
  1079   1139   /*
  1080   1140   ** COMMAND: reconstruct*
  1081   1141   **
  1082   1142   ** Usage: %fossil reconstruct ?OPTIONS? FILENAME DIRECTORY
  1083   1143   **
  1084   1144   ** This command studies the artifacts (files) in DIRECTORY and
  1085   1145   ** reconstructs the fossil record from them. It places the new