comparison mercurial/localrepo.py @ 9671:9471d9a900b4

transfer branchmap branch names over the wire in utf-8
author Henrik Stuart <henrik.stuart@edlund.dk>
date Mon, 26 Oct 2009 13:37:39 +0100
parents ceb0f59e1327
children 863ba2ea1f0b
comparison
equal deleted inserted replaced
9670:7d56b6ffef72 9671:9471d9a900b4
317 self._updatebranchcache(partial, lrev+1, tiprev+1) 317 self._updatebranchcache(partial, lrev+1, tiprev+1)
318 self._writebranchcache(partial, self.changelog.tip(), tiprev) 318 self._writebranchcache(partial, self.changelog.tip(), tiprev)
319 319
320 return partial 320 return partial
321 321
322 def branchmap(self): 322 def lbranchmap(self):
323 tip = self.changelog.tip() 323 tip = self.changelog.tip()
324 if self.branchcache is not None and self._branchcachetip == tip: 324 if self.branchcache is not None and self._branchcachetip == tip:
325 return self.branchcache 325 return self.branchcache
326
327 partial = self.branchmap()
328
329 # the branch cache is stored on disk as UTF-8, but in the local
330 # charset internally
331 for k, v in partial.iteritems():
332 self.branchcache[encoding.tolocal(k)] = v
333 return self.branchcache
334
335 def branchmap(self):
336 tip = self.changelog.tip()
337 if self._ubranchcache is not None and self._branchcachetip == tip:
338 return self._ubranchcache
326 339
327 oldtip = self._branchcachetip 340 oldtip = self._branchcachetip
328 self._branchcachetip = tip 341 self._branchcachetip = tip
329 if self.branchcache is None: 342 if self.branchcache is None:
330 self.branchcache = {} # avoid recursion in changectx 343 self.branchcache = {} # avoid recursion in changectx
338 351
339 self._branchtags(partial, lrev) 352 self._branchtags(partial, lrev)
340 # this private cache holds all heads (not just tips) 353 # this private cache holds all heads (not just tips)
341 self._ubranchcache = partial 354 self._ubranchcache = partial
342 355
343 # the branch cache is stored on disk as UTF-8, but in the local 356 return self._ubranchcache
344 # charset internally
345 for k, v in partial.iteritems():
346 self.branchcache[encoding.tolocal(k)] = v
347 return self.branchcache
348
349 357
350 def branchtags(self): 358 def branchtags(self):
351 '''return a dict where branch names map to the tipmost head of 359 '''return a dict where branch names map to the tipmost head of
352 the branch, open heads come before closed''' 360 the branch, open heads come before closed'''
353 bt = {} 361 bt = {}
354 for bn, heads in self.branchmap().iteritems(): 362 for bn, heads in self.lbranchmap().iteritems():
355 head = None 363 head = None
356 for i in range(len(heads)-1, -1, -1): 364 for i in range(len(heads)-1, -1, -1):
357 h = heads[i] 365 h = heads[i]
358 if 'close' not in self.changelog.read(h)[5]: 366 if 'close' not in self.changelog.read(h)[5]:
359 head = h 367 head = h
1166 If start is not None, return only heads reachable from start. 1174 If start is not None, return only heads reachable from start.
1167 If closed is True, return heads that are marked as closed as well. 1175 If closed is True, return heads that are marked as closed as well.
1168 ''' 1176 '''
1169 if branch is None: 1177 if branch is None:
1170 branch = self[None].branch() 1178 branch = self[None].branch()
1171 branches = self.branchmap() 1179 branches = self.lbranchmap()
1172 if branch not in branches: 1180 if branch not in branches:
1173 return [] 1181 return []
1174 # the cache returns heads ordered lowest to highest 1182 # the cache returns heads ordered lowest to highest
1175 bheads = list(reversed(branches[branch])) 1183 bheads = list(reversed(branches[branch]))
1176 if start is not None: 1184 if start is not None: