Patchwork [2,of,8] filectx: remove dependencies on filerev

login
register
mail settings
Submitter Durham Goode
Date May 31, 2013, 5:19 p.m.
Message ID <3f547fa7afcace328277.1370020784@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1684/
State Accepted
Commit bc82abe500a90ad056cd9fd4fabdd84a4a5a2ebf
Headers show

Comments

Durham Goode - May 31, 2013, 5:19 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1369967361 25200
#      Thu May 30 19:29:21 2013 -0700
# Node ID 3f547fa7afcace32827789deb6865b789970f158
# Parent  d6d28e9ca7f60bf791f0b9226804f9010441d88f
filectx: remove dependencies on filerev

Removing dependencies on filectx.filerev() makes it easier to create a filelog
implementation that doesn't have rev numbers.
Durham Goode - June 11, 2013, 12:03 a.m.
On 5/31/13 10:19 AM, "Durham Goode" <durham@fb.com> wrote:

># HG changeset patch
># User Durham Goode <durham@fb.com>
># Date 1369967361 25200
>#      Thu May 30 19:29:21 2013 -0700
># Node ID 3f547fa7afcace32827789deb6865b789970f158
># Parent  d6d28e9ca7f60bf791f0b9226804f9010441d88f
>filectx: remove dependencies on filerev
>
>Removing dependencies on filectx.filerev() makes it easier to create a
>filelog
>implementation that doesn't have rev numbers.
>
>diff --git a/mercurial/context.py b/mercurial/context.py
>--- a/mercurial/context.py
>+++ b/mercurial/context.py
>@@ -677,7 +677,7 @@
> 
>         # use linkrev to find the first changeset where self appeared
>         if self.rev() != self.linkrev():
>-            base = self.filectx(self.filerev())
>+            base = self.filectx(self.filenode())
>         else:
>             base = self
> 
>@@ -746,7 +746,7 @@
>         # prime the ancestor cache for the working directory
>         acache = {}
>         for c in (self, fc2):
>-            if c._filerev is None:
>+            if c.filenode() is None:
>                 pl = [(n.path(), n.filenode()) for n in c.parents()]
>                 acache[(c._path, None)] = pl
> 

I looked into whether these might hurt the fast path.

Line 677: Since self.linkrev() is called immediately before, the index
entry should already be in memory, so self.filenode() won't cause a disk
hit.

Line 746: 15 lines below this change we are guaranteed to call
self._filenode and fc2._filenode, so my change doesn't introduce any extra
disk hit here either.


Matt, does that ease your concerns over perf here?  I looked at patch #1
in this series (about nullid vs nullrev), and I can abandon that patch and
handle that case internally in my extension.
Matt Mackall - June 12, 2013, 9:07 p.m.
On Fri, 2013-05-31 at 10:19 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1369967361 25200
> #      Thu May 30 19:29:21 2013 -0700
> # Node ID 3f547fa7afcace32827789deb6865b789970f158
> # Parent  d6d28e9ca7f60bf791f0b9226804f9010441d88f
> filectx: remove dependencies on filerev

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -677,7 +677,7 @@ 
 
         # use linkrev to find the first changeset where self appeared
         if self.rev() != self.linkrev():
-            base = self.filectx(self.filerev())
+            base = self.filectx(self.filenode())
         else:
             base = self
 
@@ -746,7 +746,7 @@ 
         # prime the ancestor cache for the working directory
         acache = {}
         for c in (self, fc2):
-            if c._filerev is None:
+            if c.filenode() is None:
                 pl = [(n.path(), n.filenode()) for n in c.parents()]
                 acache[(c._path, None)] = pl