[PATCH 1 of 4] revert: small refactoring in the way backup value are handled

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Sep 29 17:01:07 CDT 2014



On 09/29/2014 02:37 PM, Augie Fackler wrote:
> On Wed, Sep 24, 2014 at 10:37 PM, Pierre-Yves David
> <pierre-yves.david at ens-lyon.org> wrote:
>>
>>
>> On 09/24/2014 10:11 AM, Augie Fackler wrote:
>
>>> backup = _ALWAYS_BACKUP
>>> if opts.get('no_backup'):
>>>      backup = _SKIP_BACKUPS
>>>
>>> (Possible I'm reading this wrong, but I really don't think so.)
>>
>>
>> So I agree the current thing is confusing. But I disagree that using
>> symbolic constant will help readability here. If add a comment to clarify
>> and remove the other reference to numeric value in the function would you be
>> an happy panda?
>
> Maybe, but I doubt it. Can you show me what you have in mind, at least
> as a sketch?

The end result would looks like:

         # "constant" that convey the backup strategy.
         # All set to `discard` if `no-backup` is set do avoid checking
         # no_backup lower in the code.
         backup = 2  # unconditionnally do backup
         check = 1   # check if existing file differ from target
         discard = 0 # never do backup
         if opts.get('no_backup'):
             backup = check = discard

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list