equal
deleted
inserted
replaced
7 |
7 |
8 from node import bin, hex, nullid, nullrev |
8 from node import bin, hex, nullid, nullrev |
9 import encoding |
9 import encoding |
10 import util |
10 import util |
11 |
11 |
|
12 def _filename(repo): |
|
13 """name of a branchcache file for a given repo""" |
|
14 return "cache/branchheads" |
|
15 |
12 def read(repo): |
16 def read(repo): |
13 try: |
17 try: |
14 f = repo.opener("cache/branchheads") |
18 f = repo.opener(_filename(repo)) |
15 lines = f.read().split('\n') |
19 lines = f.read().split('\n') |
16 f.close() |
20 f.close() |
17 except (IOError, OSError): |
21 except (IOError, OSError): |
18 return branchcache() |
22 return branchcache() |
19 |
23 |
115 return False |
119 return False |
116 |
120 |
117 |
121 |
118 def write(self, repo): |
122 def write(self, repo): |
119 try: |
123 try: |
120 f = repo.opener("cache/branchheads", "w", atomictemp=True) |
124 f = repo.opener(_filename(repo), "w", atomictemp=True) |
121 cachekey = [hex(self.tipnode), str(self.tiprev)] |
125 cachekey = [hex(self.tipnode), str(self.tiprev)] |
122 if self.filteredhash is not None: |
126 if self.filteredhash is not None: |
123 cachekey.append(hex(self.filteredhash)) |
127 cachekey.append(hex(self.filteredhash)) |
124 f.write(" ".join(cachekey) + '\n') |
128 f.write(" ".join(cachekey) + '\n') |
125 for label, nodes in self.iteritems(): |
129 for label, nodes in self.iteritems(): |