Patchwork [5,of,5,V2] revert: drop now useless conditional in the backup check

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 8, 2014, 2:58 p.m.
Message ID <5417bc06f6b3f7f9ab18.1410188302@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5719/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 8, 2014, 2:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1409356262 -7200
#      Sat Aug 30 01:51:02 2014 +0200
# Node ID 5417bc06f6b3f7f9ab18c998dc08541ee825afaf
# Parent  f2199b928fd12e6b82387e7563e683e935df455c
revert: drop now useless conditional in the backup check

Now that we removed the (hopeless attempt) attempt to backup file we knew to be
missing in the target changesets, we can stop checking if the file exists in
the target changeset.
Augie Fackler - Sept. 9, 2014, 4:08 p.m.
On Mon, Sep 08, 2014 at 04:58:22PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1409356262 -7200
> #      Sat Aug 30 01:51:02 2014 +0200
> # Node ID 5417bc06f6b3f7f9ab18c998dc08541ee825afaf
> # Parent  f2199b928fd12e6b82387e7563e683e935df455c
> revert: drop now useless conditional in the backup check

Series looks reasonable, queued.

>
> Now that we removed the (hopeless attempt) attempt to backup file we knew to be
> missing in the target changesets, we can stop checking if the file exists in
> the target changeset.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2549,12 +2549,12 @@ def revert(ui, repo, ctx, parents, *pats
>              for table, (xlist, msg), dobackup in disptable:
>                  if abs not in table:
>                      continue
>                  if xlist is not None:
>                      xlist.append(abs)
> -                    if (dobackup and os.path.lexists(target) and
> -                        abs in ctx and repo[None][abs].cmp(ctx[abs])):
> +                    if (dobackup and os.path.lexists(target)
> +                        and repo[None][abs].cmp(ctx[abs])):
>                          bakname = "%s.orig" % rel
>                          ui.note(_('saving current version of %s as %s\n') %
>                                  (rel, bakname))
>                          if not opts.get('dry_run'):
>                              util.rename(target, bakname)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2549,12 +2549,12 @@  def revert(ui, repo, ctx, parents, *pats
             for table, (xlist, msg), dobackup in disptable:
                 if abs not in table:
                     continue
                 if xlist is not None:
                     xlist.append(abs)
-                    if (dobackup and os.path.lexists(target) and
-                        abs in ctx and repo[None][abs].cmp(ctx[abs])):
+                    if (dobackup and os.path.lexists(target)
+                        and repo[None][abs].cmp(ctx[abs])):
                         bakname = "%s.orig" % rel
                         ui.note(_('saving current version of %s as %s\n') %
                                 (rel, bakname))
                         if not opts.get('dry_run'):
                             util.rename(target, bakname)