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

Augie Fackler raf at durin42.com
Wed Sep 24 10:31:07 CDT 2014


On Fri, Sep 19, 2014 at 06:05:00PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1409358507 -7200
> #      Sat Aug 30 02:28:27 2014 +0200
> # Node ID c7bf7274d2184c47fa0988f054b24d1b2b3416cd
> # Parent  5e16fe6fdd32124c3295db5ec40b076084cc5bd4
> revert: small refactoring in the way backup value are handled
>
> The current backup value may have two different values:
>
>   1. Do not try to do backup
>   2. Do backup if applicable
>
> We are about to move to:
>
>   1. Do not try to do backup
>   2. Do backup if applicable
>   3. Do backup in all cases
>
> So we change the current values to make room for the new one.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2620,12 +2620,14 @@ def revert(ui, repo, ctx, parents, *pats
>                     'unknown': (None, _('file not managed: %s\n')),
>                    }
>
>
>          # should we do a backup?
> -        backup = not opts.get('no_backup')
> -        discard = False
> +        backup = 2

Is there something evil and magic about 2 in this context? Why isn't
it true?

(probably missing something outside the diff context, but that
probably suggests this wants a symbolic constant instead of 2 as a
magic value.)

> +        discard = 0
> +        if opts.get('no_backup'):
> +            backup = 0
>
>          disptable = (
>              # dispatch table:
>              #   file state
>              #   action
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list