Patchwork [3,of,5] localrepo: provide workingctx by integer revision

login
register
mail settings
Submitter Yuya Nishihara
Date July 9, 2015, 2:42 p.m.
Message ID <3002f049bad78c12323d.1436452971@mimosa>
Download mbox | patch
Permalink /patch/9934/
State Accepted
Headers show

Comments

Yuya Nishihara - July 9, 2015, 2:42 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1408163145 -32400
#      Sat Aug 16 13:25:45 2014 +0900
# Node ID 3002f049bad78c12323dc78c862c6771fb7f511e
# Parent  574befe4cc3059e156fc459b716c980be5553fcc
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.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -4,7 +4,7 @@ 
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
-from node import hex, nullid, short
+from node import hex, nullid, wdirrev, short
 from i18n import _
 import urllib
 import peer, changegroup, subrepo, pushkey, obsolete, repoview
@@ -479,7 +479,7 @@  class localrepository(object):
         return dirstate.dirstate(self.vfs, self.ui, self.root, validate)
 
     def __getitem__(self, changeid):
-        if changeid is None:
+        if changeid is None or changeid == wdirrev:
             return context.workingctx(self)
         if isinstance(changeid, slice):
             return [context.changectx(self, i)