Re: [PATCH] fast-import: add ignore non-existent files option.
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Sep 1, 2008, 22:52 UTC
- Message-ID
- <94a0d4530809011552h59e476e0q9033f0b917288a8f@mail.gmail.com>
- In-Reply-To
- <20080901223802.GK7482@spearce.org>
On Tue, Sep 2, 2008 at 1:38 AM, Shawn O. Pearce <spearce@spearce.org> wrote:
Show 11 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> wrote: >> This is useful for SCMs that don't have proper changesets in each >> revision (monotone). > >> +--tolerant:: >> + Avoid fatal exceptions when actions are executed in non-existent >> + files. For example removing a file that is not there. >> + > > Yea. But I'm not sure --tolerant is the best name. --ignore-errors > or --treat-errors-as-warnings sounds better to me.
I initially named it --ignore-non-existent, but I thought the option was too specific.
--ignore-errors or --treat-errors-as-warnings imply all errors. It might make sense to always fail at certain errors, like 'mark not found'. I thought 'relaxed' or 'tolerant' would imply that only some errors will be allowed, not all.
Show 43 quoted lines
>> diff --git a/fast-import.c b/fast-import.c
>> index 7089e6f..01be3fa 100644
>> --- a/fast-import.c
>> +++ b/fast-import.c
>> @@ -345,6 +345,7 @@ static struct recent_command *rc_free;
>> static unsigned int cmd_save = 100;
>> static uintmax_t next_mark;
>> static struct strbuf new_data = STRBUF_INIT;
>> +static int tolerant;
>>
>> static void write_branch_report(FILE *rpt, struct branch *b)
>> {
>> @@ -1993,8 +1994,15 @@ static void file_change_cr(struct branch *b, int rename)
>> tree_content_remove(&b->branch_tree, s, &leaf);
>> else
>> tree_content_get(&b->branch_tree, s, &leaf);
>> - if (!leaf.versions[1].mode)
>> - die("Path %s not in branch", s);
>> + if (!leaf.versions[1].mode) {
>> + if (tolerant) {
>> + if (leaf.tree)
>> + release_tree_content_recursive(leaf.tree);
>> + warning("Path %s not in branch", s);
>> + return;
>> + } else
>> + die("Path %s not in branch", s);
>> + }
>> tree_content_set(&b->branch_tree, d,
>> leaf.versions[1].sha1,
>> leaf.versions[1].mode,
>> @@ -2447,6 +2455,8 @@ int main(int argc, const char **argv)
>> show_stats = 0;
>> else if (!strcmp(a, "--stats"))
>> show_stats = 1;
>> + else if (!strcmp(a, "--tolerant"))
>> + tolerant = 1;
>> else
>> die("unknown option %s", a);
>> }
>
> --
> Shawn.
>-- Felipe Contreras