From 00c159e07f835f574bf4a152ca16bf47b0a2e895 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Rivera?= <rene.rivera@disbelief.com>
Date: Wed, 12 Jun 2024 23:16:48 -0500
Subject: [PATCH 1/6] Start a 5.2.1 patch release.

---
 doc/src/history.adoc    | 2 ++
 src/build/version.jam   | 2 +-
 src/engine/patchlevel.h | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/src/history.adoc b/doc/src/history.adoc
index 6959c10dfd..812e368cf0 100644
--- a/doc/src/history.adoc
+++ b/doc/src/history.adoc
@@ -1,6 +1,8 @@
 [[b2.history]]
 = History
 
+== Version 5.2.1
+
 == Version 5.2.0
 
 Many fixes in this release from regular contributors Nikita and Dmitry. There
diff --git a/src/build/version.jam b/src/build/version.jam
index 7a1866e70d..674df90dc5 100644
--- a/src/build/version.jam
+++ b/src/build/version.jam
@@ -10,7 +10,7 @@ import numbers ;
 # Mirror engine JAM_VERSION
 .major = 5 ;
 .minor = 2 ;
-.patch = 0 ;
+.patch = 1 ;
 
 
 rule build ( )
diff --git a/src/engine/patchlevel.h b/src/engine/patchlevel.h
index 1341bbbcb3..3fba174185 100644
--- a/src/engine/patchlevel.h
+++ b/src/engine/patchlevel.h
@@ -14,4 +14,4 @@ Distributed under the Boost Software License, Version 1.0.
 
 #define VERSION_MAJOR 5
 #define VERSION_MINOR 2
-#define VERSION_PATCH 0
+#define VERSION_PATCH 1

From b07f0b22723f7a2f97a8af2efbd0d27f07afb062 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Rivera?= <rene.rivera@disbelief.com>
Date: Wed, 12 Jun 2024 23:18:08 -0500
Subject: [PATCH 2/6] Revert "exception-handling=off should define
 _HAS_EXCEPTIONS=0 for Dinkumware/MSSTL"

This reverts commit 376470fadd3ecad2b5cf5aa86a261281d479567c.
---
 src/tools/msvc.jam        |  1 -
 test/feature_exception.py | 26 --------------------------
 test/test_all.py          |  1 -
 3 files changed, 28 deletions(-)
 delete mode 100644 test/feature_exception.py

diff --git a/src/tools/msvc.jam b/src/tools/msvc.jam
index f5becbdd4f..5f304c807e 100644
--- a/src/tools/msvc.jam
+++ b/src/tools/msvc.jam
@@ -1965,7 +1965,6 @@ local rule register-toolset-really ( )
     toolset.flags msvc.compile C++FLAGS  <exception-handling>on/<asynch-exceptions>off/<extern-c-nothrow>on : /EHsc ;
     toolset.flags msvc.compile C++FLAGS  <exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>off : /EHa ;
     toolset.flags msvc.compile C++FLAGS  <exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>on : /EHac ;
-    toolset.flags msvc.compile C++FLAGS  <exception-handling>off : -D_HAS_EXCEPTIONS=0 ;
 
     toolset.flags msvc.compile C++FLAGS  <cxxstd>14 : "/std:c++14" ;
     toolset.flags msvc.compile C++FLAGS  <cxxstd>17 : "/std:c++17" ;
diff --git a/test/feature_exception.py b/test/feature_exception.py
deleted file mode 100644
index 8e065d887a..0000000000
--- a/test/feature_exception.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright Nikita Kniazev
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
-
-import BoostBuild
-
-
-def test_basic():
-    with BoostBuild.Tester(use_test_config=False) as t:
-        t.write('Jamroot.jam', 'obj test : test.cpp ;\n')
-        t.write('test.cpp', 'int main() { try { throw 0; } catch (int) {} }\n')
-        t.run_build_system(['exception-handling=on', 'warnings-as-errors=on'])
-        t.run_build_system(['exception-handling=off', 'warnings-as-errors=on'], status=1)
-
-
-def test_stdlib():
-    with BoostBuild.Tester(use_test_config=False) as t:
-        t.write('Jamroot.jam', 'obj test : test.cpp ;\n')
-        t.write('test.cpp', '#include <iostream>\nint main() { std::cout << "Hello!"; }\n')
-        t.run_build_system(['exception-handling=off', 'warnings-as-errors=on'])
-
-
-test_basic()
-test_stdlib()
diff --git a/test/test_all.py b/test/test_all.py
index cd4def137b..24b234f91e 100755
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -298,7 +298,6 @@ def reorder_tests(tests, first_test):
          "expansion",
          "explicit",
          "feature_cxxflags",
