Fossil SCM

Mini-checkin now pre-allocates some memory for the output manifest. Internal doc updates.

stephan 2020-05-01 05:38 UTC checkin-without-checkout
Commit bfe7750e94ca302bf99e22ec97bfaa0cbd18ddfaff77cbbc5bcab8b474d240a2
1 file changed +16 -11
+16 -11
--- src/checkin.c
+++ src/checkin.c
@@ -2874,11 +2874,13 @@
28742874
** If asDelta is true, F-cards will be handled as for a delta
28752875
** manifest, and the caller MUST have added a B-card to pOut before
28762876
** calling this.
28772877
**
28782878
** Returns 1 on success, 0 on error, and writes any error message to
2879
-** pErr (if it's not NULL).
2879
+** pErr (if it's not NULL). The only non-immediately-fatal/panic error
2880
+** is if pCI->filePerm is PERM_LNK or pCI would update a PERM_LNK
2881
+** in-repo file.
28802882
*/
28812883
static int create_manifest_mini_fcards( Blob * pOut,
28822884
CheckinMiniInfo * pCI,
28832885
int asDelta,
28842886
Blob * pErr){
@@ -2983,37 +2985,40 @@
29832985
assert(pCI->zFilename);
29842986
assert(pCI->zUser);
29852987
assert(pCI->zDate);
29862988
29872989
/* Potential TODOs include...
2988
- ** - Create a delta manifest, if possible/feasible, rather than a
2989
- ** baseline (done) even if pCI->pParent is a delta (not done).
2990
- ** - Maybe add support for tags. Those can be edited via /info page.
2991
- ** - Symlinks: if we're really in a checkout, handle commit/add of
2992
- ** symlinks like a normal commit would. For now we bail out if
2993
- ** told to handle a symlink because there would seem to be no(?)
2994
- ** sensible way to handle a symlink add/checkin without a
2995
- ** checkout.
2990
+ **
2991
+ ** - Maybe add support for tags. Those can be edited via /info page,
2992
+ ** and feel like YAGNI/feature creep for this purpose.
29962993
*/
29972994
blob_zero(pOut);
29982995
manifest_file_rewind(pCI->pParent) /* force load of baseline */;
2999
-
2996
+ /* Determine whether we want to create a delta manifest... */
30002997
if((CIMINI_PREFER_DELTA & pCI->flags)
30012998
&& ((CIMINI_STRONGLY_PREFER_DELTA & pCI->flags)
30022999
|| (pCI->pParent->pBaseline
30033000
? pCI->pParent->pBaseline
30043001
: pCI->pParent)->nFile > 15
30053002
/* 15 is arbitrary: don't create a delta when there is only a
3006
- ** tiny gain for doing so. */)
3003
+ ** tiny gain for doing so. That heuristic is not *quite*
3004
+ ** right, in that when we're deriving from another delta, we
3005
+ ** really should compare the F-card count between it and its
3006
+ ** baseline, and create a delta if the baseline has (say)
3007
+ ** twice or more as many F-cards as the previous delta. */)
30073008
&& !db_get_boolean("forbid-delta-manifests",0)
30083009
){
30093010
asDelta = 1;
30103011
blob_appendf(pOut, "B %s\n",
30113012
pCI->pParent->zBaseline
30123013
? pCI->pParent->zBaseline
30133014
: pCI->zParentUuid);
30143015
}
3016
+ blob_reserve(pOut, 1024 *
3017
+ (asDelta ? 2 : pCI->pParent->nFile/11+1
3018
+ /* In the fossil core repo, each 12-ish F-cards (on
3019
+ ** average) take up roughly 1kb */));
30153020
if(blob_size(&pCI->comment)!=0){
30163021
blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
30173022
}else{
30183023
blob_append(pOut, "C (no\\scomment)\n", 16);
30193024
}
30203025
--- src/checkin.c
+++ src/checkin.c
@@ -2874,11 +2874,13 @@
2874 ** If asDelta is true, F-cards will be handled as for a delta
2875 ** manifest, and the caller MUST have added a B-card to pOut before
2876 ** calling this.
2877 **
2878 ** Returns 1 on success, 0 on error, and writes any error message to
2879 ** pErr (if it's not NULL).
 
 
2880 */
2881 static int create_manifest_mini_fcards( Blob * pOut,
2882 CheckinMiniInfo * pCI,
2883 int asDelta,
2884 Blob * pErr){
@@ -2983,37 +2985,40 @@
2983 assert(pCI->zFilename);
2984 assert(pCI->zUser);
2985 assert(pCI->zDate);
2986
2987 /* Potential TODOs include...
2988 ** - Create a delta manifest, if possible/feasible, rather than a
2989 ** baseline (done) even if pCI->pParent is a delta (not done).
2990 ** - Maybe add support for tags. Those can be edited via /info page.
2991 ** - Symlinks: if we're really in a checkout, handle commit/add of
2992 ** symlinks like a normal commit would. For now we bail out if
2993 ** told to handle a symlink because there would seem to be no(?)
2994 ** sensible way to handle a symlink add/checkin without a
2995 ** checkout.
2996 */
2997 blob_zero(pOut);
2998 manifest_file_rewind(pCI->pParent) /* force load of baseline */;
2999
3000 if((CIMINI_PREFER_DELTA & pCI->flags)
3001 && ((CIMINI_STRONGLY_PREFER_DELTA & pCI->flags)
3002 || (pCI->pParent->pBaseline
3003 ? pCI->pParent->pBaseline
3004 : pCI->pParent)->nFile > 15
3005 /* 15 is arbitrary: don't create a delta when there is only a
3006 ** tiny gain for doing so. */)
 
 
 
 
3007 && !db_get_boolean("forbid-delta-manifests",0)
3008 ){
3009 asDelta = 1;
3010 blob_appendf(pOut, "B %s\n",
3011 pCI->pParent->zBaseline
3012 ? pCI->pParent->zBaseline
3013 : pCI->zParentUuid);
3014 }
 
 
 
 
3015 if(blob_size(&pCI->comment)!=0){
3016 blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
3017 }else{
3018 blob_append(pOut, "C (no\\scomment)\n", 16);
3019 }
3020
--- src/checkin.c
+++ src/checkin.c
@@ -2874,11 +2874,13 @@
2874 ** If asDelta is true, F-cards will be handled as for a delta
2875 ** manifest, and the caller MUST have added a B-card to pOut before
2876 ** calling this.
2877 **
2878 ** Returns 1 on success, 0 on error, and writes any error message to
2879 ** pErr (if it's not NULL). The only non-immediately-fatal/panic error
2880 ** is if pCI->filePerm is PERM_LNK or pCI would update a PERM_LNK
2881 ** in-repo file.
2882 */
2883 static int create_manifest_mini_fcards( Blob * pOut,
2884 CheckinMiniInfo * pCI,
2885 int asDelta,
2886 Blob * pErr){
@@ -2983,37 +2985,40 @@
2985 assert(pCI->zFilename);
2986 assert(pCI->zUser);
2987 assert(pCI->zDate);
2988
2989 /* Potential TODOs include...
2990 **
2991 ** - Maybe add support for tags. Those can be edited via /info page,
2992 ** and feel like YAGNI/feature creep for this purpose.
 
 
 
 
 
2993 */
2994 blob_zero(pOut);
2995 manifest_file_rewind(pCI->pParent) /* force load of baseline */;
2996 /* Determine whether we want to create a delta manifest... */
2997 if((CIMINI_PREFER_DELTA & pCI->flags)
2998 && ((CIMINI_STRONGLY_PREFER_DELTA & pCI->flags)
2999 || (pCI->pParent->pBaseline
3000 ? pCI->pParent->pBaseline
3001 : pCI->pParent)->nFile > 15
3002 /* 15 is arbitrary: don't create a delta when there is only a
3003 ** tiny gain for doing so. That heuristic is not *quite*
3004 ** right, in that when we're deriving from another delta, we
3005 ** really should compare the F-card count between it and its
3006 ** baseline, and create a delta if the baseline has (say)
3007 ** twice or more as many F-cards as the previous delta. */)
3008 && !db_get_boolean("forbid-delta-manifests",0)
3009 ){
3010 asDelta = 1;
3011 blob_appendf(pOut, "B %s\n",
3012 pCI->pParent->zBaseline
3013 ? pCI->pParent->zBaseline
3014 : pCI->zParentUuid);
3015 }
3016 blob_reserve(pOut, 1024 *
3017 (asDelta ? 2 : pCI->pParent->nFile/11+1
3018 /* In the fossil core repo, each 12-ish F-cards (on
3019 ** average) take up roughly 1kb */));
3020 if(blob_size(&pCI->comment)!=0){
3021 blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
3022 }else{
3023 blob_append(pOut, "C (no\\scomment)\n", 16);
3024 }
3025

Keyboard Shortcuts

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