Mercurial > python-hglib
changeset 95:bd23bc72e662
client: add a convenience method __getitem__ to return a changectx
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 22 Dec 2011 19:12:47 +0200 |
parents | 4da6bb8abfcc |
children | 9746227239e0 |
files | hglib/client.py tests/test-context.py |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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')