changeset 6775:6adcc5c7c1f1

branching: merge with stable
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 14 Apr 2024 00:41:49 -0300
parents c6ff8ae8a752 (current diff) 564e3d3d9799 (diff)
children 8275a04db4ae
files .gitlab-ci.yml CHANGELOG hgext3rd/evolve/metadata.py hgext3rd/topic/__init__.py hgext3rd/topic/flow.py tests/test-namespaces.t
diffstat 9 files changed, 157 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/.gitlab-ci.yml	Mon Mar 18 14:01:40 2024 -0300
+++ b/.gitlab-ci.yml	Sun Apr 14 00:41:49 2024 -0300
@@ -31,8 +31,8 @@
         - (cd tests; ls -1 test-check-*.t > /tmp/check-tests.txt)
     script:
         - *prepare_hg
-        - ("$PYTHON" --version)
-        - (cd tests; set -x; HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" /ci/repos/mercurial/tests/run-tests.py --color=always $RUNTEST_ARGS)
+        - ($PYTHON --version)
+        - (cd tests; set -x; HGMODULEPOLICY="$TEST_HGMODULEPOLICY" $PYTHON /ci/repos/mercurial/tests/run-tests.py --color=always $RUNTEST_ARGS)
 
 checks-py3:
     <<: *runtests
@@ -56,7 +56,7 @@
     <<: *runtests
     variables:
         PY: py2
-        PYTHON: python2
+        PYTHON: prlimit --nofile=1024:1024 python2
         RUNTEST_ARGS: "--no-rust --blacklist /tmp/check-tests.txt"
         TEST_HGMODULEPOLICY: "c"
         HG_BRANCH: 'max(tag("re:^6\.1"))'
--- a/.hgtags	Mon Mar 18 14:01:40 2024 -0300
+++ b/.hgtags	Sun Apr 14 00:41:49 2024 -0300
@@ -109,3 +109,4 @@
 a625eb5acea4d682becd21759170306ab769afb2 11.1.0
 369e248b6312cc3b0777033a4632f2c9e18a0897 11.1.1
 c31c6638381080bc5905fad37545610fde3b98bc 11.1.2
+2d2da4f7742a0da2c2fbd5a95c48937720eeafd4 11.1.3
--- a/CHANGELOG	Mon Mar 18 14:01:40 2024 -0300
+++ b/CHANGELOG	Sun Apr 14 00:41:49 2024 -0300
@@ -7,6 +7,22 @@
   * evolve: remove legacy.py that could be used to "detect and convert
     prehistoric format of obsolete markers" (older than Mercurial 2.3)
 
+11.1.3 -- 2024-04-12
+--------------------
+
+topic (1.1.3)
+
+  * topic namespaces: add hg debug-default-topic-namespace command that can
+    list changesets with problematic topic namespaces (i.e. "none" and
+    "default") and rewrite them
+
+  * topic namespaces: new experimental.tns-reject-push config to make servers
+    reject pushes that contain changesets with any topic namespace in commit
+    extras
+
+  * topic namespaces: slightly change .hg/topic-namespace cleanup code to be
+    executed on acquiring a wlock instead of on reading .hg/topic-namespace
+
 11.1.2 -- 2024-03-03
 --------------------
 
--- a/debian/changelog	Mon Mar 18 14:01:40 2024 -0300
+++ b/debian/changelog	Sun Apr 14 00:41:49 2024 -0300
@@ -1,3 +1,9 @@
+mercurial-evolve (11.1.3-1) unstable; urgency=medium
+
+  * new upstream release
+
+ -- Anton Shestakov <av6@dwimlabs.net>  Fri, 12 Apr 2024 14:32:49 -0300
+
 mercurial-evolve (11.1.2-1) unstable; urgency=medium
 
   * new upstream release
--- a/hgext3rd/topic/__init__.py	Mon Mar 18 14:01:40 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Sun Apr 14 00:41:49 2024 -0300
@@ -296,6 +296,9 @@
 configitem(b'experimental', b'tns-default-pull-namespaces',
            default=configitems.dynamicdefault,
 )
+configitem(b'experimental', b'tns-reject-push',
+           default=False,
+)
 configitem(b'experimental', b'topic-mode.server',
            default=configitems.dynamicdefault,
 )
@@ -869,6 +872,13 @@
 
                 tr.addvalidator(b'000-reject-publish', _validate_publish)
 
+            if self.ui.configbool(b'experimental', b'tns-reject-push'):
+                def _validate_csets_with_tns(tr2):
+                    repo = reporef()
+                    flow.reject_csets_with_tns(repo, tr2)
+
+                tr.addvalidator(b'000-reject-csets-with-tns', _validate_csets_with_tns)
+
             def _validate_affected_tns(tr2):
                 repo = reporef()
                 assert repo is not None  # help pytype
@@ -1853,13 +1863,15 @@
     revs = repo.revs(b'not public() and not obsolete() and (%lr)', condition)
     if opts[b'clear']:
         with repo.wlock(), repo.lock(), repo.transaction(b'debug-default-topic-namespace'):
+            successors = {}
             for rev in revs:
-                _clear_tns_extras(ui, repo, rev)
+                _clear_tns_extras(ui, repo, rev, successors)
+            scmutil.cleanupnodes(repo, successors, b'debug-default-topic-namespace')
         return
     displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
     logcmdutil.displayrevs(ui, repo, revs, displayer, None)
 
-def _clear_tns_extras(ui, repo, rev):
+def _clear_tns_extras(ui, repo, rev, successors):
     ctx = repo[rev]
 
     if len(ctx.parents()) > 1:
@@ -1881,6 +1893,10 @@
 
     p1 = ctx.p1().node()
     p2 = ctx.p2().node()
+    if p1 in successors:
+        p1 = successors[p1][0]
+    if p2 in successors:
+        p2 = successors[p2][0]
     mc = context.memctx(repo,
                         (p1, p2),
                         ctx.description(),
@@ -1894,8 +1910,7 @@
     with repo.ui.configoverride(overrides, b'debug-default-topic-namespace'):
         newnode = repo.commitctx(mc)
 
-    replacements = {(ctx.node(),): (newnode,)}
-    scmutil.cleanupnodes(repo, replacements, b'debug-default-topic-namespace')
+    successors[ctx.node()] = (newnode,)
 
 @command(b'debug-parse-fqbn', commands.formatteropts, _(b'FQBN'), optionalrepo=True)
 def debugparsefqbn(ui, repo, fqbn, **opts):
--- a/hgext3rd/topic/flow.py	Mon Mar 18 14:01:40 2024 -0300
+++ b/hgext3rd/topic/flow.py	Sun Apr 14 00:41:49 2024 -0300
@@ -44,7 +44,8 @@
     untopiced = repo.revs(b'not public() and (%n:) - hidden() - topic()', startnode)
     if untopiced:
         num = len(untopiced)
-        fnode = repo[untopiced.first()].hex()[:10]
+        cl = repo.changelog
+        fnode = node.short(cl.node(untopiced.first()))
         if num == 1:
             msg = _(b"%s") % fnode
         else:
@@ -72,6 +73,29 @@
             msg += b' and %d others' % (len(published) - 1)
         raise error.Abort(msg)
 
+def reject_csets_with_tns(repo, tr):
+    """Reject the push if there are changesets with any topic namespace"""
+    if b'node' not in tr.hookargs: # no new revs
+        return
+
+    reject = repo.ui.config(b'experimental', b'tns-reject-push')
+    if not reject:
+        return
+
+    startnode = node.bin(tr.hookargs[b'node'])
+    repo = repo.unfiltered()
+    with_tns = repo.revs(b'not public() and extra("topic-namespace") and (%n:) - hidden()', startnode)
+    if with_tns:
+        num = len(with_tns)
+        cl = repo.changelog
+        fnode = node.short(cl.node(with_tns.first()))
+        if num == 1:
+            msg = _(b"%s") % fnode
+        else:
+            msg = _(b"%s and %d more") % (fnode, num - 1)
+        fullmsg = _(b"rejecting draft changesets with topic namespace: %s")
+        raise error.Abort(fullmsg % msg)
+
 def replacecheckpublish(orig, pushop):
     listkeys = exchange.listkeys
     repo = pushop.repo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-namespaces-reject.t	Sun Apr 14 00:41:49 2024 -0300
@@ -0,0 +1,80 @@
+Rejecting changesets with any topic namespaces during push
+
+  $ . "$TESTDIR/testlib/common.sh"
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > topic =
+  > [phases]
+  > publish = no
+  > [devel]
+  > tns-report-transactions = push
+  > [ui]
+  > logtemplate = "{rev}: {desc} {fqbn} ({phase})\n"
+  > EOF
+
+  $ hg init orig
+  $ hg clone orig clone -q
+
+  $ cd clone
+
+changesets without topic namespace are freely exchanged
+
+  $ echo apple > a
+  $ hg debug-topic-namespace --clear
+  $ hg topic apple
+  marked working directory as topic: apple
+  $ hg ci -qAm apple
+
+  $ hg log -r . -T '{rev}: {join(extras, " ")}\n'
+  0: branch=default topic=apple
+
+  $ hg push
+  pushing to * (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+
+changesets with topic namespaces are rejected when server configuration disallows
+
+  $ cat >> ../orig/.hg/hgrc << EOF
+  > [experimental]
+  > tns-reject-push = yes
+  > EOF
+
+  $ echo banana > b
+  $ hg debug-topic-namespace bob
+  marked working directory as topic namespace: bob
+  $ hg topic banana
+  $ hg ci -qAm 'banana'
+
+  $ hg push
+  pushing to $TESTTMP/orig
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  transaction abort!
+  rollback completed
+  abort: rejecting draft changesets with topic namespace: ed9751f04a18
+  [255]
+
+changesets with topic namespaces are only exchanged if server configuration allows
+
+  $ cat >> ../orig/.hg/hgrc << EOF
+  > [experimental]
+  > tns-reject-push = no
+  > EOF
+
+  $ hg push
+  pushing to $TESTTMP/orig
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  topic namespaces affected: bob
+  added 1 changesets with 1 changes to 1 files
+
+  $ cd ..
--- a/tests/test-namespaces.t	Mon Mar 18 14:01:40 2024 -0300
+++ b/tests/test-namespaces.t	Sun Apr 14 00:41:49 2024 -0300
@@ -324,17 +324,15 @@
   5:16d6061fce0c branch=stable topic-namespace=default
 
   $ hg debug-default-topic-namespace --none --default --clear
-  1 new orphan changesets
 
   $ hg debug-default-topic-namespace --none --default
 
+  $ hg evolve --config extensions.evolve= --list
+
   $ hg evolve --config extensions.evolve= --any
   update:[7] tns=default
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 68ef84f4b0a2
-  move:[7] tns=default
-  atop:[6] tns=none
-  working directory is now at ddeaa72064d4
+  working directory is now at 38c9ea9d27a7
 
   $ hg debug-default-topic-namespace --none --default
 
--- a/tests/test-topic-flow-reject-untopiced.t	Mon Mar 18 14:01:40 2024 -0300
+++ b/tests/test-topic-flow-reject-untopiced.t	Sun Apr 14 00:41:49 2024 -0300
@@ -75,7 +75,7 @@
   adding file changes
   transaction abort!
   rollback completed
-  abort: rejecting draft changesets: 4e8b0e0237
+  abort: rejecting draft changesets: 4e8b0e0237c6
   [255]
 
   $ hg push ../server -f
@@ -86,7 +86,7 @@
   adding file changes
   transaction abort!
   rollback completed
-  abort: rejecting draft changesets: 4e8b0e0237
+  abort: rejecting draft changesets: 4e8b0e0237c6
   [255]
 
 Grow the stack with more changesets having topic
@@ -121,7 +121,7 @@
   adding file changes
   transaction abort!
   rollback completed
-  abort: rejecting draft changesets: 4e8b0e0237
+  abort: rejecting draft changesets: 4e8b0e0237c6
   [255]
 
 Testing case when both experimental.topic-mode.server and
@@ -138,7 +138,7 @@
   adding file changes
   transaction abort!
   rollback completed
-  abort: rejecting draft changesets: 4e8b0e0237
+  abort: rejecting draft changesets: 4e8b0e0237c6
   [255]
 
 Turning the changeset public and testing push