diff -r 967ac37f3d45 -r 160efb559f67 mercurial/sparse.py --- a/mercurial/sparse.py Sun Jul 09 15:11:19 2017 +0200 +++ b/mercurial/sparse.py Fri Jul 07 11:51:10 2017 -0700 @@ -478,3 +478,19 @@ dirstate.normallookup(file) return added, dropped, lookup + +def aftercommit(repo, node): + """Perform actions after a working directory commit.""" + # This function is called unconditionally, even if sparse isn't + # enabled. + ctx = repo[node] + + profiles = patternsforrev(repo, ctx.rev())[2] + + # profiles will only have data if sparse is enabled. + if set(profiles) & set(ctx.files()): + origstatus = repo.status() + origsparsematch = matcher(repo) + refreshwdir(repo, origstatus, origsparsematch, force=True) + + prunetemporaryincludes(repo)