109 nodes = [head for head in partial[branch] |
109 nodes = [head for head in partial[branch] |
110 if repo.changelog.hasnode(head)] |
110 if repo.changelog.hasnode(head)] |
111 if not nodes: |
111 if not nodes: |
112 del partial[branch] |
112 del partial[branch] |
113 |
113 |
|
114 def updatecache(repo): |
|
115 repo = repo.unfiltered() # Until we get a smarter cache management |
|
116 cl = repo.changelog |
|
117 tip = cl.tip() |
|
118 if repo._branchcache is not None and repo._branchcachetip == tip: |
|
119 return |
|
120 |
|
121 oldtip = repo._branchcachetip |
|
122 if oldtip is None or oldtip not in cl.nodemap: |
|
123 partial, last, lrev = read(repo) |
|
124 else: |
|
125 lrev = cl.rev(oldtip) |
|
126 partial = repo._branchcache |
|
127 |
|
128 catip = repo._cacheabletip() |
|
129 # if lrev == catip: cache is already up to date |
|
130 # if lrev > catip: we have uncachable element in `partial` can't write |
|
131 # on disk |
|
132 if lrev < catip: |
|
133 ctxgen = (repo[r] for r in cl.revs(lrev + 1, catip)) |
|
134 update(repo, partial, ctxgen) |
|
135 write(repo, partial, cl.node(catip), catip) |
|
136 lrev = catip |
|
137 # If cacheable tip were lower than actual tip, we need to update the |
|
138 # cache up to tip. This update (from cacheable to actual tip) is not |
|
139 # written to disk since it's not cacheable. |
|
140 tiprev = len(repo) - 1 |
|
141 if lrev < tiprev: |
|
142 ctxgen = (repo[r] for r in cl.revs(lrev + 1, tiprev)) |
|
143 update(repo, partial, ctxgen) |
|
144 repo._branchcache = partial |
|
145 repo._branchcachetip = tip |