nareshmlx/opencv-pr huggingface dataset:
**File:** .github/workflows/PR-3.4-U20.yaml
**Change Type:** added
**Context:** PR #21875: Added workflow for Github Actions to build and test OpenCV on Linux

**Code Changes:**
```diff
@@ -0,0 +1,167 @@
+name: PR:3.4 U20
+
+on:
+  pull_request:
+    branches:
+      - 3.4
+
+env:
+  EXTRA_CMAKE_OPTIONS: '-DBUILD_DOCS=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DBUILD_EXAMPLES=ON -DOPENCV_ENABLE_NONFREE=ON -DENABLE_CCACHE=OFF'
```

Review comment:
User-wise speaking, will it be difficult to find which module reports errrors if all output of unit tests is put altogether in the 'Accuracy' section?
**File:** .github/workflows/PR-3.4-U20.yaml
**Change Type:** added
**Context:** PR #21875: Added workflow for Github Actions to build and test OpenCV on Linux

**Code Changes:**
```diff
@@ -0,0 +1,167 @@
+name: PR:3.4 U20
+
+on:
+  pull_request:
+    branches:
+      - 3.4
+
+env:
+  EXTRA_CMAKE_OPTIONS: '-DBUILD_DOCS=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DBUILD_EXAMPLES=ON -DOPENCV_ENABLE_NONFREE=ON -DENABLE_CCACHE=OFF'
```

