summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-10-30 10:22:56 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-10-31 13:41:26 +0100
commit62a653d32176956365f1fe8b5cb148a6391a6c9d (patch)
tree467b62519773f63afb6c54b57b31edfcec72bb54 /scripts
parent54885fd599d03c738661a6788c82d97c9d6de220 (diff)
branch_qt: implement sync
We sometimes want to quickly fast forward branches where possible, for example 5.13 was just updated with 5.13.2 where fast forward merges were possible. Change-Id: I6460df11f505b792947e6f688f2bd86e54b29086 Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/qt/branch_qt.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/scripts/qt/branch_qt.py b/scripts/qt/branch_qt.py
index 535c9868..3cda4cf2 100755
--- a/scripts/qt/branch_qt.py
+++ b/scripts/qt/branch_qt.py
@@ -154,8 +154,8 @@ class QtBranching:
self.merge_repo(repo)
elif self.mode == Mode['branch']:
self.branch_repo(repo)
- # elif self.mode == Mode['sync']:
- # self.sync_repo()
+ elif self.mode == Mode['sync']:
+ self.sync_repo(repo)
elif self.mode == Mode['bump']:
self.version_bump_repo(repo)
else:
@@ -168,6 +168,9 @@ class QtBranching:
def sanity_check(self) -> None:
assert os.path.exists('qt.pro'), "This script must be run in an existing qt5.git checkout."
+ if self.mode == Mode['sync']:
+ return
+
if self.fromBranch == 'dev':
assert is_major_minor(self.toBranch), "Branching from dev must be to a minor version (a.b)"
elif is_major_minor_patch(self.fromBranch):
@@ -252,22 +255,34 @@ class QtBranching:
if not repo_name in (extra_repo.split('/')[-1] for extra_repo in extra_repositories):
self.subprocess_or_pretend(f"git config -f ../.gitmodules submodule.{repo_name}.branch {self.toBranch}".split())
+ def push(self):
+ self.subprocess_or_pretend(f'git push gerrit {self.toBranch}:{self.toBranch}'.split(), check=True)
+
def merge_repo(self, repo: git.Repo) -> None:
log.info(f"Merge: {repo.working_dir}")
- push_merge = lambda: self.subprocess_or_pretend(f'git push gerrit {self.toBranch}:{self.toBranch}'.split(), check=True)
+
self.checkout_and_pull_branch(repo, self.toBranch)
try:
subprocess.run(f'git merge --ff-only --quiet gerrit/{self.fromBranch}'.split(), check=True, stderr=subprocess.PIPE)
- push_merge()
+ self.push()
except subprocess.CalledProcessError:
# The merge was not fast forward, try again
try:
log.info(f" Attempting non ff merge for {repo.working_dir}")
subprocess.run(['git', 'merge', f'gerrit/{self.fromBranch}', '--quiet', '-m', f'Merge {self.fromBranch} into {self.toBranch}'], check=True)
- push_merge()
+ self.push()
except subprocess.CalledProcessError:
log.warning(f" Merge had conflicts. {repo.working_dir} needs to be merged manually!")
+ def sync_repo(self, repo: git.Repo) -> None:
+ log.info(f"Sync: {repo.working_dir} ({self.fromBranch} -> {self.toBranch})")
+ self.checkout_and_pull_branch(repo, self.toBranch)
+ try:
+ subprocess.run(f'git merge --ff-only --quiet gerrit/{self.fromBranch}'.split(), check=True, stderr=subprocess.PIPE)
+ self.push()
+ except Exception as e:
+ log.exception(f"Could not sync repository: {repo.working_dir}")
+
def version_bump_repo(self, repo: git.Repo) -> None:
qmake_conf_file_name = '.qmake.conf'
with open(qmake_conf_file_name, mode='r', encoding='utf-8') as qmake_conf: