##// END OF EJS Templates
branchmap: use a context manager when writing the branchmap...
marmoute -
r50098:f923bdd7 default
parent child Browse files
Show More
@@ -428,22 +428,22 b' class branchcache:'
428 self._delayed = True
428 self._delayed = True
429 return
429 return
430 try:
430 try:
431 f = repo.cachevfs(self._filename(repo), b"w", atomictemp=True)
431 filename = self._filename(repo)
432 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
432 with repo.cachevfs(filename, b"w", atomictemp=True) as f:
433 if self.filteredhash is not None:
433 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
434 cachekey.append(hex(self.filteredhash))
434 if self.filteredhash is not None:
435 f.write(b" ".join(cachekey) + b'\n')
435 cachekey.append(hex(self.filteredhash))
436 nodecount = 0
436 f.write(b" ".join(cachekey) + b'\n')
437 for label, nodes in sorted(self._entries.items()):
437 nodecount = 0
438 label = encoding.fromlocal(label)
438 for label, nodes in sorted(self._entries.items()):
439 for node in nodes:
439 label = encoding.fromlocal(label)
440 nodecount += 1
440 for node in nodes:
441 if node in self._closednodes:
441 nodecount += 1
442 state = b'c'
442 if node in self._closednodes:
443 else:
443 state = b'c'
444 state = b'o'
444 else:
445 f.write(b"%s %s %s\n" % (hex(node), state, label))
445 state = b'o'
446 f.close()
446 f.write(b"%s %s %s\n" % (hex(node), state, label))
447 repo.ui.log(
447 repo.ui.log(
448 b'branchcache',
448 b'branchcache',
449 b'wrote %s with %d labels and %d nodes\n',
449 b'wrote %s with %d labels and %d nodes\n',
General Comments 0
You need to be logged in to leave comments. Login now