diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
index 236bb604dc39438327db8551ced7ad7b9c37e487_bWVyY3VyaWFsL2xvY2FscmVwby5weQ==..ce0ad184f489edb292034130b0d69e117f0ee390_bWVyY3VyaWFsL2xvY2FscmVwby5weQ== 100644
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1304,6 +1304,9 @@
         # tag cache retrieval" case to work.
         self.invalidatecaches()
 
+        # Discard all cache entries to force reloading everything.
+        self._filecache.clear()
+
     def walk(self, match, node=None):
         '''
         walk recursively through the directory tree or a given
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
index 236bb604dc39438327db8551ced7ad7b9c37e487_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnB5..ce0ad184f489edb292034130b0d69e117f0ee390_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnB5 100644
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -200,6 +200,16 @@
     os.system('hg phase -r . -p')
     runcommand(server, ['phase', '-r', '.'])
 
+def rollback(server):
+    readchannel(server)
+    runcommand(server, ['phase', '-r', '.', '-p'])
+    f = open('a', 'ab')
+    f.write('a\n')
+    f.close()
+    runcommand(server, ['commit', '-Am.'])
+    runcommand(server, ['rollback'])
+    runcommand(server, ['phase', '-r', '.'])
+
 if __name__ == '__main__':
     os.system('hg init')
 
@@ -219,3 +229,4 @@
     check(bookmarks)
     check(tagscache)
     check(setphase)
+    check(rollback)
diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out
index 236bb604dc39438327db8551ced7ad7b9c37e487_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnB5Lm91dA==..ce0ad184f489edb292034130b0d69e117f0ee390_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnB5Lm91dA== 100644
--- a/tests/test-commandserver.py.out
+++ b/tests/test-commandserver.py.out
@@ -134,3 +134,14 @@
 3: draft
  runcommand phase -r .
 3: public
+no phases changed
+
+testing rollback:
+
+ runcommand phase -r . -p
+ runcommand commit -Am.
+ runcommand rollback
+repository tip rolled back to revision 3 (undo commit)
+working directory now based on revision 3
+ runcommand phase -r .
+3: public