Patchwork changelog: document the 'readpending' method

login
register
mail settings
Submitter Pierre-Yves David
Date June 20, 2015, 6:33 a.m.
Message ID <4ee6cb9d4164b381a983.1434781994@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9726/
State Accepted
Headers show

Comments

Pierre-Yves David - June 20, 2015, 6:33 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1411960723 25200
#      Sun Sep 28 20:18:43 2014 -0700
# Node ID 4ee6cb9d4164b381a98359815eaf615a3e207c7e
# Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
changelog: document the 'readpending' method

I happen to have spend some time understanding this logic, so I'm leaving
documentation for the next poor fellow.
Matt Mackall - June 20, 2015, 8 p.m.
On Fri, 2015-06-19 at 23:33 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1411960723 25200
> #      Sun Sep 28 20:18:43 2014 -0700
> # Node ID 4ee6cb9d4164b381a98359815eaf615a3e207c7e
> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
> changelog: document the 'readpending' method

Queued for default (with substantial editing), thanks.
Pierre-Yves David - June 20, 2015, 10:11 p.m.
On 06/20/2015 01:00 PM, Matt Mackall wrote:
> On Fri, 2015-06-19 at 23:33 -0700, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1411960723 25200
>> #      Sun Sep 28 20:18:43 2014 -0700
>> # Node ID 4ee6cb9d4164b381a98359815eaf615a3e207c7e
>> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
>> changelog: document the 'readpending' method
>
> Queued for default (with substantial editing), thanks.

The new wording, "and extend the main index" seems wrong. The main index 
is not "extended" it is just replaced by a full copy. The pending file 
is not extending it either, it contains the full copy of the original + 
the extra data. (at least this is how I eventually get to understand 
this function).
Matt Mackall - June 25, 2015, 9:31 p.m.
On Sat, 2015-06-20 at 15:11 -0700, Pierre-Yves David wrote:
> 
> On 06/20/2015 01:00 PM, Matt Mackall wrote:
> > On Fri, 2015-06-19 at 23:33 -0700, Pierre-Yves David wrote:
> >> # HG changeset patch
> >> # User Pierre-Yves David <pierre-yves.david@fb.com>
> >> # Date 1411960723 25200
> >> #      Sun Sep 28 20:18:43 2014 -0700
> >> # Node ID 4ee6cb9d4164b381a98359815eaf615a3e207c7e
> >> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
> >> changelog: document the 'readpending' method
> >
> > Queued for default (with substantial editing), thanks.
> 
> The new wording, "and extend the main index" seems wrong. The main index 
> is not "extended" it is just replaced by a full copy. The pending file 
> is not extending it either, it contains the full copy of the original + 
> the extra data. (at least this is how I eventually get to understand 
> this function).

Derp, you're right.
Pierre-Yves David - June 26, 2015, 12:15 a.m.
On 06/25/2015 02:31 PM, Matt Mackall wrote:
> On Sat, 2015-06-20 at 15:11 -0700, Pierre-Yves David wrote:
>>
>> On 06/20/2015 01:00 PM, Matt Mackall wrote:
>>> On Fri, 2015-06-19 at 23:33 -0700, Pierre-Yves David wrote:
>>>> # HG changeset patch
>>>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>>>> # Date 1411960723 25200
>>>> #      Sun Sep 28 20:18:43 2014 -0700
>>>> # Node ID 4ee6cb9d4164b381a98359815eaf615a3e207c7e
>>>> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
>>>> changelog: document the 'readpending' method
>>>
>>> Queued for default (with substantial editing), thanks.
>>
>> The new wording, "and extend the main index" seems wrong. The main index
>> is not "extended" it is just replaced by a full copy. The pending file
>> is not extending it either, it contains the full copy of the original +
>> the extra data. (at least this is how I eventually get to understand
>> this function).
>
> Derp, you're right.

I'll send a follow up with the re-wording.

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -257,10 +257,22 @@  class changelog(revlog.revlog):
         self._divert = False
         # split when we're done
         self.checkinlinesize(tr)
 
     def readpending(self, file):
+        """read index data from a "pending" file
+
+        During transaction, the actual changesets' data are still stored in the
+        main file, but are not referenced in the official index. Instead a
+        "pending" index is written by the transaction logic. If this function
+        is running, we are likely in a subprocess invoked in a hook. The
+        subprocess is informed that it is within a transaction and need to
+        access it's content.
+
+        This function will read all the index data out of the pending file and
+        overide the local ones. We just overide a handful of key index related
+        data because everything else is still relevant."""
         if not self.opener.exists(file):
             return # no pending data for changelog
         r = revlog.revlog(self.opener, file)
         self.index = r.index
         self.nodemap = r.nodemap