Fossil SCM
Mini-checkin now pre-allocates some memory for the output manifest. Internal doc updates.
Commit
bfe7750e94ca302bf99e22ec97bfaa0cbd18ddfaff77cbbc5bcab8b474d240a2
Parent
972cc5f9ac23a8d…
1 file changed
+16
-11
+16
-11
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2874,11 +2874,13 @@ | ||
| 2874 | 2874 | ** If asDelta is true, F-cards will be handled as for a delta |
| 2875 | 2875 | ** manifest, and the caller MUST have added a B-card to pOut before |
| 2876 | 2876 | ** calling this. |
| 2877 | 2877 | ** |
| 2878 | 2878 | ** 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. | |
| 2880 | 2882 | */ |
| 2881 | 2883 | static int create_manifest_mini_fcards( Blob * pOut, |
| 2882 | 2884 | CheckinMiniInfo * pCI, |
| 2883 | 2885 | int asDelta, |
| 2884 | 2886 | Blob * pErr){ |
| @@ -2983,37 +2985,40 @@ | ||
| 2983 | 2985 | assert(pCI->zFilename); |
| 2984 | 2986 | assert(pCI->zUser); |
| 2985 | 2987 | assert(pCI->zDate); |
| 2986 | 2988 | |
| 2987 | 2989 | /* 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. | |
| 2996 | 2993 | */ |
| 2997 | 2994 | blob_zero(pOut); |
| 2998 | 2995 | manifest_file_rewind(pCI->pParent) /* force load of baseline */; |
| 2999 | - | |
| 2996 | + /* Determine whether we want to create a delta manifest... */ | |
| 3000 | 2997 | if((CIMINI_PREFER_DELTA & pCI->flags) |
| 3001 | 2998 | && ((CIMINI_STRONGLY_PREFER_DELTA & pCI->flags) |
| 3002 | 2999 | || (pCI->pParent->pBaseline |
| 3003 | 3000 | ? pCI->pParent->pBaseline |
| 3004 | 3001 | : pCI->pParent)->nFile > 15 |
| 3005 | 3002 | /* 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. */) | |
| 3007 | 3008 | && !db_get_boolean("forbid-delta-manifests",0) |
| 3008 | 3009 | ){ |
| 3009 | 3010 | asDelta = 1; |
| 3010 | 3011 | blob_appendf(pOut, "B %s\n", |
| 3011 | 3012 | pCI->pParent->zBaseline |
| 3012 | 3013 | ? pCI->pParent->zBaseline |
| 3013 | 3014 | : pCI->zParentUuid); |
| 3014 | 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 */)); | |
| 3015 | 3020 | if(blob_size(&pCI->comment)!=0){ |
| 3016 | 3021 | blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment)); |
| 3017 | 3022 | }else{ |
| 3018 | 3023 | blob_append(pOut, "C (no\\scomment)\n", 16); |
| 3019 | 3024 | } |
| 3020 | 3025 |
| --- 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 |