mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
namespaces: add bookmarks to the names data structure
This marks the first use of abstracting our different types of named objects (bookmarks, tags, branches, etc.) and upcoming patches will use this to simplify logic.
This commit is contained in:
parent
d9e45fae2c
commit
80fbfb49cc
@ -18,6 +18,7 @@ import tags as tagsmod
|
||||
from lock import release
|
||||
import weakref, errno, os, time, inspect
|
||||
import branchmap, pathutil
|
||||
import namespaces
|
||||
propertycache = util.propertycache
|
||||
filecache = scmutil.filecache
|
||||
|
||||
@ -297,6 +298,9 @@ class localrepository(object):
|
||||
# - bookmark changes
|
||||
self.filteredrevcache = {}
|
||||
|
||||
# generic mapping between names and nodes
|
||||
self.names = namespaces.namespaces(self)
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
@ -35,6 +35,11 @@ class namespaces(object):
|
||||
self._names = util.sortdict()
|
||||
self._repo = weakref.ref(repo)
|
||||
|
||||
# we need current mercurial named objects (bookmarks, tags, and
|
||||
# branches) to be initialized somewhere, so that place is here
|
||||
self.addnamespace("bookmarks",
|
||||
lambda repo, name: tolist(repo._bookmarks.get(name)))
|
||||
|
||||
@property
|
||||
def repo(self):
|
||||
return self._repo()
|
||||
|
@ -8,7 +8,7 @@
|
||||
# GNU General Public License version 2 or any later version.
|
||||
|
||||
from i18n import _
|
||||
import changelog, byterange, url, error
|
||||
import changelog, byterange, url, error, namespaces
|
||||
import localrepo, manifest, util, scmutil, store
|
||||
import urllib, urllib2, errno, os
|
||||
|
||||
@ -106,6 +106,8 @@ class statichttprepository(localrepo.localrepository):
|
||||
self.vfs = self.opener
|
||||
self._phasedefaults = []
|
||||
|
||||
self.names = namespaces.namespaces(self)
|
||||
|
||||
try:
|
||||
requirements = scmutil.readrequires(self.opener, self.supported)
|
||||
except IOError, inst:
|
||||
|
Loading…
Reference in New Issue
Block a user