Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 25764:22049b565d57
localrepo: provide workingctx by integer revision
This allows us to use the integer representation in revset. None doesn't
work well while computing revset because revset heavily depends on and
optimized for integer revisions.
Still repo[wdirrev].rev() is None, which means the canonical form of the
working-directory revision is None.
This patch doesn't add the case for the wdirid because we can't handle short
and ambiguous identifiers here. Perhaps, the wdirid will have to be handled
in the changelog layer.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 16 Aug 2014 13:25:45 +0900 |
parents | a69bb29b9638 |
children | 1f8287b41935 |
comparison
equal
deleted
inserted
replaced
25763:60c791592aa7 | 25764:22049b565d57 |
---|---|
2 # | 2 # |
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 from node import hex, nullid, short | 7 from node import hex, nullid, wdirrev, short |
8 from i18n import _ | 8 from i18n import _ |
9 import urllib | 9 import urllib |
10 import peer, changegroup, subrepo, pushkey, obsolete, repoview | 10 import peer, changegroup, subrepo, pushkey, obsolete, repoview |
11 import changelog, dirstate, filelog, manifest, context, bookmarks, phases | 11 import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
12 import lock as lockmod | 12 import lock as lockmod |
477 return nullid | 477 return nullid |
478 | 478 |
479 return dirstate.dirstate(self.vfs, self.ui, self.root, validate) | 479 return dirstate.dirstate(self.vfs, self.ui, self.root, validate) |
480 | 480 |
481 def __getitem__(self, changeid): | 481 def __getitem__(self, changeid): |
482 if changeid is None: | 482 if changeid is None or changeid == wdirrev: |
483 return context.workingctx(self) | 483 return context.workingctx(self) |
484 if isinstance(changeid, slice): | 484 if isinstance(changeid, slice): |
485 return [context.changectx(self, i) | 485 return [context.changectx(self, i) |
486 for i in xrange(*changeid.indices(len(self))) | 486 for i in xrange(*changeid.indices(len(self))) |
487 if i not in self.changelog.filteredrevs] | 487 if i not in self.changelog.filteredrevs] |