Diff
Modified: trunk/Tools/ChangeLog (289385 => 289386)
--- trunk/Tools/ChangeLog 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/ChangeLog 2022-02-08 18:36:13 UTC (rev 289386)
@@ -1,3 +1,18 @@
+2022-02-01 Jonathan Bedard <[email protected]>
+
+ [git-webkit] Autostash when pulling
+ https://bugs.webkit.org/show_bug.cgi?id=235861
+ <rdar://problem/88298948>
+
+ Reviewed by Ryosuke Niwa.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+ (Git.pull): Pass --autostash when pulling and resetting timestamps.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Handle --autostash.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+
2022-02-08 Jon Lee <[email protected]>
Enable GPU Process for WebGL by default on iOS
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (289385 => 289386)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-02-08 18:36:13 UTC (rev 289386)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.0.0',
+ version='4.0.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (289385 => 289386)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-08 18:36:13 UTC (rev 289386)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 0, 0)
+version = Version(4, 0, 1)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (289385 => 289386)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2022-02-08 18:36:13 UTC (rev 289386)
@@ -921,25 +921,24 @@
def pull(self, rebase=None, branch=None, remote='origin'):
commit = self.commit() if self.is_svn or branch else None
- code = run(
- [self.executable(), 'pull'] + (
- [remote, branch] if branch else []
- ) + (
- [] if rebase is None else ['--rebase={}'.format('True' if rebase else 'False')]
- ), cwd=self.root_path,
- ).returncode
+
+ code = 0
+ if branch and self.branch != branch:
+ code = self.fetch(branch=branch, remote=remote)
+ if not code:
+ command = [self.executable(), 'pull'] + ([remote, branch] if branch else []) + ['--autostash']
+ if rebase is not None:
+ command += ['--rebase={}'.format('True' if rebase else 'False')]
+ code = run(command, cwd=self.root_path).returncode
if self.cache and rebase and branch != self.branch:
self.cache.clear(self.branch)
- if not code and branch:
- code = self.fetch(branch=branch, remote=remote)
-
if not code and branch and rebase:
result = run([self.executable(), 'rev-parse', 'HEAD'], cwd=self.root_path, capture_output=True, encoding='utf-8')
if not result.returncode and result.stdout.rstrip() != commit.hash:
code = run([
self.executable(),
- 'filter-branch', '-f',
+ 'filter-branch', '-f', '--autostash',
'--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(
date='{} -{}'.format(int(time.time()), self.gmtoffset())
), 'HEAD...{}'.format('{}/{}'.format(remote, branch)),
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (289385 => 289386)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2022-02-08 18:36:13 UTC (rev 289386)
@@ -362,6 +362,15 @@
generator=lambda *args, **kwargs:
mocks.ProcessCompletion(returncode=0) if self.checkout(args[2], create=False) else mocks.ProcessCompletion(returncode=1)
), mocks.Subprocess.Route(
+ self.executable, 'filter-branch', '-f', '--autostash', '--env-filter', re.compile(r'.*'), '--msg-filter',
+ cwd=self.path,
+ generator=lambda *args, **kwargs: self.filter_branch(
+ args[-1],
+ identifier_template=args[-2].split("'")[-2] if args[-3] == '--msg-filter' else None,
+ environment_shell=args[5] if args[4] == '--env-filter' and args[5] else None,
+ autostash=True,
+ )
+ ), mocks.Subprocess.Route(
self.executable, 'filter-branch', '-f', '--env-filter', re.compile(r'.*'), '--msg-filter',
cwd=self.path,
generator=lambda *args, **kwargs: self.filter_branch(
@@ -391,6 +400,10 @@
cwd=self.path,
generator=lambda *args, **kwargs: self.pull(),
), mocks.Subprocess.Route(
+ self.executable, 'pull', '--autostash',
+ cwd=self.path,
+ generator=lambda *args, **kwargs: self.pull(autostash=True),
+ ), mocks.Subprocess.Route(
self.executable, 'config', '-l',
cwd=self.path,
generator=lambda *args, **kwargs:
@@ -633,7 +646,10 @@
self.detached = something not in self.commits.keys()
return True if commit else False
- def filter_branch(self, range, identifier_template=None, environment_shell=None, sed=None):
+ def filter_branch(self, range, identifier_template=None, environment_shell=None, sed=None, autostash=False):
+ if not autostash and (self.modified or self.staged):
+ return mocks.ProcessCompletion(returncode=128)
+
# We can't effectively mock the bash script in the command, but we can mock the python code that
# script calls, which is where the program logic is.
head, start = range.split('...')
@@ -869,7 +885,9 @@
commit.identifier += self.commits[target][-1].identifier
return mocks.ProcessCompletion(returncode=0)
- def pull(self):
+ def pull(self, autostash=False):
+ if not autostash and (self.modified or self.staged):
+ return mocks.ProcessCompletion(returncode=128)
self.head = self.commits[self.head.branch][-1]
return mocks.ProcessCompletion(returncode=0)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (289385 => 289386)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2022-02-08 18:20:19 UTC (rev 289385)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py 2022-02-08 18:36:13 UTC (rev 289386)
@@ -493,7 +493,17 @@
list(repo.diff_lines(base='3@main', head='4@main'))
)
+ def test_pull(self):
+ with mocks.local.Git(self.path) as mocked, OutputCapture():
+ mocked.staged['added.txt'] = 'added'
+ self.assertEqual(local.Git(self.path).pull(), 0)
+ def test_pull_no_stash(self):
+ with mocks.local.Git(self.path) as mocked, OutputCapture():
+ mocked.staged['added.txt'] = 'added'
+ self.assertEqual(run([local.Git.executable(), 'pull'], cwd=self.path).returncode, 128)
+
+
class TestGitHub(testing.TestCase):
remote = 'https://github.example.com/WebKit/WebKit'