Mercurial > hg
comparison mercurial/revlog.py @ 2560:c35694df7b13
revlog: handle integer arguments to lookup
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 28 Jun 2006 15:49:33 -0500 |
parents | 6ff82ec1f4b8 |
children | 494f7787d8ee |
comparison
equal
deleted
inserted
replaced
2501:b73552a00b20 | 2560:c35694df7b13 |
---|---|
741 continue | 741 continue |
742 return c | 742 return c |
743 | 743 |
744 def lookup(self, id): | 744 def lookup(self, id): |
745 """locate a node based on revision number or subset of hex nodeid""" | 745 """locate a node based on revision number or subset of hex nodeid""" |
746 if type(id) == type(0): | |
747 rev = id | |
748 if rev < 0: rev = self.count() + rev | |
749 if rev < 0 or rev >= self.count(): return None | |
750 return self.node(rev) | |
746 try: | 751 try: |
747 rev = int(id) | 752 rev = int(id) |
748 if str(rev) != id: raise ValueError | 753 if str(rev) != id: raise ValueError |
749 if rev < 0: rev = self.count() + rev | 754 if rev < 0: rev = self.count() + rev |
750 if rev < 0 or rev >= self.count(): raise ValueError | 755 if rev < 0 or rev >= self.count(): raise ValueError |