D6312: branchcache: update the filteredhash if we update the tiprev

Yuya Nishihara yuya at tcha.org
Sun Apr 28 04:36:56 EDT 2019


>          if ntiprev > self.tiprev:
>              self.tiprev = ntiprev
>              self.tipnode = cl.node(ntiprev)
> +            self.filteredhash = scmutil.filteredhash(repo, self.tiprev)
>  
>          if not self.validfor(repo):
>              # cache key are not valid anymore

and update `self.filteredhash` later again, which smells. Instead, shouldn't
we check the validity first, and take the fast path only if it was valid?

```
if self.validfor(repo):  # was valid, can take fast path
    self.tiprev = ntiprev
    self.tipnode = cl.node(ntiprev)
else:  # bad luck, recompute tiprev/tipnode
    ...
self.filteredhash = scmutil.filteredhash(repo, self.tiprev)
```


More information about the Mercurial-devel mailing list