Patchwork [4,of,4] revert: drop `lexist` check in the backup logic

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 10, 2014, 1:05 a.m.
Message ID <7bfda6350dc7cbc50204.1410311141@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5763/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 10, 2014, 1:05 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1409357429 -7200
#      Sat Aug 30 02:10:29 2014 +0200
# Node ID 7bfda6350dc7cbc50204212a22ed198cb15097fb
# Parent  10052be213bf4471ce3df9fc87e2382c7c472209
revert: drop `lexist` check in the backup logic

We are no longer trying to backup file that does not exists on disk. This check
can be safely dropped.
Augie Fackler - Sept. 10, 2014, 7:10 p.m.
On Wed, Sep 10, 2014 at 02:05:41AM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1409357429 -7200
> #      Sat Aug 30 02:10:29 2014 +0200
> # Node ID 7bfda6350dc7cbc50204212a22ed198cb15097fb
> # Parent  10052be213bf4471ce3df9fc87e2382c7c472209
> revert: drop `lexist` check in the backup logic

series queued with english tweaks

>
> We are no longer trying to backup file that does not exists on disk. This check
> can be safely dropped.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2574,12 +2574,11 @@ 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 wctx[abs].cmp(ctx[abs])):
> +                    if (dobackup and wctx[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
@@ -2574,12 +2574,11 @@  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 wctx[abs].cmp(ctx[abs])):
+                    if (dobackup and wctx[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)