Review comment:
I split tests by steps, don't need to do this.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
This can't work properly without working directory.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Hook could update DL_HASH value, so its call should be moved upper (at least before "# Check CMake cache for already processed tasks").
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> This is not a git repo "OpenCV source tree is not fetched as git repository"? "Unable to detect git repository server of OpenCV source tree"?
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> OPENCV_MIRROR_CUSTOM If user specifies this then we should not run git check. --- I believe variable name should be `OPENCV_DOWNLOAD_MIRROR_ID`.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> -DOPENCV_MIRROR_CUSTOM=gitcode.net How this can help to enable gitcode hooks if script forces "custom"?
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
To avoid false-positive replacement it makes sense to compare "original" hash first. Scenarios: - PR updates 3rdparty component. This hooks file is left untouched. We should not keep downloading old resources. - TBB dependency could be configured through CMake parameters for any version (see [ocv_update() calls](https://github.com/opencv/opencv/blob/4.5.5/3rdparty/tbb/CMakeLists.txt#L8-L10)). This hook can't support all of them.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Done. Replaced with "OpenCV source tree is not fetched as git repository".
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
I added ``` WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ``` in `execute_process`. Did this solve the problem?
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
This was functional in older version of the code. Will be removed soon.
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
> To avoid false-positive replacement it makes sense to compare "original" hash first. Is "original" hash the commit hash of the release? Commit hashes are not saved in CMake files downloading ADE & TBB. If we are using commit hash, I think we should also make ADE & TBB download using commit hash in the same way as Tengine does to keep CMake code unified and simple. > PR updates 3rdparty component. This hooks file is left untouched. We should not keep downloading old resources. As far as I know, mirrored repos in gitcode.net are automatically synced everyday. So hook files can be updated once PR updates 3rdparty components. Or do you mean we should fall back to original source if a newer version is used? > TBB dependency could be configured through CMake parameters for any version. Did you mean line 3 to line 6 ? ```cmake # TBB (Download from release page) ocv_update(TBB_GITCODE_RELEASE "v2020.2") ocv_update(TBB_GITCODE_PKG_NAME "tbb-${TBB_GITCODE_RELEASE}") ocv_update(TBB_GITCODE_PKG_MD5 4eeafdf16a90cb66e39a31c8d6c6804e) ```
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Old vars are all replaced with `OPENCV_DOWNLOAD_MIRROR_ID`, which should be simpler.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Done removing useless prompts.
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
TBB release from scripts: ``` $ cmake ... -DWITH_TBB=ON -DBUILD_TBB=ON ... -- TBB: Download: v2020.2.tar.gz ... -- Parallel framework: TBB (ver 2020.2 interface 11102) ``` Manual TBB version selection: ``` $ cmake ... -DWITH_TBB=ON -DBUILD_TBB=ON \ -DOPENCV_TBB_RELEASE=v2020.3 -DOPENCV_TBB_RELEASE_MD5=ea8fa4332f4bad10a75a361cba025380 ... -- TBB: Download: v2020.3.tar.gz ... -- Parallel framework: TBB (ver 2020.3 interface 11103) ``` The second case should not be silently hijacked by mirror hooks and retrieve incorrect version. Hooks may fail configuration or just don't change anything to cause failure on problem environment.
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
In the latest commit, custom TBB is downloaded from github.com by default unless `-DTBB_GITCODE_RELEASE` and `-DTBB_GITCODE_PKG_MD5` are set.
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
It is not about TBB only. It is about updating of any dependencies (without changes of mirror hooks code). Mirror hooks should NOT silently downgrade dependencies with "new outdated" hashsum. We need to check the "original" hash before replacing hashsum and URL. If we downloading something else then we should emit warning and do nothing (until we have updated hooks code).
**File:** cmake/mirrors/custom.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,77 @@
+# Gitlab-style mirror
+# CMake scripts look for opencv/opencv_3rdparty,
+#  OAID/Tengine, 01org/tbb(oneAPI/oneTBB), opencv/ade
+#  from OPENCV_DOWNLOAD_MIRROR
+ocv_update(OPENCV_DOWNLOAD_MIRROR_URL "")
+# Tengine
+ocv_update(TENGINE_PKG_MD5_CUSTOM "")
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
```

Review comment:
> set ... This message looks misleading as we don't update downloaded MD5 hashsum.
**File:** cmake/mirrors/custom.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,77 @@
+# Gitlab-style mirror
+# CMake scripts look for opencv/opencv_3rdparty,
+#  OAID/Tengine, 01org/tbb(oneAPI/oneTBB), opencv/ade
+#  from OPENCV_DOWNLOAD_MIRROR
+ocv_update(OPENCV_DOWNLOAD_MIRROR_URL "")
+# Tengine
+ocv_update(TENGINE_PKG_MD5_CUSTOM "")
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
```

Review comment:
> else() We should have something like these: ``` elseif("${${DL_ID}_CUSTOM_PKG_MD5_ORIGIN}" STREQUAL "${DL_HASH}") # pre-check before changing DL_HASH ... update fields ... else() message(STATUS "WARNING: No information about mirrors for downloading ${DL_ID} from URL='${DL_URL}' MD5=${DL_HASH}") # try to check "cached file", try to download from original URL (last step would probably fail until mirrors configuration update) endif() ```
**File:** cmake/mirrors/custom.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,77 @@
+# Gitlab-style mirror
+# CMake scripts look for opencv/opencv_3rdparty,
+#  OAID/Tengine, 01org/tbb(oneAPI/oneTBB), opencv/ade
+#  from OPENCV_DOWNLOAD_MIRROR
+ocv_update(OPENCV_DOWNLOAD_MIRROR_URL "")
+# Tengine
+ocv_update(TENGINE_PKG_MD5_CUSTOM "")
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
```

Review comment:
Yes, we do not update hashsum but users need to set values for several empty vars in custom.cmake to use their custom source. I think I can improve the description to tell users to modify the file.
**File:** cmake/mirrors/custom.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,77 @@
+# Gitlab-style mirror
+# CMake scripts look for opencv/opencv_3rdparty,
+#  OAID/Tengine, 01org/tbb(oneAPI/oneTBB), opencv/ade
+#  from OPENCV_DOWNLOAD_MIRROR
+ocv_update(OPENCV_DOWNLOAD_MIRROR_URL "")
+# Tengine
+ocv_update(TENGINE_PKG_MD5_CUSTOM "")
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
```

Review comment:
Checks for hashsums and warning messages are added both in gitcode.cmake & custom.cmake.
**File:** cmake/mirrors/custom.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,77 @@
+# Gitlab-style mirror
+# CMake scripts look for opencv/opencv_3rdparty,
+#  OAID/Tengine, 01org/tbb(oneAPI/oneTBB), opencv/ade
+#  from OPENCV_DOWNLOAD_MIRROR
+ocv_update(OPENCV_DOWNLOAD_MIRROR_URL "")
+# Tengine
+ocv_update(TENGINE_PKG_MD5_CUSTOM "")
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
```

Review comment:
set -> specify ?
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Logic should look like: ``` if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID) ... git remote get-url ... ... to configure OPENCV_DOWNLOAD_MIRROR_ID in CACHE (to avoid re-check on CMake re-run) ... endif() ... using OPENCV_DOWNLOAD_MIRROR_ID instead of __HOST ... ```
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> Unknown host detected Unable to recognize git server of OpenCV source code. --- Replace WARNING with STATUS to pass CI Condition should be: ``` if(OPENCV_DOWNLOAD_MIRROR_ID STREQUAL "github" OR OPENCV_DOWNLOAD_MIRROR_ID STREQUAL "") ```
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Cache entry should be written below after "detection". Here we should have: ``` ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID) ``` to support environment variables too.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
`ocv_init_download_mirror()` --- EOL before EOF
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> `OCV_DOWNLOAD_MIRROR_${OPENCV_DOWNLOAD_MIRROR_ID}` > `_${OPENCV_DOWNLOAD_MIRROR_ID}` We do not need dynamic suffix in the hook name. Just `OPENCV_DOWNLOAD_PRE`. --- Or we should have to `include(...cmake/mirrors/${__HOST}.cmake")` files which would register known hooks. and use here `ocv_cmake_hook(OCV_DOWNLOAD_PACKAGE_${DL_ID})`
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Need to check if we have file