Bug 1872242 - Change how the last segment of milestone_winversion is generated to improve uniqueness r=firefox-build-system-reviewers,RyanVM,glandium

The previous implementation used days since Jan 1 2000 for the last
16-bit segment. This was not unique enough and caused issues with
Antivirus software if two different channels were built on the same day.

The new approach uses hours since the last milestone bump and uses the
VCS to determine how long ago that was relative to the build time. This
means it will always reset when a new cycle begins, but still be unique
since the digits in the first 3 segments have incremented.

We also now use two of the 16-bits to encode the channel (nightly, beta,
ESR, and release). So two channels built within the same hour will still
be unique.

Using only 14-bits to store the 'hours since version bump', we have
about ~682 days from a version bump before we reach the maximum value we
can store. If a build is done after that point, the segment value will
always be the maximum value for that channel.

Differential Revision: https://phabricator.services.mozilla.com/D200989
This commit is contained in:
ahochheiden committed 2024-02-08 07:00:48 +00:00
1 parent edc0fbc7a2
commit e77c3ff321
3 files changed
+122 -6

No files matched your search

@@ -8,6 +8,7 @@ import os
import re
import shutil
import subprocess
from datetime import datetime
from pathlib import Path
from typing import (
Iterator,
@@ -345,6 +346,11 @@ class Repository(object):
def remove_current_commit(self):
"""Remove the currently checked out commit from VCS history."""
@abc.abstractmethod
def get_last_modified_time_for_file(self, path: Path):
"""Return last modified in VCS time for the specified file."""
pass
class HgRepository(Repository):
"""An implementation of `Repository` for Mercurial repositories."""
@@ -673,6 +679,20 @@ class HgRepository(Repository):
self.raise_for_missing_extension("evolve")
raise
def get_last_modified_time_for_file(self, path: Path):
"""Return last modified in VCS time for the specified file."""
out = self._run(
"log",
"--template",
"{date|isodatesec}",
"--limit",
"1",
"--follow",
str(path),
)
return datetime.strptime(out[:-6].strip(), "%Y-%m-%d %H:%M:%S")
class GitRepository(Repository):
"""An implementation of `Repository` for Git repositories."""
@@ -916,6 +936,12 @@ class GitRepository(Repository):
"""Remove the currently checked out commit from VCS history."""
self._run("reset", "HEAD~")
def get_last_modified_time_for_file(self, path: Path):
"""Return last modified in VCS time for the specified file."""
out = self._run("log", "-1", "--format=%ad", "--date=iso", path)
return datetime.strptime(out[:-6].strip(), "%Y-%m-%d %H:%M:%S")
class SrcRepository(Repository):
"""An implementation of `Repository` for Git repositories."""
@@ -1037,6 +1063,10 @@ class SrcRepository(Repository):
def set_config(self, name, value):
pass
def get_last_modified_time_for_file(self, path: Path):
"""Return last modified in VCS time for the specified file."""
raise MissingVCSTool
def get_repository_object(
path: Optional[Union[str, Path]], hg="hg", git="git", src="src"
+11 -1
View File
@@ -2,6 +2,9 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from datetime import datetime
from pathlib import Path
import mozunit
from mozversioncontrol import get_repository_object
@@ -30,14 +33,21 @@ def test_commit(repo):
repo.execute_next_step()
assert not vcs.working_directory_clean()
date_string = "2017-07-14 02:40:00 UTC"
# Commit just bar
vcs.commit(
message="Modify bar\n\nbut not baz",
author="Testing McTesterson <[email protected]>",
date="2017-07-14 02:40:00 UTC",
date=date_string,
paths=["bar"],
)
original_date = datetime.strptime(date_string[:-4], "%Y-%m-%d %H:%M:%S")
date_from_vcs = vcs.get_last_modified_time_for_file(Path("bar"))
assert original_date == date_from_vcs
# We only committed bar, so foo is still keeping the working dir dirty
assert not vcs.working_directory_clean()