# HG changeset patch # User Idan Kamara # Date 1324573967 -7200 # Node ID bd23bc72e6620cb6fc25df6567bad6ee6a2e1ab2 # Parent 4da6bb8abfcc1b47c50fd24bd65a886ed657674f client: add a convenience method __getitem__ to return a changectx diff -r 4da6bb8abfcc -r bd23bc72e662 hglib/client.py --- a/hglib/client.py Thu Dec 22 19:12:47 2011 +0200 +++ b/hglib/client.py Thu Dec 22 19:12:47 2011 +0200 @@ -1,5 +1,5 @@ import subprocess, os, struct, cStringIO, re -import hglib, error, util, templates, merge +import hglib, error, util, templates, merge, context from util import cmdbuilder @@ -1520,3 +1520,6 @@ self._version = tuple(v) return self._version + + def __getitem__(self, changeid): + return context.changectx(self, changeid) diff -r 4da6bb8abfcc -r bd23bc72e662 tests/test-context.py --- a/tests/test-context.py Thu Dec 22 19:12:47 2011 +0200 +++ b/tests/test-context.py Thu Dec 22 19:12:47 2011 +0200 @@ -13,7 +13,7 @@ self.append('c', 'c') rev1, node1 = self.client.commit('second', addremove=True) - ctx = context.changectx(self.client, node0) + ctx = self.client[node0] self.assertEquals(ctx.description(), 'first') self.assertEquals(str(ctx), node0[:12]) @@ -52,7 +52,7 @@ self.client.tag('tag', rev=node0) # tags are read on construction - self.assertEquals(context.changectx(self.client, node0).tags(), ['tag']) + self.assertEquals(self.client[node0].tags(), ['tag']) def test_construction(self): self.append('a', 'a')