summaryrefslogtreecommitdiffstats
path: root/tools/scripts
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-07-02 11:34:47 +0200
committerAndras Becsi <andras.becsi@digia.com>2014-07-03 13:14:44 +0200
commitd8245424b814591a4fbc4115c1fabe0a34479bb3 (patch)
treeeec90dda1799b2631f0d99f2c51a2b974c89ac38 /tools/scripts
parent5317069f3d0d27ed6192a41b3f7b7e6b74dfbbed (diff)
tools: add reset option to patch_upstream.py
This patch makes it possible to reset the upstream chromium repository to its baseline state. Change-Id: Idff94a0f873e994716f77c83f4c5b79bcd48aec5 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'tools/scripts')
-rw-r--r--tools/scripts/git_submodule.py8
-rwxr-xr-xtools/scripts/patch_upstream.py6
-rw-r--r--tools/scripts/version_resolver.py28
3 files changed, 41 insertions, 1 deletions
diff --git a/tools/scripts/git_submodule.py b/tools/scripts/git_submodule.py
index 48913cb7..0505d2ca 100644
--- a/tools/scripts/git_submodule.py
+++ b/tools/scripts/git_submodule.py
@@ -220,6 +220,7 @@ class Submodule:
def initialize(self):
if self.matchesOS():
print '-- initializing ' + self.path + ' --'
+ oldCwd = os.getcwd()
if os.path.isdir(self.path):
self.reset()
@@ -231,6 +232,11 @@ class Submodule:
if self.findShaAndCheckout() != 0:
sys.exit("!!! initialization failed !!!")
+
+ os.chdir(self.path)
+ commit = subprocessCheckOutput(['git', 'rev-list', '--max-count=1', 'HEAD'])
+ subprocessCall(['git', 'commit', '-a', '--allow-empty', '-m', '-- QtWebEngine baseline --\n\ncommit ' + commit])
+ os.chdir(oldCwd)
else:
print '-- skipping ' + self.path + ' for this operating system. --'
@@ -291,5 +297,5 @@ class Submodule:
for submodule in submodules:
submodule.initialize()
if self.ref:
- subprocessCall(['git', 'commit', '-a', '-m', 'initialize submodules'])
+ subprocessCall(['git', 'commit', '-a', '--amend', '--no-edit'])
os.chdir(oldCwd)
diff --git a/tools/scripts/patch_upstream.py b/tools/scripts/patch_upstream.py
index 081a2452..d15dcf5c 100755
--- a/tools/scripts/patch_upstream.py
+++ b/tools/scripts/patch_upstream.py
@@ -55,6 +55,12 @@ import version_resolver as resolver
os.chdir(os.path.join(resolver.upstream_src_dir, 'chromium'))
+if len(sys.argv) != 1:
+ if "--reset" in sys.argv:
+ resolver.resetUpstream()
+ sys.exit()
+ else:
+ sys.exit('unknown option, try --reset or w/o options\n')
if not len(resolver.findSnapshotBaselineSha1()):
sys.exit('\n-- missing chromium snapshot patches, try running init-repository.py w/o options first --')
diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py
index 73a5c5c6..aec1bf6f 100644
--- a/tools/scripts/version_resolver.py
+++ b/tools/scripts/version_resolver.py
@@ -197,3 +197,31 @@ def preparePatchesFromSnapshot():
os.chdir(oldCwd)
return patches_dict
+def resetUpstream():
+ oldCwd = os.getcwd()
+ target_dir = os.path.join(upstream_src_dir, 'chromium')
+ os.chdir(target_dir)
+
+ chromium = GitSubmodule.Submodule()
+ chromium.path = "."
+ submodules = chromium.readSubmodules()
+ submodules.append(chromium)
+
+ print('-- resetting upstream submodules in ' + os.path.relpath(target_dir) + ' to baseline --')
+
+ for module in submodules:
+ oldCwd = os.getcwd()
+ module_path = os.path.abspath(os.path.join(target_dir, module.path))
+ if not os.path.isdir(module_path):
+ continue
+
+ cwd = os.getcwd()
+ os.chdir(module_path)
+ line = subprocess.check_output(['git', 'log', '-n1', '--pretty=oneline', '--grep=-- QtWebEngine baseline --'])
+ line = line.split(' ')[0]
+ if line:
+ subprocess.call(['git', 'reset', '-q', '--hard', line])
+ os.chdir(cwd)
+ module.reset()
+ os.chdir(oldCwd)
+ print('done.\n')