Title: [289423] trunk/Tools
Revision
289423
Author
[email protected]
Date
2022-02-08 13:33:24 -0800 (Tue, 08 Feb 2022)

Log Message

[git-webkit] Autostash when pulling (Follow-up fix)
https://bugs.webkit.org/show_bug.cgi?id=235861
<rdar://problem/88298948>

Unreviewed follow-up fix.

Accidently landed a previous iteration of the change.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.Cache.clear): Handle empty cache.
(Git.pull): Only autostash when rebasing.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (289422 => 289423)


--- trunk/Tools/ChangeLog	2022-02-08 21:31:16 UTC (rev 289422)
+++ trunk/Tools/ChangeLog	2022-02-08 21:33:24 UTC (rev 289423)
@@ -1,5 +1,21 @@
 2022-02-08  Jonathan Bedard  <[email protected]>
 
+        [git-webkit] Autostash when pulling (Follow-up fix)
+        https://bugs.webkit.org/show_bug.cgi?id=235861
+        <rdar://problem/88298948>
+
+        Unreviewed follow-up fix.
+
+        Accidently landed a previous iteration of the change.
+
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git.Cache.clear): Handle empty cache.
+        (Git.pull): Only autostash when rebasing.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+
+2022-02-08  Jonathan Bedard  <[email protected]>
+
         [git-webkit] Allow repositories to declare their bug trackers
         https://bugs.webkit.org/show_bug.cgi?id=236306
         <rdar://problem/88633018>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (289422 => 289423)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-02-08 21:31:16 UTC (rev 289422)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-02-08 21:33:24 UTC (rev 289423)
@@ -205,6 +205,8 @@
             self._hash_to_identifiers = NestedFuzzyDict(primary_size=6)
             self._revisions_to_identifiers = {}
 
+            if self.repo.default_branch not in self._ordered_commits:
+                return
             self._fill(self.repo.default_branch)
             for branch in self._ordered_commits.keys():
                 if branch == self.repo.default_branch:
@@ -926,9 +928,11 @@
         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')]
+            command = [self.executable(), 'pull'] + ([remote, branch] if branch else [])
+            if rebase is True:
+                command += ['--rebase=True', '--autostash']
+            elif rebase is False:
+                command += ['--rebase=False']
             code = run(command, cwd=self.root_path).returncode
         if self.cache and rebase and branch != self.branch:
             self.cache.clear(self.branch)
@@ -938,7 +942,7 @@
             if not result.returncode and result.stdout.rstrip() != commit.hash:
                 code = run([
                     self.executable(),
-                    'filter-branch', '-f', '--autostash',
+                    'filter-branch', '-f',
                     '--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 (289422 => 289423)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2022-02-08 21:31:16 UTC (rev 289422)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2022-02-08 21:33:24 UTC (rev 289423)
@@ -362,15 +362,6 @@
                 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(
@@ -400,7 +391,7 @@
                 cwd=self.path,
                 generator=lambda *args, **kwargs: self.pull(),
             ), mocks.Subprocess.Route(
-                self.executable, 'pull', '--autostash',
+                self.executable, 'pull', '--rebase=True', '--autostash',
                 cwd=self.path,
                 generator=lambda *args, **kwargs: self.pull(autostash=True),
             ), mocks.Subprocess.Route(

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (289422 => 289423)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-02-08 21:31:16 UTC (rev 289422)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-02-08 21:33:24 UTC (rev 289423)
@@ -496,12 +496,12 @@
     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)
+            self.assertEqual(local.Git(self.path).pull(rebase=True), 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)
+            self.assertEqual(local.Git(self.path).pull(), 128)
 
 
 class TestGitHub(testing.TestCase):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to