# HG changeset patch # User Matt Mackall # Date 1214610283 18000 # Node ID 403682f1c67880b02d0732c7be7d7ec2df137306 # Parent f67d1468ac50a88eea7ac2804f646ee3ddbe0c41 context: add __int__ and hex methods diff -r f67d1468ac50 -r 403682f1c678 mercurial/context.py --- a/mercurial/context.py Fri Jun 27 18:28:45 2008 -0500 +++ b/mercurial/context.py Fri Jun 27 18:44:43 2008 -0500 @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from node import nullid, nullrev, short +from node import nullid, nullrev, short, hex from i18n import _ import ancestor, bdiff, revlog, util, os, errno @@ -23,6 +23,9 @@ def __str__(self): return short(self.node()) + def __int__(self): + return self.rev() + def __repr__(self): return "" % str(self) @@ -79,6 +82,7 @@ def rev(self): return self._rev def node(self): return self._node + def hex(self): return hex(self._node) def user(self): return self._changeset[1] def date(self): return self._changeset[2] def files(self): return self._changeset[3] @@ -693,6 +697,9 @@ def __str__(self): return str(self._parents[0]) + "+" + def __int__(self): + return self._rev + def __nonzero__(self): return True