Modified: trunk/Tools/ChangeLog (283846 => 283847)
--- trunk/Tools/ChangeLog 2021-10-08 22:57:14 UTC (rev 283846)
+++ trunk/Tools/ChangeLog 2021-10-08 23:02:19 UTC (rev 283847)
@@ -1,3 +1,20 @@
+2021-10-08 Jonathan Bedard <jbed...@apple.com>
+
+ [webkitscmpy] Allow caller to differentiate remote branches
+ https://bugs.webkit.org/show_bug.cgi?id=231450
+ <rdar://problem/84042400>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+ (Git.branches): Change _branches_for to branches_for.
+ (Git.branches_for): Allow call to differentiate remote branches
+ to be returned, or return dictionary of all remotes.
+ (Git.commit): Change _branches_for to branches_for.
+ (Git._branches_for): Renamed branches_for.
+
2021-10-08 Michael Catanzaro <mcatanz...@gnome.org>
Ensure webkitpy secret storage works successfully on Linux using only autoinstalled libraries
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (283846 => 283847)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-10-08 22:57:14 UTC (rev 283846)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2021-10-08 23:02:19 UTC (rev 283847)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='2.2.7',
+ version='2.2.8',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (283846 => 283847)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-10-08 22:57:14 UTC (rev 283846)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2021-10-08 23:02:19 UTC (rev 283847)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(2, 2, 7)
+version = Version(2, 2, 8)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('monotonic', Version(1, 5)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (283846 => 283847)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-10-08 22:57:14 UTC (rev 283846)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py 2021-10-08 23:02:19 UTC (rev 283847)
@@ -31,6 +31,7 @@
import time
from datetime import datetime, timedelta
+from collections import defaultdict
from webkitcorepy import run, decorators, NestedFuzzyDict
from webkitscmpy.local import Scm
@@ -275,6 +276,7 @@
GIT_COMMIT = re.compile(r'commit (?P<hash>[0-9a-f]+)')
SSH_REMOTE = re.compile('(ssh://)?git@(?P<host>[^:/]+)[:/](?P<path>.+).git')
HTTP_REMOTE = re.compile('(?P<protocol>https?)://(?P<host>.+)/(?P<path>.+).git')
+ REMOTE_BRANCH = re.compile(r'remotes\/(?P<remote>[^\/]+)\/(?P<branch>.+)')
@classmethod
@decorators.Memoize()
@@ -388,7 +390,7 @@
@property
def branches(self):
- return self._branches_for()
+ return self.branches_for()
@property
def tags(self):
@@ -434,7 +436,7 @@
raise self.Exception('Failed to retrieve revision count for {}'.format(native_parameter))
return int(revision_count.stdout)
- def _branches_for(self, hash=None):
+ def branches_for(self, hash=None, remote=True):
branch = run(
[self.executable(), 'branch', '-a'] + (['--contains', hash] if hash else []),
cwd=self.root_path,
@@ -443,9 +445,22 @@
)
if branch.returncode:
raise self.Exception('Failed to retrieve branch list for {}'.format(self.root_path))
- result = [branch.lstrip(' *') for branch in filter(lambda branch: '->' not in branch, branch.stdout.splitlines())]
- return sorted(set(['/'.join(branch.split('/')[2:]) if branch.startswith('remotes/origin/') else branch for branch in result]))
+ result = defaultdict(set)
+ for branch in [branch.lstrip(' *') for branch in filter(lambda branch: '->' not in branch, branch.stdout.splitlines())]:
+ match = self.REMOTE_BRANCH.match(branch)
+ if match:
+ result[match.group('remote')].add(match.group('branch'))
+ else:
+ result[None].add(branch)
+ if remote is False:
+ return sorted(result[None])
+ if remote is True:
+ return sorted(set.union(*result.values()))
+ if isinstance(remote, str):
+ return sorted(result[remote])
+ return result
+
def commit(self, hash=None, revision=None, identifier=None, branch=None, tag=None, include_log=True, include_identifier=True):
# Only git-svn checkouts can convert revisions to fully qualified commits, unless we happen to have a SVN cache built
if revision:
@@ -514,7 +529,7 @@
baseline = branch or 'HEAD'
is_default = baseline == default_branch
if baseline == 'HEAD':
- is_default = default_branch in self._branches_for(baseline)
+ is_default = default_branch in self.branches_for(baseline)
if is_default and parsed_branch_point:
raise self.Exception('Cannot provide a branch point for a commit on the default branch')
@@ -565,7 +580,7 @@
branch_point = None
# A commit is often on multiple branches, the canonical branch is the one with the highest priority
if branch != default_branch:
- branch = self.prioritize_branches(self._branches_for(hash))
+ branch = self.prioritize_branches(self.branches_for(hash))
if not identifier and include_identifier:
cached_identifier = self.cache.to_identifier(hash=hash, branch=branch) if self.cache else None