changeset 6050:bec2d792ceae

branching: merge stable into default
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 12 Oct 2021 09:57:52 +0300
parents 441e7e773d6c (current diff) 6c67219ce779 (diff)
children 0118b5e4010c be2008649675
files CHANGELOG hgext3rd/topic/__init__.py tests/test-check-sdist.t
diffstat 3 files changed, 53 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Thu Oct 07 21:50:29 2021 +0300
+++ b/CHANGELOG	Tue Oct 12 09:57:52 2021 +0300
@@ -20,6 +20,8 @@
 
 topic (0.23.0)
 
+  * topic: don't cache .topic() of memctx instances, as that could produce
+    KeyError: b'topic' during some rewrite operations (issue6500)
   * topic: drop old code for working with amends on ancient hg versions (~3.6)
 
 10.3.3 -- 2021-08-13
@@ -28,7 +30,10 @@
   * evolve: compatibility with Mercurial 5.9
   * fold: make sure to save commit messages in last-message.txt, also affects
     metaedit (issue6549)
-  * touch: fix `hg touch` on merge commits
+  * touch/fold/metaedit/rewind: no longer lose changes from merge commits
+    (issue6416). As a consequence (for technical reasons), when run with
+    Mercurial 5.5 and earlier, these commands now require there to be no
+    unresolved conflicts.
 
 topic (0.22.3)
 
@@ -42,11 +47,6 @@
 
   * next: remove duplicated targets when updating from an unstable changeset
   * evolve: use "served" repo filter to guess what the server will publish
-  * touch/fold/metaedit/rewind: no longer lose changes from merge commits
-    (issue6416). As a consequence (for technical reasons), when run with
-    Mercurial 5.5 and earlier, these commands now require there to be no
-    unresolved conflicts.
-
 
 topic (0.22.2)
 
--- a/hgext3rd/topic/__init__.py	Thu Oct 07 21:50:29 2021 +0300
+++ b/hgext3rd/topic/__init__.py	Tue Oct 12 09:57:52 2021 +0300
@@ -297,6 +297,9 @@
     # topic loaded, but not enabled (eg: multiple repo in the same process)
     if cache is None:
         return b''
+    if self.rev() is None:
+        # don't cache volatile ctx instances that aren't stored on-disk yet
+        return self.extra().get(constants.extrakey, b'')
     topic = cache.get(self.rev())
     if topic is None:
         topic = self.extra().get(constants.extrakey, b'')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-topic-issue6500.t	Tue Oct 12 09:57:52 2021 +0300
@@ -0,0 +1,44 @@
+KeyError: b'topic' on history-rewriting commands (issue6500)
+https://bz.mercurial-scm.org/show_bug.cgi?id=6500
+
+  $ . $TESTDIR/testlib/common.sh
+
+Making sure we're not caching .topic() results for memctx or anything else that's not stored on-disk
+
+  $ hg init issue6500-caching-memctx
+  $ cd issue6500-caching-memctx
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > evolve =
+  > topic =
+  > EOF
+
+for this test we need 2 changesets with amend_source, one with topic and one without
+
+  $ hg topics foo
+  marked working directory as topic: foo
+  $ echo apple > a
+  $ hg ci -qAm 'apple'
+  $ echo apricot > a
+  $ hg ci --amend -m 'apricot'
+
+not using `hg topics --clear -r .` here because that would remove amend_source, see _changetopics()
+
+  $ hg topics --clear
+  $ hg ci --amend -m 'no foo apricot'
+
+  $ hg log --hidden -r 1+2 -T '{rev}: {join(extras, " ")}\n'
+  1: amend_source=* branch=default topic=foo (glob)
+  2: amend_source=* branch=default (glob)
+
+creating and handling 2 memctx instances (based on 1 and then 2) should work
+
+  $ hg touch --hidden -r 1+2 --duplicate
+  switching to topic foo
+
+make sure extras stay the same
+
+  $ hg log --hidden -r 3+4 -T '{rev}: {join(extras, " ")}\n'
+  3: __touch-noise__=* amend_source=* branch=default topic=foo (glob)
+  4: __touch-noise__=* amend_source=* branch=default (glob)