[Bf-blender-cvs] [546314fc966] master: Build utils: `make_update`: Add option to choose SVN branch.

Bastien Montagne noreply at git.blender.org
Thu Sep 2 14:56:59 CEST 2021


Commit: 546314fc9669f88dd501b50be159fa0219813596
Author: Bastien Montagne
Date:   Thu Sep 2 12:11:32 2021 +0200
Branches: master
https://developer.blender.org/rB546314fc9669f88dd501b50be159fa0219813596

Build utils: `make_update`: Add option to choose SVN branch.

Needed for studio sprite-fright frozen branch.

Also do not overwrite branch for git sub-modules when it is defined, and
fallback to `master` branch in case specified branch is not found in a
specific sub-repository.

===================================================================

M	build_files/utils/make_update.py
M	build_files/utils/make_utils.py

===================================================================

diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index 2b8c7af98fb..b901fa56f52 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -31,6 +31,7 @@ def parse_arguments():
     parser.add_argument("--no-submodules", action="store_true")
     parser.add_argument("--use-tests", action="store_true")
     parser.add_argument("--svn-command", default="svn")
+    parser.add_argument("--svn-branch", default=None)
     parser.add_argument("--git-command", default="git")
     parser.add_argument("--use-centos-libraries", action="store_true")
     return parser.parse_args()
@@ -46,7 +47,7 @@ def svn_update(args, release_version):
     svn_non_interactive = [args.svn_command, '--non-interactive']
 
     lib_dirpath = os.path.join(get_blender_git_root(), '..', 'lib')
-    svn_url = make_utils.svn_libraries_base_url(release_version)
+    svn_url = make_utils.svn_libraries_base_url(release_version, args.svn_branch)
 
     # Checkout precompiled libraries
     if sys.platform == 'darwin':
@@ -170,26 +171,28 @@ def submodules_update(args, release_version, branch):
         sys.stderr.write("git not found, can't update code\n")
         sys.exit(1)
 
-    # Update submodules to latest master or appropriate release branch.
-    if not release_version:
-        branch = "master"
+    # Update submodules to appropriate given branch,
+    # falling back to master if none is given and/or found in a sub-repository.
+    branch_fallback = "master"
+    if not branch:
+        branch = branch_fallback
 
     submodules = [
-        ("release/scripts/addons", branch),
-        ("release/scripts/addons_contrib", branch),
-        ("release/datafiles/locale", branch),
-        ("source/tools", branch),
+        ("release/scripts/addons", branch, branch_fallback),
+        ("release/scripts/addons_contrib", branch, branch_fallback),
+        ("release/datafiles/locale", branch, branch_fallback),
+        ("source/tools", branch, branch_fallback),
     ]
 
     # Initialize submodules only if needed.
-    for submodule_path, submodule_branch in submodules:
+    for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
         if not os.path.exists(os.path.join(submodule_path, ".git")):
             call([args.git_command, "submodule", "update", "--init", "--recursive"])
             break
 
     # Checkout appropriate branch and pull changes.
     skip_msg = ""
-    for submodule_path, submodule_branch in submodules:
+    for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
         cwd = os.getcwd()
         try:
             os.chdir(submodule_path)
@@ -201,6 +204,11 @@ def submodules_update(args, release_version, branch):
                     call([args.git_command, "fetch", "origin"])
                     call([args.git_command, "checkout", submodule_branch])
                 call([args.git_command, "pull", "--rebase", "origin", submodule_branch])
+                # If we cannot find the specified branch for this submodule, fallback to default one (aka master).
+                if make_utils.git_branch(args.git_command) != submodule_branch:
+                    call([args.git_command, "fetch", "origin"])
+                    call([args.git_command, "checkout", submodule_branch_fallback])
+                    call([args.git_command, "pull", "--rebase", "origin", submodule_branch_fallback])
         finally:
             os.chdir(cwd)
 
diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py
index 9f928bb524d..7cd23baad68 100755
--- a/build_files/utils/make_utils.py
+++ b/build_files/utils/make_utils.py
@@ -70,9 +70,11 @@ def git_branch_release_version(branch, tag):
     return release_version
 
 
-def svn_libraries_base_url(release_version):
+def svn_libraries_base_url(release_version, branch):
     if release_version:
         svn_branch = "tags/blender-" + release_version + "-release"
+    elif branch:
+        svn_branch = "branches/" + branch
     else:
         svn_branch = "trunk"
     return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"



More information about the Bf-blender-cvs mailing list