Title: [278955] trunk/Tools
Revision
278955
Author
jbed...@apple.com
Date
2021-06-16 14:34:59 -0700 (Wed, 16 Jun 2021)

Log Message

[webkitscmpy] Cache more Git commands
https://bugs.webkit.org/show_bug.cgi?id=227082
<rdar://problem/79405244>

Reviewed by Stephanie Lewis.

* Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.__init__): Reset branch cache.
(Git.default_branch): Memoize default_branch call.
(Git.branch): Prefer branch cache.
(Git.checkout): Reset branch cache.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (278954 => 278955)


--- trunk/Tools/ChangeLog	2021-06-16 20:51:16 UTC (rev 278954)
+++ trunk/Tools/ChangeLog	2021-06-16 21:34:59 UTC (rev 278955)
@@ -1,3 +1,17 @@
+2021-06-16  Jonathan Bedard  <jbed...@apple.com>
+
+        [webkitscmpy] Cache more Git commands
+        https://bugs.webkit.org/show_bug.cgi?id=227082
+        <rdar://problem/79405244>
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git.__init__): Reset branch cache.
+        (Git.default_branch): Memoize default_branch call.
+        (Git.branch): Prefer branch cache.
+        (Git.checkout): Reset branch cache.
+
 2021-06-16  Alicia Boya GarcĂ­a  <ab...@igalia.com>
 
         [WTF] DataMutex: Assert on double locking on the same thread

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (278954 => 278955)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-06-16 20:51:16 UTC (rev 278954)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-06-16 21:34:59 UTC (rev 278955)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='0.14.4',
+    version='0.14.5',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (278954 => 278955)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-06-16 20:51:16 UTC (rev 278954)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-06-16 21:34:59 UTC (rev 278955)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 14, 4)
+version = Version(0, 14, 5)
 
 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 (278954 => 278955)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-06-16 20:51:16 UTC (rev 278954)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-06-16 21:34:59 UTC (rev 278955)
@@ -50,6 +50,7 @@
 
     def __init__(self, path, dev_branches=None, prod_branches=None, contributors=None, id=None):
         super(Git, self).__init__(path, dev_branches=dev_branches, prod_branches=prod_branches, contributors=contributors, id=id)
+        self._branch = None
         if not self.root_path:
             raise OSError('Provided path {} is not a git repository'.format(path))
 
@@ -94,6 +95,7 @@
         return result.stdout.rstrip()
 
     @property
+    @decorators.Memoize()
     def default_branch(self):
         result = run([self.executable(), 'rev-parse', '--abbrev-ref', 'origin/HEAD'], cwd=self.path, capture_output=True, encoding='utf-8')
         if result.returncode:
@@ -107,6 +109,9 @@
 
     @property
     def branch(self):
+        if self._branch:
+            return self._branch
+
         status = run([self.executable(), 'status'], cwd=self.root_path, capture_output=True, encoding='utf-8')
         if status.returncode:
             raise self.Exception('Failed to run `git status` for {}'.format(self.root_path))
@@ -116,7 +121,8 @@
         result = run([self.executable(), 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=self.root_path, capture_output=True, encoding='utf-8')
         if result.returncode:
             raise self.Exception('Failed to retrieve branch for {}'.format(self.root_path))
-        return result.stdout.rstrip()
+        self._branch = result.stdout.rstrip()
+        return self._branch
 
     @property
     def branches(self):
@@ -442,6 +448,8 @@
         if not isinstance(argument, six.string_types):
             raise ValueError("Expected 'argument' to be a string, not '{}'".format(type(argument)))
 
+        self._branch = None
+
         if log.level > logging.WARNING:
             log_arg = ['-q']
         elif log.level < logging.WARNING:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to