comparison mercurial/localrepo.py @ 4209:dbc3846c09a1

Merge with -stable, fix small test failure
author Matt Mackall <mpm@selenic.com>
date Wed, 14 Mar 2007 01:26:09 -0500
parents b5d1eaade333 0b48e3985765
children 5ccbc0be6cdb
comparison
equal deleted inserted replaced
4203:bd9b84b9a84b 4209:dbc3846c09a1
13 import os, revlog, time, util 13 import os, revlog, time, util
14 14
15 class localrepository(repo.repository): 15 class localrepository(repo.repository):
16 capabilities = ('lookup', 'changegroupsubset') 16 capabilities = ('lookup', 'changegroupsubset')
17 supported = ('revlogv1', 'store') 17 supported = ('revlogv1', 'store')
18 branchcache_features = ('unnamed',)
19 18
20 def __del__(self): 19 def __del__(self):
21 self.transhandle = None 20 self.transhandle = None
22 def __init__(self, parentui, path=None, create=0): 21 def __init__(self, parentui, path=None, create=0):
23 repo.repository.__init__(self) 22 repo.repository.__init__(self)
393 return self.branchcache 392 return self.branchcache
394 393
395 def _readbranchcache(self): 394 def _readbranchcache(self):
396 partial = {} 395 partial = {}
397 try: 396 try:
398 f = self.opener("branches.cache") 397 f = self.opener("branch.cache")
399 lines = f.read().split('\n') 398 lines = f.read().split('\n')
400 f.close() 399 f.close()
401 features = lines.pop(0).strip()
402 if not features.startswith('features: '):
403 raise ValueError(_('branch cache: no features specified'))
404 features = features.split(' ', 1)[1].split()
405 missing_features = []
406 for feature in self.branchcache_features:
407 try:
408 features.remove(feature)
409 except ValueError, inst:
410 missing_features.append(feature)
411 if missing_features:
412 raise ValueError(_('branch cache: missing features: %s')
413 % ', '.join(missing_features))
414 if features:
415 raise ValueError(_('branch cache: unknown features: %s')
416 % ', '.join(features))
417 last, lrev = lines.pop(0).split(" ", 1) 400 last, lrev = lines.pop(0).split(" ", 1)
418 last, lrev = bin(last), int(lrev) 401 last, lrev = bin(last), int(lrev)
419 if not (lrev < self.changelog.count() and 402 if not (lrev < self.changelog.count() and
420 self.changelog.node(lrev) == last): # sanity check 403 self.changelog.node(lrev) == last): # sanity check
421 # invalidate the cache 404 # invalidate the cache
432 partial, last, lrev = {}, nullid, nullrev 415 partial, last, lrev = {}, nullid, nullrev
433 return partial, last, lrev 416 return partial, last, lrev
434 417
435 def _writebranchcache(self, branches, tip, tiprev): 418 def _writebranchcache(self, branches, tip, tiprev):
436 try: 419 try:
437 f = self.opener("branches.cache", "w") 420 f = self.opener("branch.cache", "w")
438 f.write(" features: %s\n" % ' '.join(self.branchcache_features))
439 f.write("%s %s\n" % (hex(tip), tiprev)) 421 f.write("%s %s\n" % (hex(tip), tiprev))
440 for label, node in branches.iteritems(): 422 for label, node in branches.iteritems():
441 f.write("%s %s\n" % (hex(node), label)) 423 f.write("%s %s\n" % (hex(node), label))
442 except IOError: 424 except IOError:
443 pass 425 pass
757 raise util.Abort(_('branch name not in UTF-8!')) 739 raise util.Abort(_('branch name not in UTF-8!'))
758 else: 740 else:
759 branchname = "" 741 branchname = ""
760 742
761 if use_dirstate: 743 if use_dirstate:
762 oldname = c1[5].get("branch", "") # stored in UTF-8 744 oldname = c1[5].get("branch") # stored in UTF-8
763 if not commit and not remove and not force and p2 == nullid and \ 745 if not commit and not remove and not force and p2 == nullid and \
764 branchname == oldname: 746 branchname == oldname:
765 self.ui.status(_("nothing changed\n")) 747 self.ui.status(_("nothing changed\n"))
766 return None 748 return None
767 749