Patchwork [10,of,18,V2] localrepo: filter unknown nodes from the phasecache on destroyed

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 4, 2013, 1:04 a.m.
Message ID <9cc61b186ab76a50d1c8.1357261453@yamac.lan>
Download mbox | patch
Permalink /patch/379/
State Accepted
Commit 082d6929fd4dcaf0c6ae97e0589e5dcb083d1a4c
Headers show

Comments

Pierre-Yves David - Jan. 4, 2013, 1:04 a.m.
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1356106792 -3600
# Node ID 9cc61b186ab76a50d1c896351d08d55ebd4e6bb9
# Parent  733b35c15776bb62518cf3e544022d41e717b7d7
localrepo: filter unknown nodes from the phasecache on destroyed

When commit is followed by strip (qrefresh), phasecache contains nodes that were
removed from the changelog. Since phasecache is filecached with .hg/store/phaseroots
which doesn't change as a result of stripping, we have to filter it manually.

If we don't write it immediately, the next time it is read from disk the nodes
will be filtered again. That's what happened before, but there's no reason not
to write it immediately.

The change in test-keyword.t is caused by the above.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1423,10 +1423,22 @@  class localrepository(object):
                       if self.changelog.hasnode(node))
             cache = self._branchcaches[None]
             cache.update(self, ctxgen)
             cache.write(self)
 
+        # When one tries to:
+        # 1) destroy nodes thus calling this method (e.g. strip)
+        # 2) use phasecache somewhere (e.g. commit)
+        #
+        # then 2) will fail because the phasecache contains nodes that were
+        # removed. We can either remove phasecache from the filecache,
+        # causing it to reload next time it is accessed, or simply filter
+        # the removed nodes now and write the updated cache.
+        if '_phasecache' in self._filecache:
+            self._phasecache.filterunknown(self)
+            self._phasecache.write()
+
         # Ensure the persistent tag cache is updated.  Doing it now
         # means that the tag cache only has to worry about destroyed
         # heads immediately after a strip/rollback.  That in turn
         # guarantees that "cachetip == currenttip" (comparing both rev
         # and node) always means no nodes have been added or destroyed.
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -576,11 +576,10 @@  Copy and show added kwfiles
 Commit and show expansion in original and copy
 
   $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user at example.com>'
   c
    c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
-  removing unknown node 40a904bbbe4c from 1-phase boundary
   overwriting c expanding keywords
   committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
   $ cat a c
   expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
   do not process $Id:
@@ -747,11 +746,10 @@  Interrupted commit should not change sta
 
 Commit with multi-line message and custom expansion
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user at example.com>'
   a
-  removing unknown node 40a904bbbe4c from 1-phase boundary
   overwriting a expanding keywords
   committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
   $ rm log
 
 Stat, verify and show custom expansion (firstline)