-         "feature_exception",
          "feature_implicit_dependency",
          "feature_relevant",
          "feature_suppress_import_lib",

From 957e37007e9bec4216c9fa4e52398a2742354355 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Rivera?= <rene.rivera@disbelief.com>
Date: Wed, 12 Jun 2024 23:24:33 -0500
Subject: [PATCH 3/6] Note for the patch revert of has expcetions define.

---
 doc/src/history.adoc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/src/history.adoc b/doc/src/history.adoc
index 812e368cf0..8735a5ae8a 100644
--- a/doc/src/history.adoc
+++ b/doc/src/history.adoc
@@ -3,6 +3,12 @@
 
 == Version 5.2.1
 
+This patch reverts the change to define `_HAS_EXCEPTIONS=0` for Dinkumware
+std library. It has the undesired effect of changing the ABI. It's better for
+user code to handle the conbination of turning off exceptions while treating
+warnings as errors, and getting warnings/errors from the std library by having
+the users silence the warning themselves.
+
 == Version 5.2.0
 
 Many fixes in this release from regular contributors Nikita and Dmitry. There

From 09a084850782320914e6b949853bf1a14329a66c Mon Sep 17 00:00:00 2001
From: Rene Rivera <grafikrobot@gmail.com>
Date: Thu, 13 Jun 2024 07:46:49 -0500
Subject: [PATCH 4/6] Test version patch branches on AppVeyor.

---
 appveyor.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/appveyor.yml b/appveyor.yml
index 15bd832e92..f456e0a763 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -10,6 +10,7 @@ branches:
     - /release/
     - /feature\/.*/
     - /backport-.*/
+    - /version\/.*/
 
 skip_commits:
   files:

From 53daa9e33b7ffbb7c8fe5ab8cc41caee7ed673c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Rivera?= <rene.rivera@disbelief.com>
Date: Thu, 13 Jun 2024 22:31:23 -0500
Subject: [PATCH 5/6] Fix the case of asking to initialize any msvc toolset
 when they are already initialized causing errors.

When having "using msvc : x.y ;" in  one config and doing "using msvc ;" in another would fail as the later would try and re-init x.y and error. With this change the empty msvc init will be a no-op as we already having toolsets to use.
---
 src/tools/msvc.jam | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/tools/msvc.jam b/src/tools/msvc.jam
index 5f304c807e..c210b93b30 100644
--- a/src/tools/msvc.jam
+++ b/src/tools/msvc.jam
@@ -1272,6 +1272,13 @@ local rule configure-really ( version ? : options * )
 {
     local command = [ feature.get-values <command> : $(options) ] ;
 
+    # We don't try and register any more versions than what we already know
+    # about when ask to discover any available versions.
+    if ! $(version) && ! $(command) && [ $(.versions).used ]
+    {
+        return ;
+    }
+
     if ! $(version) && ! $(command)
     {
         # We were given neither a command, nor a version.

From 3c0f5630157c3db1025b54c2f6da25cf234b8e20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Rivera?= <rene.rivera@disbelief.com>
Date: Thu, 13 Jun 2024 22:40:55 -0500
Subject: [PATCH 6/6] Add release note for double msvc init fix.

---
 doc/src/history.adoc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/src/history.adoc b/doc/src/history.adoc
index 8735a5ae8a..438d193736 100644
--- a/doc/src/history.adoc
+++ b/doc/src/history.adoc
@@ -9,6 +9,12 @@ user code to handle the conbination of turning off exceptions while treating
 warnings as errors, and getting warnings/errors from the std library by having
 the users silence the warning themselves.
 
+This patch also fixes the case of asking to initialize any msvc toolset
+versions (`using msvc ;`) when there are already versions initialized. Instead
+of erroring to say that a version is already in use, it considers the set
+of already initialized msvc toolsets as satisfying the request to generally
+initialize msvc.
+
 == Version 5.2.0
 
 Many fixes in this release from regular contributors Nikita and Dmitry. There