<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[278963] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/278963">278963</a></dd>
<dt>Author</dt> <dd>jbedard@apple.com</dd>
<dt>Date</dt> <dd>2021-06-16 15:41:35 -0700 (Wed, 16 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[webkitscmpy] Support branch queries in mock git log
https://bugs.webkit.org/show_bug.cgi?id=225889
<rdar://problem/78122705>

Reviewed by Stephanie Lewis.

* Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Add support for branches in
`git log` commands.
* Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
(TestGit.test_log):
(TestGit.test_branch_log):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptslibrarieswebkitscmpysetuppy">trunk/Tools/Scripts/libraries/webkitscmpy/setup.py</a></li>
<li><a href="#trunkToolsScriptslibrarieswebkitscmpywebkitscmpy__init__py">trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py</a></li>
<li><a href="#trunkToolsScriptslibrarieswebkitscmpywebkitscmpymockslocalgitpy">trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py</a></li>
<li><a href="#trunkToolsScriptslibrarieswebkitscmpywebkitscmpytestgit_unittestpy">trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (278962 => 278963)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/ChangeLog       2021-06-16 22:41:35 UTC (rev 278963)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2021-06-16  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><ins>+        [webkitscmpy] Support branch queries in mock git log
+        https://bugs.webkit.org/show_bug.cgi?id=225889
+        <rdar://problem/78122705>
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Add support for branches in
+        `git log` commands.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+        (TestGit.test_log):
+        (TestGit.test_branch_log):
+
+2021-06-16  Jonathan Bedard  <jbedard@apple.com>
+
</ins><span class="cx">         [webkitscmpy] Cache more Git commands
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=227082
</span><span class="cx">         <rdar://problem/79405244>
</span></span></pre></div>
<a id="trunkToolsScriptslibrarieswebkitscmpysetuppy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (278962 => 278963)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py       2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py  2021-06-16 22:41:35 UTC (rev 278963)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> setup(
</span><span class="cx">     name='webkitscmpy',
</span><del>-    version='0.14.5',
</del><ins>+    version='0.14.6',
</ins><span class="cx">     description='Library designed to interact with git and svn repositories.',
</span><span class="cx">     long_description=readme(),
</span><span class="cx">     classifiers=[
</span></span></pre></div>
<a id="trunkToolsScriptslibrarieswebkitscmpywebkitscmpy__init__py"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (278962 => 278963)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py        2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py   2021-06-16 22:41:35 UTC (rev 278963)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
</span><span class="cx">     )
</span><span class="cx"> 
</span><del>-version = Version(0, 14, 5)
</del><ins>+version = Version(0, 14, 6)
</ins><span class="cx"> 
</span><span class="cx"> AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
</span><span class="cx"> AutoInstall.register(Package('monotonic', Version(1, 5)))
</span></span></pre></div>
<a id="trunkToolsScriptslibrarieswebkitscmpywebkitscmpymockslocalgitpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (278962 => 278963)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py 2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py    2021-06-16 22:41:35 UTC (rev 278963)
</span><span class="lines">@@ -253,7 +253,7 @@
</span><span class="cx">                         'AuthorDate: {date}\n'
</span><span class="cx">                         'Commit:     {author} <{email}>\n'
</span><span class="cx">                         'CommitDate: {date}\n'
</span><del>-                        '\n{log}'.format(
</del><ins>+                        '\n{log}\n'.format(
</ins><span class="cx">                             hash=commit.hash,
</span><span class="cx">                             author=commit.author.name,
</span><span class="cx">                             email=commit.author.email,
</span><span class="lines">@@ -353,7 +353,7 @@
</span><span class="cx">                     return self.commits[self.default_branch][found.branch_point - difference - 1]
</span><span class="cx">                 return None
</span><span class="cx"> 
</span><del>-        something = str(something)
</del><ins>+        something = str(something).replace('remotes/', '')
</ins><span class="cx">         if '..' in something:
</span><span class="cx">             a, b = something.split('..')
</span><span class="cx">             a = self.find(a)
</span><span class="lines">@@ -501,28 +501,43 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">     def commits_in_range(self, begin, end):
</span><ins>+        begin = begin.replace('remotes/', '') if begin else begin
+        end = end.replace('remotes/', '') if end else end
+
+        if begin and self.remotes.get(begin):
+            begin = self.remotes.get(begin).hash
+        if end and self.remotes.get(end):
+            end = self.remotes.get(end).hash
+
</ins><span class="cx">         branches = [self.default_branch]
</span><del>-        for branch, commits in self.commits.items():
-            if branch == self.default_branch:
-                continue
-            for commit in commits:
-                if commit.hash == end:
-                    branches.insert(0, branch)
</del><ins>+        if end in self.commits.keys() and end != self.default_branch:
+            branches.append(end)
+        else:
+            for branch, commits in self.commits.items():
+                if branch == self.default_branch:
+                    continue
+                for commit in commits:
+                    if commit.hash.startswith(end):
+                        branches.insert(0, branch)
+                        break
+                if len(branches) > 1:
</ins><span class="cx">                     break
</span><del>-            if len(branches) > 1:
-                break
</del><span class="cx"> 
</span><span class="cx">         in_range = False
</span><span class="cx">         previous = None
</span><span class="cx">         for branch in branches:
</span><span class="cx">             for commit in reversed(self.commits[branch]):
</span><del>-                if commit.hash == end:
</del><ins>+                if branch == begin:
+                    break
+                if commit.hash.startswith(end) or end == branch:
</ins><span class="cx">                     in_range = True
</span><span class="cx">                 if in_range and (not previous or commit.hash != previous.hash):
</span><span class="cx">                     yield commit
</span><span class="cx">                 previous = commit
</span><del>-                if commit.hash == begin:
</del><ins>+                if begin and commit.hash.startswith(begin):
</ins><span class="cx">                     in_range = False
</span><ins>+                    break
+
</ins><span class="cx">             in_range = False
</span><span class="cx">             if not previous or branch == self.default_branch:
</span><span class="cx">                 continue
</span></span></pre></div>
<a id="trunkToolsScriptslibrarieswebkitscmpywebkitscmpytestgit_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (278962 => 278963)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py       2021-06-16 22:39:29 UTC (rev 278962)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py  2021-06-16 22:41:35 UTC (rev 278963)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> import unittest
</span><span class="cx"> 
</span><span class="cx"> from datetime import datetime
</span><del>-from webkitcorepy import LoggerCapture, OutputCapture
</del><ins>+from webkitcorepy import run, LoggerCapture, OutputCapture
</ins><span class="cx"> from webkitcorepy.mocks import Time as MockTime
</span><span class="cx"> from webkitscmpy import Commit, local, mocks, remote
</span><span class="cx"> 
</span><span class="lines">@@ -305,7 +305,79 @@
</span><span class="cx">                     git.commit(hash='9b8311f2'),
</span><span class="cx">                 ]), Commit.Encoder().default(list(git.commits(begin=dict(argument='9b8311f2'), end=dict(argument='621652ad')))))
</span><span class="cx"> 
</span><ins>+    def test_log(self):
+        with mocks.local.Git(self.path, git_svn=True):
+            self.assertEqual(
+                run([
+                    local.Git.executable(), 'log', '--format=fuller', 'remotes/origin/main...1abe25b4',
+                ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
+                '''commit d8bce26fa65c6fc8f39c17927abb77f69fab82fc
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 03:46:40 2020 +0000
</ins><span class="cx"> 
</span><ins>+    Patch Series
+    git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit bae5d1e90999d4f916a8a15810ccfa43f37a2fd6
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 03:46:40 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 03:46:40 2020 +0000
+
+    8th commit
+    git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit 1abe25b443e985f93b90d830e4a7e3731336af4d
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 02:23:20 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 02:23:20 2020 +0000
+
+    4th commit
+    git-svn-id: https://svn.example.org/repository/repository/trunk@4 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+'''
+            )
+
+    def test_branch_log(self):
+        with mocks.local.Git(self.path, git_svn=True):
+            self.assertEqual(
+                run([
+                    local.Git.executable(), 'log', '--format=fuller', 'branch-b...main',
+                ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
+                '''commit 790725a6d79e28db2ecdde29548d2262c0bd059d
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 03:30:00 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 03:30:00 2020 +0000
+
+    7th commit
+    git-svn-id: https://svn.example.org/repository/repository/trunk@7 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit 3cd32e352410565bb543821fbf856a6d3caad1c4
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 02:40:00 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 02:40:00 2020 +0000
+
+    5th commit
+        Cherry pick
+        git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+    git-svn-id: https://svn.example.org/repository/repository/trunk@5 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+commit a30ce8494bf1ac2807a69844f726be4a9843ca55
+Author:     Jonathan Bedard <jbedard@apple.com>
+AuthorDate: Sat Oct 03 02:06:40 2020 +0000
+Commit:     Jonathan Bedard <jbedard@apple.com>
+CommitDate: Sat Oct 03 02:06:40 2020 +0000
+
+    3rd commit
+    git-svn-id: https://svn.example.org/repository/repository/trunk@3 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+'''
+            )
+
+
</ins><span class="cx"> class TestGitHub(unittest.TestCase):
</span><span class="cx">     remote = 'https://github.example.com/WebKit/WebKit'
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>