[x265] [X265] [Final Patch] fix: avoids unnecessary lexicographic order checks on git changesets

Srikanth Kurapati srikanth.kurapati at multicorewareinc.com
Thu Dec 24 17:18:38 UTC 2020


>From d3eefd984eb0f2d1b9bb0ab0c0393eeb3e0cf643 Mon Sep 17 00:00:00 2001
From: Srikanth Kurapati <srikanth.kurapati at multicorewareinc.com>
Date: Wed, 16 Dec 2020 10:52:33 +0530
Subject: [PATCH] fix: avoids unnecessary lexicographic order checks on git
 changesets

also corrects variables used for git archive version reporting and
mandatory fields in version file
---
 source/cmake/Version.cmake | 108 ++++++++++++++++---------------------
 x265Version.txt            |   1 -
 2 files changed, 47 insertions(+), 62 deletions(-)

diff --git a/source/cmake/Version.cmake b/source/cmake/Version.cmake
index 37c759268..a3988d39f 100644
--- a/source/cmake/Version.cmake
+++ b/source/cmake/Version.cmake
@@ -28,8 +28,6 @@
 set(X265_VERSION "unknown")
 set(X265_LATEST_TAG "0.0")
 set(X265_TAG_DISTANCE "0")
-set(HG_ARCHETYPE "0")
-set(GIT_ARCHETYPE "0")

 #Find version control software to be used for live and extracted
repositories from compressed tarballs
 if(CMAKE_VERSION VERSION_LESS "2.8.10")
@@ -43,10 +41,10 @@ else()
 endif()
 if(HG_EXECUTABLE)
     #Set Version Control binary for source code kind
-    if(EXISTS CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
+    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
         set(HG_ARCHETYPE "1")
     elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg)
-        set(HG_ARCHETYPE "2")
+        set(HG_ARCHETYPE "0")
     endif()
 endif(HG_EXECUTABLE)
 find_package(Git QUIET) #No restrictions on Git versions used, any
versions from 1.8.x to 2.2.x or later should do.
@@ -54,14 +52,14 @@ if(Git_FOUND)
     find_program(GIT_EXECUTABLE git)
     message(STATUS "GIT_EXECUTABLE ${GIT_EXECUTABLE}")
     if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
-        set(GIT_ARCHETYPE "2")
+        set(GIT_ARCHETYPE "0")
     elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt)
         set(GIT_ARCHETYPE "1")
     endif()
 endif(Git_FOUND)
-if(HG_ARCHETYPE STREQUAL "1")
+if(HG_ARCHETYPE)
     #Read the lines of the archive summary file to extract the version
-    message(STATUS "SOURCE CODE IS FROM x265 ARCHIVED ZIP OR TAR BALL")
+    message(STATUS "SOURCE CODE IS FROM x265 HG ARCHIVED ZIP OR TAR BALL")
     file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt archive)
     STRING(REGEX REPLACE "\n" ";" archive "${archive}")
     foreach(f ${archive})
@@ -79,7 +77,8 @@ if(HG_ARCHETYPE STREQUAL "1")
         string(SUBSTRING "${hg_node}" 0 12 X265_REVISION_ID)
     endif()
     message(STATUS "HG ARCHIVAL INFORMATION PROCESSED")
