Fossil SCM

Prefer manifest_file_find() over manifest_file_seek(), for case-insensitivity. Added option to force creating a delta whenever it's possible, rather than just suggest it.

stephan 2020-04-30 14:02 UTC checkin-without-checkout
Commit c3ae6b349637278b990ab76dec827408ddcbebcce0058b750948cb959a0d249e
1 file changed +48 -24
+48 -24
--- src/checkin.c
+++ src/checkin.c
@@ -2785,23 +2785,30 @@
27852785
** converted, if needed, to use the same EOL style as the previous
27862786
** version of that file. Only the in-memory/in-repo copies are
27872787
** affected, not the original file (if any).
27882788
*/
27892789
CIMINI_CONVERT_EOL = 1<<5,
2790
-
27912790
/*
2792
-** A hint to checkin_mini() to prefer creation of a delta manifest.
2791
+** A hint to checkin_mini() to "prefer" creation of a delta manifest.
2792
+** It may decide not to for various reasons.
27932793
*/
27942794
CIMINI_PREFER_DELTA = 1<<6,
2795
-
2795
+/*
2796
+** A "stronger hint" to checkin_mini() to prefer creation of a delta
2797
+** manifest if it at all can. It will decide not to only if creation
2798
+** of a delta is not a realistic option. For this to work, it must be
2799
+** set together with the CIMINI_PREFER_DELTA flag, but the two cannot
2800
+** be combined in this enum.
2801
+*/
2802
+CIMINI_STRONGLY_PREFER_DELTA = 1<<7,
27962803
/*
27972804
** Tells checkin_mini() to permit the addition of a new file. Normally
27982805
** this is disabled because there are many cases where it could cause
27992806
** the inadvertent addition of a new file when an update to an
28002807
** existing was intended, as a side-effect of name-case differences.
28012808
*/
2802
-CIMINI_ALLOW_NEW_FILE = 1<<7
2809
+CIMINI_ALLOW_NEW_FILE = 1<<8
28032810
};
28042811
28052812
/*
28062813
** Handles the F-card parts for create_manifest_mini().
28072814
**
@@ -2834,11 +2841,11 @@
28342841
if(asDelta){
28352842
/* Parent is a baseline and we have only 1 file to modify, so this
28362843
** is the simplest case...
28372844
*/
28382845
assert(pCI->pParent->zBaseline==0 && "Delta-from-delta is NYI.");
2839
- zFile = manifest_file_seek(pCI->pParent, pCI->zFilename,0);
2846
+ zFile = manifest_file_find(pCI->pParent, pCI->zFilename);
28402847
if(zFile==0){
28412848
/* New file */
28422849
zFilename = pCI->zFilename;
28432850
}else{
28442851
/* Replacement file */
@@ -2924,50 +2931,60 @@
29242931
*/
29252932
static int create_manifest_mini( Blob * pOut, CheckinMiniInfo * pCI,
29262933
Blob * pErr){
29272934
Blob zCard = empty_blob; /* Z-card checksum */
29282935
int asDelta = 0;
2936
+#define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
29292937
29302938
assert(blob_str(&pCI->fileHash));
29312939
assert(pCI->pParent);
29322940
assert(pCI->zFilename);
29332941
assert(pCI->zUser);
29342942
assert(pCI->zDate);
2935
-
2936
-#define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
2943
+
29372944
/* Potential TODOs include...
2938
- ** - Create a delta manifest, if possible, rather than a baseline.
2945
+ ** - Create a delta manifest, if possible/feasible, rather than a
2946
+ ** baseline (done) even if pCI->pParent is a delta (not done).
29392947
** - Maybe add support for tags. Those can be edited via /info page.
29402948
** - Symlinks: if we're really in a checkout, handle commit/add of
2941
- ** symlinks like a normal commit would. For now we bail out if
2949
+ ** symlinks like a normal commit would. For now we bail out if
29422950
** told to handle a symlink because there would seem to be no(?)
29432951
** sensible way to handle a symlink add/checkin without a
29442952
** checkout.
29452953
*/
29462954
blob_zero(pOut);
2947
- if((pCI->flags & CIMINI_PREFER_DELTA)
2948
- && pCI->pParent->zBaseline==0){
2955
+ manifest_file_rewind(pCI->pParent) /* force load of baseline */;
2956
+ if(((CIMINI_PREFER_DELTA & pCI->flags)
2957
+ && pCI->pParent->zBaseline==0 /* parent is not a delta */
2958
+ /* ^^^ TODO allow creation of a delta from a delta */
2959
+ )&&(
2960
+ CIMINI_STRONGLY_PREFER_DELTA & pCI->flags
2961
+ || (pCI->pParent->pBaseline
2962
+ ? pCI->pParent->pBaseline
2963
+ : pCI->pParent)->nFile > 10
2964
+ /* 10 is arbitrary: don't create a delta when there is only a
2965
+ ** tiny gain for doing so. */)){
29492966
asDelta = 1;
29502967
}
29512968
if(asDelta){
2952
- blob_appendf(pOut, "B %s\n", pCI->zParentUuid);
2969
+ blob_appendf(pOut, "B %s\n",
2970
+ pCI->pParent->zBaseline
2971
+ ? pCI->pParent->zBaseline
2972
+ : pCI->zParentUuid);
29532973
}
29542974
if(blob_size(&pCI->comment)!=0){
29552975
blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
29562976
}else{
29572977
blob_append(pOut, "C (no\\scomment)\n", 16);
29582978
}
29592979
blob_appendf(pOut, "D %z\n", pCI->zDate);
2960
-
29612980
if(!create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)){
29622981
return 0;
29632982
}
2964
-
29652983
if(pCI->zMimetype!=0 && pCI->zMimetype[0]!=0){
29662984
blob_appendf(pOut, "N %F\n", pCI->zMimetype);
29672985
}
2968
-
29692986
blob_appendf(pOut, "P %s\n", pCI->zParentUuid);
29702987
blob_appendf(pOut, "U %F\n", pCI->zUser);
29712988
md5sum_blob(pOut, &zCard);
29722989
blob_appendf(pOut, "Z %b\n", &zCard);
29732990
blob_reset(&zCard);
@@ -3122,11 +3139,11 @@
31223139
** X/Y/z gets committed as X/Y/Z or X/y/z due to a typo or
31233140
** case-sensitivity mismatch between the user/repo/filesystem, or
31243141
** some such.
31253142
*/
31263143
manifest_file_rewind(pCI->pParent);
3127
- zFilePrev = manifest_file_seek(pCI->pParent, pCI->zFilename, 0);
3144
+ zFilePrev = manifest_file_find(pCI->pParent, pCI->zFilename);
31283145
if(!zFilePrev && !(CIMINI_ALLOW_NEW_FILE & pCI->flags)){
31293146
ci_err((pErr,"File [%s] not found in manifest [%S]. "
31303147
"Adding new files is currently not permitted.",
31313148
pCI->zFilename, pCI->zParentUuid));
31323149
}else if(zFilePrev
@@ -3242,31 +3259,34 @@
32423259
** vfile table.
32433260
**
32443261
** Options:
32453262
**
32463263
** --repository|-R REPO The repository file to commit to.
3247
-** --as FILENAME The repository-side name of the input file,
3248
-** relative to the top of the repository.
3249
-** Default is the same as the input file name.
3264
+** --as FILENAME The repository-side name of the input
3265
+** file, relative to the top of the
3266
+** repository. Default is the same as the
3267
+** input file name.
32503268
** --comment|-m COMMENT Required checkin comment.
32513269
** --comment-file|-M FILE Reads checkin comment from the given file.
32523270
** --revision|-r VERSION Commit from this version. Default is
32533271
** the checkout version (if available) or
32543272
** trunk (if used without a checkout).
32553273
** --allow-fork Allows the commit to be made against a
32563274
** non-leaf parent. Note that no autosync
32573275
** is performed beforehand.
3258
-** --allow-merge-conflict Allows checkin of a file even if it appears
3259
-** to contain a fossil merge conflict marker.
3260
-** --user-override USER USER to use instead of the current default.
3276
+** --allow-merge-conflict Allows checkin of a file even if it
3277
+** appears to contain a fossil merge conflict
3278
+** marker.
3279
+** --user-override USER USER to use instead of the current
3280
+** default.
32613281
** --date-override DATETIME DATE to use instead of 'now'.
32623282
** --allow-older Allow a commit to be older than its
32633283
** ancestor.
32643284
** --convert-eol Convert EOL style of the checkin to match
32653285
** the previous version's content. Does not
3266
-** modify the original file, only the
3267
-** checked-in content.
3286
+** modify the input file, only the checked-in
3287
+** content.
32683288
** --delta Prefer to generate a delta manifest, if
32693289
** able.
32703290
** --allow-new-file Allow addition of a new file this way.
32713291
** Disabled by default to avoid that case-
32723292
** sensitivity errors inadvertently lead to
@@ -3323,10 +3343,14 @@
33233343
cinf.flags |= CIMINI_CONVERT_EOL;
33243344
}
33253345
if(find_option("delta",0,0)!=0){
33263346
cinf.flags |= CIMINI_PREFER_DELTA;
33273347
}
3348
+ if(find_option("delta2",0,0)!=0){
3349
+ /* Undocumented. For testing only. */
3350
+ cinf.flags |= CIMINI_PREFER_DELTA | CIMINI_STRONGLY_PREFER_DELTA;
3351
+ }
33283352
if(find_option("allow-new-file",0,0)!=0){
33293353
cinf.flags |= CIMINI_ALLOW_NEW_FILE;
33303354
}
33313355
db_find_and_open_repository(0, 0);
33323356
verify_all_options();
33333357
--- src/checkin.c
+++ src/checkin.c
@@ -2785,23 +2785,30 @@
2785 ** converted, if needed, to use the same EOL style as the previous
2786 ** version of that file. Only the in-memory/in-repo copies are
2787 ** affected, not the original file (if any).
2788 */
2789 CIMINI_CONVERT_EOL = 1<<5,
2790
2791 /*
2792 ** A hint to checkin_mini() to prefer creation of a delta manifest.
 
2793 */
2794 CIMINI_PREFER_DELTA = 1<<6,
2795
 
 
 
 
 
 
 
2796 /*
2797 ** Tells checkin_mini() to permit the addition of a new file. Normally
2798 ** this is disabled because there are many cases where it could cause
2799 ** the inadvertent addition of a new file when an update to an
2800 ** existing was intended, as a side-effect of name-case differences.
2801 */
2802 CIMINI_ALLOW_NEW_FILE = 1<<7
2803 };
2804
2805 /*
2806 ** Handles the F-card parts for create_manifest_mini().
2807 **
@@ -2834,11 +2841,11 @@
2834 if(asDelta){
2835 /* Parent is a baseline and we have only 1 file to modify, so this
2836 ** is the simplest case...
2837 */
2838 assert(pCI->pParent->zBaseline==0 && "Delta-from-delta is NYI.");
2839 zFile = manifest_file_seek(pCI->pParent, pCI->zFilename,0);
2840 if(zFile==0){
2841 /* New file */
2842 zFilename = pCI->zFilename;
2843 }else{
2844 /* Replacement file */
@@ -2924,50 +2931,60 @@
2924 */
2925 static int create_manifest_mini( Blob * pOut, CheckinMiniInfo * pCI,
2926 Blob * pErr){
2927 Blob zCard = empty_blob; /* Z-card checksum */
2928 int asDelta = 0;
 
2929
2930 assert(blob_str(&pCI->fileHash));
2931 assert(pCI->pParent);
2932 assert(pCI->zFilename);
2933 assert(pCI->zUser);
2934 assert(pCI->zDate);
2935
2936 #define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
2937 /* Potential TODOs include...
2938 ** - Create a delta manifest, if possible, rather than a baseline.
 
2939 ** - Maybe add support for tags. Those can be edited via /info page.
2940 ** - Symlinks: if we're really in a checkout, handle commit/add of
2941 ** symlinks like a normal commit would. For now we bail out if
2942 ** told to handle a symlink because there would seem to be no(?)
2943 ** sensible way to handle a symlink add/checkin without a
2944 ** checkout.
2945 */
2946 blob_zero(pOut);
2947 if((pCI->flags & CIMINI_PREFER_DELTA)
2948 && pCI->pParent->zBaseline==0){
 
 
 
 
 
 
 
 
 
2949 asDelta = 1;
2950 }
2951 if(asDelta){
2952 blob_appendf(pOut, "B %s\n", pCI->zParentUuid);
 
 
 
2953 }
2954 if(blob_size(&pCI->comment)!=0){
2955 blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
2956 }else{
2957 blob_append(pOut, "C (no\\scomment)\n", 16);
2958 }
2959 blob_appendf(pOut, "D %z\n", pCI->zDate);
2960
2961 if(!create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)){
2962 return 0;
2963 }
2964
2965 if(pCI->zMimetype!=0 && pCI->zMimetype[0]!=0){
2966 blob_appendf(pOut, "N %F\n", pCI->zMimetype);
2967 }
2968
2969 blob_appendf(pOut, "P %s\n", pCI->zParentUuid);
2970 blob_appendf(pOut, "U %F\n", pCI->zUser);
2971 md5sum_blob(pOut, &zCard);
2972 blob_appendf(pOut, "Z %b\n", &zCard);
2973 blob_reset(&zCard);
@@ -3122,11 +3139,11 @@
3122 ** X/Y/z gets committed as X/Y/Z or X/y/z due to a typo or
3123 ** case-sensitivity mismatch between the user/repo/filesystem, or
3124 ** some such.
3125 */
3126 manifest_file_rewind(pCI->pParent);
3127 zFilePrev = manifest_file_seek(pCI->pParent, pCI->zFilename, 0);
3128 if(!zFilePrev && !(CIMINI_ALLOW_NEW_FILE & pCI->flags)){
3129 ci_err((pErr,"File [%s] not found in manifest [%S]. "
3130 "Adding new files is currently not permitted.",
3131 pCI->zFilename, pCI->zParentUuid));
3132 }else if(zFilePrev
@@ -3242,31 +3259,34 @@
3242 ** vfile table.
3243 **
3244 ** Options:
3245 **
3246 ** --repository|-R REPO The repository file to commit to.
3247 ** --as FILENAME The repository-side name of the input file,
3248 ** relative to the top of the repository.
3249 ** Default is the same as the input file name.
 
3250 ** --comment|-m COMMENT Required checkin comment.
3251 ** --comment-file|-M FILE Reads checkin comment from the given file.
3252 ** --revision|-r VERSION Commit from this version. Default is
3253 ** the checkout version (if available) or
3254 ** trunk (if used without a checkout).
3255 ** --allow-fork Allows the commit to be made against a
3256 ** non-leaf parent. Note that no autosync
3257 ** is performed beforehand.
3258 ** --allow-merge-conflict Allows checkin of a file even if it appears
3259 ** to contain a fossil merge conflict marker.
3260 ** --user-override USER USER to use instead of the current default.
 
 
3261 ** --date-override DATETIME DATE to use instead of 'now'.
3262 ** --allow-older Allow a commit to be older than its
3263 ** ancestor.
3264 ** --convert-eol Convert EOL style of the checkin to match
3265 ** the previous version's content. Does not
3266 ** modify the original file, only the
3267 ** checked-in content.
3268 ** --delta Prefer to generate a delta manifest, if
3269 ** able.
3270 ** --allow-new-file Allow addition of a new file this way.
3271 ** Disabled by default to avoid that case-
3272 ** sensitivity errors inadvertently lead to
@@ -3323,10 +3343,14 @@
3323 cinf.flags |= CIMINI_CONVERT_EOL;
3324 }
3325 if(find_option("delta",0,0)!=0){
3326 cinf.flags |= CIMINI_PREFER_DELTA;
3327 }
 
 
 
 
3328 if(find_option("allow-new-file",0,0)!=0){
3329 cinf.flags |= CIMINI_ALLOW_NEW_FILE;
3330 }
3331 db_find_and_open_repository(0, 0);
3332 verify_all_options();
3333
--- src/checkin.c
+++ src/checkin.c
@@ -2785,23 +2785,30 @@
2785 ** converted, if needed, to use the same EOL style as the previous
2786 ** version of that file. Only the in-memory/in-repo copies are
2787 ** affected, not the original file (if any).
2788 */
2789 CIMINI_CONVERT_EOL = 1<<5,
 
2790 /*
2791 ** A hint to checkin_mini() to "prefer" creation of a delta manifest.
2792 ** It may decide not to for various reasons.
2793 */
2794 CIMINI_PREFER_DELTA = 1<<6,
2795 /*
2796 ** A "stronger hint" to checkin_mini() to prefer creation of a delta
2797 ** manifest if it at all can. It will decide not to only if creation
2798 ** of a delta is not a realistic option. For this to work, it must be
2799 ** set together with the CIMINI_PREFER_DELTA flag, but the two cannot
2800 ** be combined in this enum.
2801 */
2802 CIMINI_STRONGLY_PREFER_DELTA = 1<<7,
2803 /*
2804 ** Tells checkin_mini() to permit the addition of a new file. Normally
2805 ** this is disabled because there are many cases where it could cause
2806 ** the inadvertent addition of a new file when an update to an
2807 ** existing was intended, as a side-effect of name-case differences.
2808 */
2809 CIMINI_ALLOW_NEW_FILE = 1<<8
2810 };
2811
2812 /*
2813 ** Handles the F-card parts for create_manifest_mini().
2814 **
@@ -2834,11 +2841,11 @@
2841 if(asDelta){
2842 /* Parent is a baseline and we have only 1 file to modify, so this
2843 ** is the simplest case...
2844 */
2845 assert(pCI->pParent->zBaseline==0 && "Delta-from-delta is NYI.");
2846 zFile = manifest_file_find(pCI->pParent, pCI->zFilename);
2847 if(zFile==0){
2848 /* New file */
2849 zFilename = pCI->zFilename;
2850 }else{
2851 /* Replacement file */
@@ -2924,50 +2931,60 @@
2931 */
2932 static int create_manifest_mini( Blob * pOut, CheckinMiniInfo * pCI,
2933 Blob * pErr){
2934 Blob zCard = empty_blob; /* Z-card checksum */
2935 int asDelta = 0;
2936 #define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
2937
2938 assert(blob_str(&pCI->fileHash));
2939 assert(pCI->pParent);
2940 assert(pCI->zFilename);
2941 assert(pCI->zUser);
2942 assert(pCI->zDate);
2943
 
2944 /* Potential TODOs include...
2945 ** - Create a delta manifest, if possible/feasible, rather than a
2946 ** baseline (done) even if pCI->pParent is a delta (not done).
2947 ** - Maybe add support for tags. Those can be edited via /info page.
2948 ** - Symlinks: if we're really in a checkout, handle commit/add of
2949 ** symlinks like a normal commit would. For now we bail out if
2950 ** told to handle a symlink because there would seem to be no(?)
2951 ** sensible way to handle a symlink add/checkin without a
2952 ** checkout.
2953 */
2954 blob_zero(pOut);
2955 manifest_file_rewind(pCI->pParent) /* force load of baseline */;
2956 if(((CIMINI_PREFER_DELTA & pCI->flags)
2957 && pCI->pParent->zBaseline==0 /* parent is not a delta */
2958 /* ^^^ TODO allow creation of a delta from a delta */
2959 )&&(
2960 CIMINI_STRONGLY_PREFER_DELTA & pCI->flags
2961 || (pCI->pParent->pBaseline
2962 ? pCI->pParent->pBaseline
2963 : pCI->pParent)->nFile > 10
2964 /* 10 is arbitrary: don't create a delta when there is only a
2965 ** tiny gain for doing so. */)){
2966 asDelta = 1;
2967 }
2968 if(asDelta){
2969 blob_appendf(pOut, "B %s\n",
2970 pCI->pParent->zBaseline
2971 ? pCI->pParent->zBaseline
2972 : pCI->zParentUuid);
2973 }
2974 if(blob_size(&pCI->comment)!=0){
2975 blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
2976 }else{
2977 blob_append(pOut, "C (no\\scomment)\n", 16);
2978 }
2979 blob_appendf(pOut, "D %z\n", pCI->zDate);
 
2980 if(!create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)){
2981 return 0;
2982 }
 
2983 if(pCI->zMimetype!=0 && pCI->zMimetype[0]!=0){
2984 blob_appendf(pOut, "N %F\n", pCI->zMimetype);
2985 }
 
2986 blob_appendf(pOut, "P %s\n", pCI->zParentUuid);
2987 blob_appendf(pOut, "U %F\n", pCI->zUser);
2988 md5sum_blob(pOut, &zCard);
2989 blob_appendf(pOut, "Z %b\n", &zCard);
2990 blob_reset(&zCard);
@@ -3122,11 +3139,11 @@
3139 ** X/Y/z gets committed as X/Y/Z or X/y/z due to a typo or
3140 ** case-sensitivity mismatch between the user/repo/filesystem, or
3141 ** some such.
3142 */
3143 manifest_file_rewind(pCI->pParent);
3144 zFilePrev = manifest_file_find(pCI->pParent, pCI->zFilename);
3145 if(!zFilePrev && !(CIMINI_ALLOW_NEW_FILE & pCI->flags)){
3146 ci_err((pErr,"File [%s] not found in manifest [%S]. "
3147 "Adding new files is currently not permitted.",
3148 pCI->zFilename, pCI->zParentUuid));
3149 }else if(zFilePrev
@@ -3242,31 +3259,34 @@
3259 ** vfile table.
3260 **
3261 ** Options:
3262 **
3263 ** --repository|-R REPO The repository file to commit to.
3264 ** --as FILENAME The repository-side name of the input
3265 ** file, relative to the top of the
3266 ** repository. Default is the same as the
3267 ** input file name.
3268 ** --comment|-m COMMENT Required checkin comment.
3269 ** --comment-file|-M FILE Reads checkin comment from the given file.
3270 ** --revision|-r VERSION Commit from this version. Default is
3271 ** the checkout version (if available) or
3272 ** trunk (if used without a checkout).
3273 ** --allow-fork Allows the commit to be made against a
3274 ** non-leaf parent. Note that no autosync
3275 ** is performed beforehand.
3276 ** --allow-merge-conflict Allows checkin of a file even if it
3277 ** appears to contain a fossil merge conflict
3278 ** marker.
3279 ** --user-override USER USER to use instead of the current
3280 ** default.
3281 ** --date-override DATETIME DATE to use instead of 'now'.
3282 ** --allow-older Allow a commit to be older than its
3283 ** ancestor.
3284 ** --convert-eol Convert EOL style of the checkin to match
3285 ** the previous version's content. Does not
3286 ** modify the input file, only the checked-in
3287 ** content.
3288 ** --delta Prefer to generate a delta manifest, if
3289 ** able.
3290 ** --allow-new-file Allow addition of a new file this way.
3291 ** Disabled by default to avoid that case-
3292 ** sensitivity errors inadvertently lead to
@@ -3323,10 +3343,14 @@
3343 cinf.flags |= CIMINI_CONVERT_EOL;
3344 }
3345 if(find_option("delta",0,0)!=0){
3346 cinf.flags |= CIMINI_PREFER_DELTA;
3347 }
3348 if(find_option("delta2",0,0)!=0){
3349 /* Undocumented. For testing only. */
3350 cinf.flags |= CIMINI_PREFER_DELTA | CIMINI_STRONGLY_PREFER_DELTA;
3351 }
3352 if(find_option("allow-new-file",0,0)!=0){
3353 cinf.flags |= CIMINI_ALLOW_NEW_FILE;
3354 }
3355 db_find_and_open_repository(0, 0);
3356 verify_all_options();
3357

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button