changeset 16116:ce0ad184f489 stable

localrepo: clear _filecache on rollback (issue3261) Files are being replaced by rollback but the corresponding data in localrepo isn't actually updated for things like bookmarks, phases, etc. Then when rollback is done, the cache is updated thinking it has the most up-to-date data, where in fact it is still pre-rollback. We clear _filecache to force everything to be recreated.
author Idan Kamara <idankk86@gmail.com>
date Thu, 16 Feb 2012 01:21:34 +0200
parents 236bb604dc39
children 6ecf5fb2a475
files mercurial/localrepo.py tests/test-commandserver.py tests/test-commandserver.py.out
diffstat 3 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Feb 15 20:02:35 2012 +0200
+++ b/mercurial/localrepo.py	Thu Feb 16 01:21:34 2012 +0200
@@ -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
--- a/tests/test-commandserver.py	Wed Feb 15 20:02:35 2012 +0200
+++ b/tests/test-commandserver.py	Thu Feb 16 01:21:34 2012 +0200
@@ -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)
--- a/tests/test-commandserver.py.out	Wed Feb 15 20:02:35 2012 +0200
+++ b/tests/test-commandserver.py.out	Thu Feb 16 01:21:34 2012 +0200
@@ -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