-elseif(HG_ARCHETYPE STREQUAL "2")
+elseif(NOT DEFINED GIT_ARCHETYPE)
+# means that's its neither hg archive nor git clone/archive hence it has
to be hg live repo as these are only four cases that need to processed in
mutual exclusion.
     execute_process(COMMAND
         ${HG_EXECUTABLE} log -r. --template "{latesttag}"
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -107,7 +106,41 @@ elseif(HG_ARCHETYPE STREQUAL "2")
         string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
     endif()
     message(STATUS "HG LIVE REPO STATUS CHECK DONE")
-elseif(GIT_ARCHETYPE STREQUAL "2")
+elseif(GIT_ARCHETYPE)
+    message(STATUS "SOURCE CODE IS FROM x265 GIT ARCHIVED ZIP OR TAR BALL")
+    #Read the lines of the archive summary file to extract the version
+    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt filebuf)
+    STRING(REGEX REPLACE "\n" ";" filebuf "${filebuf}")
+    foreach(line ${filebuf})
+        string(FIND "${line}" ": " pos)
+        string(SUBSTRING "${line}" 0 ${pos} key)
+        string(SUBSTRING "${line}" ${pos} -1 value)
+        string(SUBSTRING "${value}" 2 -1 value)
+        set(git_${key} ${value})
+    endforeach()
+    if(DEFINED git_releasetag)
+        set(X265_LATEST_TAG ${git_releasetag})
+        if(DEFINED git_releasetagdistance)
+            set(X265_TAG_DISTANCE ${git_releasetagdistance})
+            if(X265_TAG_DISTANCE STRGREATER_EQUAL "0")
+                #for x265 the repository changeset has to be a tag id or
commit id after the tag
+                #hence mandating it's presence in version file always for
valid tag distances.
+                if(DEFINED git_repositorychangeset)
+                    string(SUBSTRING "${git_repositorychangeset}" 0 9
X265_REVISION_ID)
+                else()
+                    message(WARNING "X265 LATEST COMMIT TIP INFORMATION
NOT AVAILABLE")
+                endif()
+            else()
+                message(WARNING "X265 TAG DISTANCE INVALID")
+            endif()
+        else()
+            message(WARNING "COMMIT INFORMATION AFTER LATEST REVISION
UNAVAILABLE")
+        endif()
+    else()
+        message(WARNING "X265 RELEASE VERSION LABEL MISSING:
${X265_LATEST_TAG}")
+    endif()
+    message(STATUS "GIT ARCHIVAL INFORMATION PROCESSED")
+else()
     execute_process(
         COMMAND
         ${GIT_EXECUTABLE} describe --abbrev=0 --tags
@@ -132,62 +165,15 @@ elseif(GIT_ARCHETYPE STREQUAL "2")
         ERROR_QUIET
         OUTPUT_STRIP_TRAILING_WHITESPACE
         )
-elseif(GIT_ARCHETYPE STREQUAL "1")
-    message(STATUS "X265 GIT ARCHIVE EXTRACT VERSION INFORMATION
PROCESSING")
-    #Read the lines of the archive summary file to extract the version
-    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt filebuf)
-    STRING(REGEX REPLACE "\n" ";" filebuf "${filebuf}")
-    foreach(line ${filebuf})
-        string(FIND "${line}" ": " pos)
-        string(SUBSTRING "${line}" 0 ${pos} key)
-        string(SUBSTRING "${line}" ${pos} -1 value)
-        string(SUBSTRING "${value}" 2 -1 value)
-        set(git_${key} ${value})
-    endforeach()
-    if(DEFINED git_releasetag)
-        set(X265_LATEST_TAG ${git_releasetag})
-        if(DEFINED git_releasetagcommitid)
-            string(SUBSTRING "${git_releasetagcommitid}" 0 9
X265_REVISION_ID)
-        else()
-            message(WARNING "RELEASE CHANGESET INFO NOT PRESENT IN VERSION
FILE")
-        endif()
-        if(DEFINED git_repositorychangeset)
-           string(SUBSTRING "${git_repositorychangeset}" 0 9 X265_REPO_ID)
-        else()
-           message(STATUS "X265 LATEST COMMIT TIP INFORMATION NOT
AVAILABLE")
-        endif()
-        if(DEFINED git_releasetagdistance)
-           set(X265_TAG_DISTANCE ${git_releasetagdistance})
-        else()
-           message(WARNING "COMMIT INFORMATION AFTER LATEST REVISION
UNAVAILABLE")
-        endif()
-    else()
-        message(WARNING "X265 RELEASE VERSION LABEL MISSING:
${X265_LATEST_TAG}")
-    endif()
+    message(STATUS "GIT LIVE REPO VERSION RETRIEVED")
 endif()

-# formatting based on positive or negative distance from tag
+# formatting based on distance from tag
 if(X265_TAG_DISTANCE STREQUAL "0")
-    if(X265_REVISION_ID STREQUAL X265_REPO_ID)
-        set(X265_VERSION "${X265_LATEST_TAG}")
-    else()
-        message(WARNING "REPO AND RELEASE CHANGESETS NOT MATCHING")
-    endif()
+    set(X265_VERSION "${X265_LATEST_TAG}")
 elseif(X265_TAG_DISTANCE STRGREATER "0")
-    if(X265_REVISION_ID STRLESS X265_REPO_ID)
-        set(X265_VERSION
"${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
-    else()
-        message(WARNING "ARCCHIVE TIP CHANGESET TO BE GREATER THAN
REVISION ID")
-    endif()
-elseif(X265_TAG_DISTANCE STRLESS "0")
-    if(X265_REVISION_ID STRGREATER X265_REPO_ID)
-       set(X265_VERSION
"${X265_LATEST_TAG}${X265_TAG_DISTANCE}+${X265_REPO_ID}")
-    else()
-        message(WARNING "REVISION ID EXPECTED TO BE LARGER THAN ARCHIVE
TIP CHANGESET")
-    endif()
-else()
-    message(ERROR "Inappropriate set of version information")
+    set(X265_VERSION
"${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
 endif()

 #will always be printed in its entirety based on version file
configuration to avail revision monitoring by repo owners
-message(STATUS "x265 RELEASE VERSION ${X265_VERSION}")
+message(STATUS "X265 RELEASE VERSION ${X265_VERSION}")
diff --git a/x265Version.txt b/x265Version.txt
index ac225ec4d..33950f9a0 100644
--- a/x265Version.txt
+++ b/x265Version.txt
@@ -1,5 +1,4 @@
 #Attribute:     Values
 repositorychangeset: 5163c32d7
-releasetagcommitid: a4f320054
 releasetagdistance: 28
 releasetag: 3.4
-- 
2.20.1.windows.1


-- 
*With Regards,*
*Srikanth Kurapati.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201224/0df4826f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-avoids-unnecessary-lexicographic-order-checks-on.patch
Type: application/octet-stream
Size: 8198 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201224/0df4826f/attachment-0001.obj>


More information about the x265-devel mailing list