changeset 6546:30d0d3d92c8d stable

topic: properly process revbranchcache before sending it to peers (issue6841)
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 25 Aug 2023 16:01:28 -0300
parents 9148051f3712
children ba8354de1c4d
files hgext3rd/topic/discovery.py tests/test-check-sdist.t tests/test-topic-issue6841.t
diffstat 3 files changed, 70 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py	Thu Jul 20 13:42:06 2023 -0300
+++ b/hgext3rd/topic/discovery.py	Fri Aug 25 16:01:28 2023 -0300
@@ -354,6 +354,12 @@
         # to do the conversion
         return orig(self, rev, **kwargs)
 
+def wrapaddpartrevbranchcache(orig, repo, bundler, outgoing):
+    """making sure we send rev-branch-cache that only has bare branches"""
+    overrides = {(b'_internal', b'tns-disable-fqbn'): True}
+    with repo.ui.configoverride(overrides, b'topic-namespaces'):
+        orig(repo, bundler, outgoing)
+
 def modsetup(ui):
     """run at uisetup time to install all destinations wrapping"""
     extensions.wrapfunction(discovery, '_headssummary', _headssummary)
@@ -376,5 +382,6 @@
         extensions.wrapfunction(bundle2, 'handlecheckupdatedheads', handlecheckheads)
         bundle2.handlecheckupdatedheads.params = frozenset()
         bundle2.parthandlermapping[b'check:updated-heads'] = bundle2.handlecheckupdatedheads
+    extensions.wrapfunction(bundle2, 'addpartrevbranchcache', wrapaddpartrevbranchcache)
     extensions.wrapfunction(exchange, '_pushb2phases', _pushb2phases)
     exchange.b2partsgenmapping[b'phase'] = exchange._pushb2phases
--- a/tests/test-check-sdist.t	Thu Jul 20 13:42:06 2023 -0300
+++ b/tests/test-check-sdist.t	Fri Aug 25 16:01:28 2023 -0300
@@ -35,7 +35,7 @@
 
   $ tar -tzf hg-evolve-*.tar.gz | sed 's|^hg-evolve-[^/]*/||' | sort > files
   $ wc -l files
-  361 files
+  362 files
   $ fgrep debian files
   tests/test-check-debian.t
   $ fgrep __init__.py files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-topic-issue6841.t	Fri Aug 25 16:01:28 2023 -0300
@@ -0,0 +1,62 @@
+New clones shouldn't have topics in any on-disk caches (issue6841)
+https://bz.mercurial-scm.org/show_bug.cgi?id=6841
+
+  $ . "$TESTDIR/testlib/common.sh"
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > topic =
+  > [phases]
+  > publish = no
+  > [ui]
+  > ssh = "$PYTHON" "$RUNTESTDIR/dummyssh"
+  > EOF
+
+  $ hg init orig
+  $ hg clone orig publishing -q
+  $ cat >> publishing/.hg/hgrc << EOF
+  > [phases]
+  > publish = yes
+  > EOF
+
+  $ cd orig
+  $ mkcommit ROOT
+  $ hg push ../publishing
+  pushing to ../publishing
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+
+  $ echo foo > foo
+  $ hg topic topic-foo
+  marked working directory as topic: topic-foo
+  $ hg ci -qAm foo
+
+  $ cd ..
+
+cloning via ssh to use wire protocol
+
+  $ hg clone ssh://user@dummy/orig new-clone -q
+  $ cd new-clone
+
+on-disk caches are using bare branch names only
+
+  $ f -H .hg/cache/rbc-names-v1
+  .hg/cache/rbc-names-v1:
+  0000: 64 65 66 61 75 6c 74                            |default|
+  $ grep topic-foo .hg/cache/*
+  [1]
+
+and pushing works fine
+
+  $ hg push ssh://user@dummy/publishing
+  pushing to ssh://user@dummy/publishing
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+
+  $ cd ..