Patchwork [2,of,2,stable,v2] changelog: use headrevsfiltered

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 26, 2014, 11:32 a.m.
Message ID <49ab00d49aa7e7d30086.1414323178@localhost.localdomain>
Download mbox | patch
Permalink /patch/6469/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 26, 2014, 11:32 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1414322052 -3600
#      Sun Oct 26 12:14:12 2014 +0100
# Branch stable
# Node ID 49ab00d49aa7e7d300863c5e79a2951b3b582427
# Parent  b47beb587afc679188a3060d84cec4d6f38bbfb8
changelog: use headrevsfiltered

2b5940f64750 introduced use of the new filtering headrevs C implementation. It
caught TypeError to detect when to fall back to the implementation that was
compatible with old extensions. That method was however not reliable.

Instead, use the new headrevsfiltered function when passing a filter. It will
reliably fail with AttributeError when an old extension that predates
headrevsfiltered is used.
Pierre-Yves David - Oct. 26, 2014, 12:27 p.m.
On 10/26/2014 12:32 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1414322052 -3600
> #      Sun Oct 26 12:14:12 2014 +0100
> # Branch stable
> # Node ID 49ab00d49aa7e7d300863c5e79a2951b3b582427
> # Parent  b47beb587afc679188a3060d84cec4d6f38bbfb8
> changelog: use headrevsfiltered

Looks good to me and pushed to the clowncopter.

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -172,10 +172,10 @@  class changelog(revlog.revlog):
     def headrevs(self):
         if self.filteredrevs:
             try:
-                return self.index.headrevs(self.filteredrevs)
-            # AttributeError covers non-c-extension environments.
-            # TypeError allows us work with old c extensions.
-            except (AttributeError, TypeError):
+                return self.index.headrevsfiltered(self.filteredrevs)
+            # AttributeError covers non-c-extension environments and
+            # old c extensions without filter handling.
+            except AttributeError:
                 return self._headrevs()
 
         return super(changelog, self).headrevs()