Patchwork clfilter: stronger detection of filtered changeset in changectx.__init__

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 16, 2013, 4:26 a.m.
Message ID <58a0530087d99f06fdab.1358310388@yamac.lan>
Download mbox | patch
Permalink /patch/638/
State Accepted
Commit 5d6ee2494f635d14e060e307c2804f0cb5868d1f
Headers show

Comments

Pierre-Yves David - Jan. 16, 2013, 4:26 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1358310071 -3600
# Node ID 58a0530087d99f06fdabd16590254cc305718dc2
# Parent  66cec3c2ee00abbcaa0813eb01f34f7123eb3b49
clfilter: stronger detection of filtered changeset in changectx.__init__

We previously let some IndexError spill out of this function.

A new tests is added to check the command that spotted the error.
Matt Mackall - Jan. 17, 2013, 6:45 p.m.
On Wed, 2013-01-16 at 05:26 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1358310071 -3600
> # Node ID 58a0530087d99f06fdabd16590254cc305718dc2
> # Parent  66cec3c2ee00abbcaa0813eb01f34f7123eb3b49
> clfilter: stronger detection of filtered changeset in changectx.__init__

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -65,11 +65,11 @@  class changectx(object):
             if r < 0 or r >= l:
                 raise ValueError
             self._rev = r
             self._node = repo.changelog.node(r)
             return
-        except (ValueError, OverflowError):
+        except (ValueError, OverflowError, IndexError):
             pass
 
         if len(changeid) == 40:
             try:
                 self._node = bin(changeid)
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -184,10 +184,27 @@  check that summary does not report them
   branch: default
   commit: (clean)
   update: 3 new changesets, 4 branch heads (merge)
   remote: 3 outgoing
 
+check that various commands work well with filtering
+
+  $ hg tip
+  changeset:   5:5601fb93a350
+  tag:         tip
+  parent:      1:7c3bad9141dc
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add new_3_c
+  
+  $ hg log -r 6
+  abort: unknown revision '6'!
+  [255]
+  $ hg log -r 4
+  abort: unknown revision '4'!
+  [255]
+
 Check that public changeset are not accounted as obsolete:
 
   $ hg --hidden phase --public 2
   $ hg --config 'extensions.graphlog=' glog
   @  changeset:   5:5601fb93a350