"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hgext/remotenames.py" between
mercurial-5.8.tar.gz and mercurial-5.8.1.tar.gz

About: Mercurial is a Source (Version) Control Management system designed for efficient handling of very large distributed projects.

remotenames.py  (mercurial-5.8):remotenames.py  (mercurial-5.8.1)
skipping to change at line 104 skipping to change at line 104
""" """
def __init__(self, kind, repo): def __init__(self, kind, repo):
self.cache = {} self.cache = {}
self.potentialentries = {} self.potentialentries = {}
self._kind = kind # bookmarks or branches self._kind = kind # bookmarks or branches
self._repo = repo self._repo = repo
self.loaded = False self.loaded = False
def _load(self): def _load(self):
""" Read the remotenames file, store entries matching selected kind """ """Read the remotenames file, store entries matching selected kind"""
self.loaded = True self.loaded = True
repo = self._repo repo = self._repo
for node, rpath, rname in logexchange.readremotenamefile( for node, rpath, rname in logexchange.readremotenamefile(
repo, self._kind repo, self._kind
): ):
name = rpath + b'/' + rname name = rpath + b'/' + rname
self.potentialentries[name] = (node, rpath, name) self.potentialentries[name] = (node, rpath, name)
def _resolvedata(self, potentialentry): def _resolvedata(self, potentialentry):
""" Check that the node for potentialentry exists and return it """ """Check that the node for potentialentry exists and return it"""
if not potentialentry in self.potentialentries: if not potentialentry in self.potentialentries:
return None return None
node, remote, name = self.potentialentries[potentialentry] node, remote, name = self.potentialentries[potentialentry]
repo = self._repo repo = self._repo
binnode = bin(node) binnode = bin(node)
# if the node doesn't exist, skip it # if the node doesn't exist, skip it
try: try:
repo.changelog.rev(binnode) repo.changelog.rev(binnode)
except LookupError: except LookupError:
return None return None
skipping to change at line 162 skipping to change at line 162
if key in self.cache: if key in self.cache:
return self.cache[key] return self.cache[key]
val = self._resolvedata(key) val = self._resolvedata(key)
if val is not None: if val is not None:
self.cache[key] = val self.cache[key] = val
return val return val
else: else:
return None return None
def keys(self): def keys(self):
""" Get a list of bookmark or branch names """ """Get a list of bookmark or branch names"""
if not self.loaded: if not self.loaded:
self._load() self._load()
return self.potentialentries.keys() return self.potentialentries.keys()
def iteritems(self): def iteritems(self):
""" Iterate over (name, node) tuples """ """Iterate over (name, node) tuples"""
if not self.loaded: if not self.loaded:
self._load() self._load()
for k, vtup in pycompat.iteritems(self.potentialentries): for k, vtup in pycompat.iteritems(self.potentialentries):
yield (k, [bin(vtup[0])]) yield (k, [bin(vtup[0])])
items = iteritems items = iteritems
class remotenames(object): class remotenames(object):
skipping to change at line 191 skipping to change at line 191
methods to access that state in convenient ways. Remotenames are lazy methods to access that state in convenient ways. Remotenames are lazy
loaded. Whenever client code needs to ensure the freshest copy of loaded. Whenever client code needs to ensure the freshest copy of
remotenames, use the `clearnames` method to force an eventual load. remotenames, use the `clearnames` method to force an eventual load.
""" """
def __init__(self, repo, *args): def __init__(self, repo, *args):
self._repo = repo self._repo = repo
self.clearnames() self.clearnames()
def clearnames(self): def clearnames(self):
""" Clear all remote names state """ """Clear all remote names state"""
self.bookmarks = lazyremotenamedict(b"bookmarks", self._repo) self.bookmarks = lazyremotenamedict(b"bookmarks", self._repo)
self.branches = lazyremotenamedict(b"branches", self._repo) self.branches = lazyremotenamedict(b"branches", self._repo)
self._invalidatecache() self._invalidatecache()
def _invalidatecache(self): def _invalidatecache(self):
self._nodetobmarks = None self._nodetobmarks = None
self._nodetobranch = None self._nodetobranch = None
self._hoisttonodes = None self._hoisttonodes = None
self._nodetohoists = None self._nodetohoists = None
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)