Patchwork [2,of,2] histedit: use samefile function from cmdutil

login
register
mail settings
Submitter Hannes Oldenburg
Date Aug. 21, 2016, 9:41 a.m.
Message ID <1d7a0008d92207f95761.1471772467@localhost.localdomain>
Download mbox | patch
Permalink /patch/16370/
State Accepted
Headers show

Comments

Hannes Oldenburg - Aug. 21, 2016, 9:41 a.m.
# HG changeset patch
# User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
# Date 1471766602 0
#      Sun Aug 21 08:03:22 2016 +0000
# Node ID 1d7a0008d92207f9576186a099fe1059966a636e
# Parent  72c8a126a490dcb86903b31632cb69f0803484d8
histedit: use samefile function from cmdutil

Replace usage of inefficient samefile function in collapse with a call to
cmdutil.samefile().
Pierre-Yves David - Aug. 22, 2016, 12:24 p.m.
On 08/21/2016 11:41 AM, Hannes Oldenburg wrote:
> # HG changeset patch
> # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> # Date 1471766602 0
> #      Sun Aug 21 08:03:22 2016 +0000
> # Node ID 1d7a0008d92207f9576186a099fe1059966a636e
> # Parent  72c8a126a490dcb86903b31632cb69f0803484d8
> histedit: use samefile function from cmdutil
>
> Replace usage of inefficient samefile function in collapse with a call to
> cmdutil.samefile().

Pushed, thanks.

Patch

diff -r 72c8a126a490 -r 1d7a0008d922 hgext/histedit.py
--- a/hgext/histedit.py	Sun Aug 21 08:00:18 2016 +0000
+++ b/hgext/histedit.py	Sun Aug 21 08:03:22 2016 +0000
@@ -573,18 +573,7 @@ 
     copied = copies.pathcopies(base, last)
 
     # prune files which were reverted by the updates
-    def samefile(f):
-        if f in last.manifest():
-            a = last.filectx(f)
-            if f in base.manifest():
-                b = base.filectx(f)
-                return (a.data() == b.data()
-                        and a.flags() == b.flags())
-            else:
-                return False
-        else:
-            return f not in base.manifest()
-    files = [f for f in files if not samefile(f)]
+    files = [f for f in files if not cmdutil.samefile(f, last, base)]
     # commit version of these files as defined by head
     headmf = last.manifest()
     def filectxfn(repo, ctx, path):