Title: [268293] trunk/Tools
Revision
268293
Author
[email protected]
Date
2020-10-09 15:24:29 -0700 (Fri, 09 Oct 2020)

Log Message

[webkitscmpy] Handle svn info run from directory
https://bugs.webkit.org/show_bug.cgi?id=217521
<rdar://problem/70144173>

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py:
(Svn.__init__): Set the root_path, so that svn info is run from the top level.
(Svn.info): Rely on root_path, not path.
(Svn.root_path): Use self._root_path instead of self.info() call.
(Svn.list): Rely on root_path, not path.
(Svn._cache_revisions):  Ditto.
(Svn.remote): The repository root will not change during a single command invocation.
(Svn._branch_for): Handle initial branch commits, which. may have non-standard change lists.
(Svn.commit): Rely on root_path, not path, certain svn info calls will not change during
the invocation of a single program.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (268292 => 268293)


--- trunk/Tools/ChangeLog	2020-10-09 22:15:07 UTC (rev 268292)
+++ trunk/Tools/ChangeLog	2020-10-09 22:24:29 UTC (rev 268293)
@@ -1,3 +1,23 @@
+2020-10-09  Jonathan Bedard  <[email protected]>
+
+        [webkitscmpy] Handle svn info run from directory
+        https://bugs.webkit.org/show_bug.cgi?id=217521
+        <rdar://problem/70144173>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py:
+        (Svn.__init__): Set the root_path, so that svn info is run from the top level.
+        (Svn.info): Rely on root_path, not path.
+        (Svn.root_path): Use self._root_path instead of self.info() call.
+        (Svn.list): Rely on root_path, not path.
+        (Svn._cache_revisions):  Ditto.
+        (Svn.remote): The repository root will not change during a single command invocation.
+        (Svn._branch_for): Handle initial branch commits, which. may have non-standard change lists.
+        (Svn.commit): Rely on root_path, not path, certain svn info calls will not change during
+        the invocation of a single program.
+
 2020-10-09  Alex Christensen  <[email protected]>
 
         REGRESSION: [Mac Release] 2 Cookie API are failing

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (268292 => 268293)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2020-10-09 22:15:07 UTC (rev 268292)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2020-10-09 22:24:29 UTC (rev 268293)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 1, 1)
+version = Version(0, 1, 2)
 
 AutoInstall.register(Package('dateutil', Version(2, 8, 1), pypi_name='python-dateutil'))
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py (268292 => 268293)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py	2020-10-09 22:15:07 UTC (rev 268292)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py	2020-10-09 22:24:29 UTC (rev 268293)
@@ -47,6 +47,10 @@
 
     def __init__(self, path, dev_branches=None, prod_branches=None):
         super(Svn, self).__init__(path, dev_branches=dev_branches, prod_branches=prod_branches)
+
+        self._root_path = self.path
+        self._root_path = self.info(cached=False).get('Working Copy Root Path')
+
         if not self.root_path:
             raise OSError('Provided path {} is not a svn repository'.format(path))
 
@@ -66,7 +70,7 @@
         additional_args = ['^/branches/{}'.format(branch)] if branch and branch != self.default_branch else []
         additional_args += ['-r', str(revision)] if revision else []
 
-        info_result = run([self.executable, 'info'] + additional_args, cwd=self.path, capture_output=True, encoding='utf-8')
+        info_result = run([self.executable, 'info'] + additional_args, cwd=self.root_path, capture_output=True, encoding='utf-8')
         if info_result.returncode:
             return {}
 
@@ -82,7 +86,7 @@
 
     @property
     def root_path(self):
-        return self.info(cached=True).get('Working Copy Root Path')
+        return self._root_path
 
     @property
     def default_branch(self):
@@ -96,7 +100,7 @@
         return self.info()['Relative URL'][2:]
 
     def list(self, category):
-        list_result = run([self.executable, 'list', '^/{}'.format(category)], cwd=self.path, capture_output=True, encoding='utf-8')
+        list_result = run([self.executable, 'list', '^/{}'.format(category)], cwd=self.root_path, capture_output=True, encoding='utf-8')
         if list_result.returncode:
             return []
         return [element.rstrip('/') for element in list_result.stdout.splitlines()]
@@ -138,7 +142,7 @@
 
             log = subprocess.Popen(
                 [self.executable, 'log', '-q', branch_arg],
-                cwd=self.path,
+                cwd=self.root_path,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 **kwargs
@@ -192,7 +196,7 @@
         return self._commit_count(revision=self._metadata_cache[branch][0], branch=self.default_branch)
 
     def remote(self, name=None):
-        return self.info()['Repository Root']
+        return self.info(cached=True)['Repository Root']
 
     def _branch_for(self, revision):
         candidates = [branch for branch, revisions in self._metadata_cache.items() if branch != 'version' and revision in revisions]
@@ -204,7 +208,7 @@
 
         process = run(
             [self.executable, 'log', '-v', '-q', self.remote(), '-r', str(revision), '-l', '1'],
-            cwd=self.path, capture_output=True, encoding='utf-8',
+            cwd=self.root_path, capture_output=True, encoding='utf-8',
         )
 
         # If we didn't get a valid answer from the remote, but we found a matching candidate, we return that.
@@ -229,7 +233,7 @@
 
         if len(partial) <= 3:
             raise self.Exception('Malformed set  of edited files')
-        partial = partial[2:]
+        partial = partial[2:].split(' ')[0]
         return partial.split('/')[2 if partial.startswith('/branches') else 1]
 
     def commit(self, hash=None, revision=None, identifier=None, branch=None):
@@ -272,7 +276,7 @@
                 branch = self.default_branch
 
             revision = self._metadata_cache[branch][identifier]
-            info = self.info(branch=branch, revision=revision)
+            info = self.info(cached=True, branch=branch, revision=revision)
             branch = self._branch_for(revision)
 
         elif revision:
@@ -280,7 +284,7 @@
                 raise ValueError('Cannot define both branch and revision')
             revision = Commit._parse_revision(revision, do_assert=True)
             branch = self._branch_for(revision)
-            info = self.info(branch=branch, revision=revision)
+            info = self.info(cached=True, branch=branch, revision=revision)
 
         else:
             branch = branch or self.branch
@@ -318,7 +322,7 @@
 
         branch_arg = '^/{}{}'.format('' if branch == self.default_branch else 'branches/', branch)
         log = run(
-            [self.executable, 'log', '-l', '1', '-r', str(revision), branch_arg], cwd=self.path,
+            [self.executable, 'log', '-l', '1', '-r', str(revision), branch_arg], cwd=self.root_path,
             capture_output=True, encoding='utf-8',
         )
         split_log = log.stdout.splitlines()
@@ -330,7 +334,7 @@
                     break
 
             author = Contributor.from_scm_log(author_line)
-            message = '\n'.join(split_log[3:])
+            message = '\n'.join(split_log[3:-1])
         else:
             self.log('Failed to connect to remote, cannot compute commit message')
             email = info['Last Changed Author']
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to