Mercurial > hg
comparison mercurial/context.py @ 6741:5918e2b79859
context: simplify changeid logic
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 26 Jun 2008 13:46:31 -0500 |
parents | 7239e06e58e9 |
children | 2d54e7c1e69d |
comparison
equal
deleted
inserted
replaced
6740:b148e9099133 | 6741:5918e2b79859 |
---|---|
10 import ancestor, bdiff, revlog, util, os, errno | 10 import ancestor, bdiff, revlog, util, os, errno |
11 | 11 |
12 class changectx(object): | 12 class changectx(object): |
13 """A changecontext object makes access to data related to a particular | 13 """A changecontext object makes access to data related to a particular |
14 changeset convenient.""" | 14 changeset convenient.""" |
15 def __init__(self, repo, changeid=None): | 15 def __init__(self, repo, changeid=''): |
16 """changeid is a revision number, node, or tag""" | 16 """changeid is a revision number, node, or tag""" |
17 if changeid == '': | |
18 changeid = '.' | |
17 self._repo = repo | 19 self._repo = repo |
18 | |
19 if not changeid and changeid != 0: | |
20 p1, p2 = self._repo.dirstate.parents() | |
21 self._rev = self._repo.changelog.rev(p1) | |
22 self._node = p1 | |
23 return | |
24 | |
25 self._node = self._repo.lookup(changeid) | 20 self._node = self._repo.lookup(changeid) |
26 self._rev = self._repo.changelog.rev(self._node) | 21 self._rev = self._repo.changelog.rev(self._node) |
27 | 22 |
28 def __str__(self): | 23 def __str__(self): |
29 return short(self.node()) | 24 return short(self.node()) |