Title: [270254] trunk/Tools
Revision
270254
Author
[email protected]
Date
2020-11-30 11:23:08 -0800 (Mon, 30 Nov 2020)

Log Message

[webkitscmpy] Support remote repositories in git-webkit
https://bugs.webkit.org/show_bug.cgi?id=219172
<rdar://problem/71594909>

Rubber-stamped by Aakash Jain.

* Scripts/libraries/webkitscmpy/webkitscmpy/program.py:
(Command.parser): Remove repository, since it depends on the parser.
(Command.main): Support arguments to main functions.
(Find.parser): Remove repository, since it depends on the parser.
(Checkout.parser): Ditto.
(Checkout.main): Early return if specified repository is remote.
(main): Construct repository based on path argument.
* Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py:
(TestCheckout):
(TestCheckout.test_checkout_remote):
* Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py:
(TestFind.test_baisc_svn_remote):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (270253 => 270254)


--- trunk/Tools/ChangeLog	2020-11-30 19:20:52 UTC (rev 270253)
+++ trunk/Tools/ChangeLog	2020-11-30 19:23:08 UTC (rev 270254)
@@ -1,5 +1,26 @@
 2020-11-30  Jonathan Bedard  <[email protected]>
 
+        [webkitscmpy] Support remote repositories in git-webkit
+        https://bugs.webkit.org/show_bug.cgi?id=219172
+        <rdar://problem/71594909>
+
+        Rubber-stamped by Aakash Jain.
+
+        * Scripts/libraries/webkitscmpy/webkitscmpy/program.py:
+        (Command.parser): Remove repository, since it depends on the parser.
+        (Command.main): Support arguments to main functions.
+        (Find.parser): Remove repository, since it depends on the parser.
+        (Checkout.parser): Ditto.
+        (Checkout.main): Early return if specified repository is remote.
+        (main): Construct repository based on path argument.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py:
+        (TestCheckout):
+        (TestCheckout.test_checkout_remote):
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py:
+        (TestFind.test_baisc_svn_remote):
+
+2020-11-30  Jonathan Bedard  <[email protected]>
+
         [webkitscmpy] webkitscmpy.test.svn_unittest.TestRemoteSvn.test_info timezone dependent
         https://bugs.webkit.org/show_bug.cgi?id=219263
         <rdar://problem/71806358>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (270253 => 270254)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2020-11-30 19:20:52 UTC (rev 270253)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2020-11-30 19:23:08 UTC (rev 270254)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 4, 0)
+version = Version(0, 4, 1)
 
 AutoInstall.register(Package('dateutil', Version(2, 8, 1), pypi_name='python-dateutil'))
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py (270253 => 270254)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py	2020-11-30 19:20:52 UTC (rev 270253)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py	2020-11-30 19:23:08 UTC (rev 270254)
@@ -28,7 +28,7 @@
 
 from datetime import datetime
 from webkitcorepy import arguments, log as webkitcorepy_log
-from webkitscmpy import Commit, local, log
+from webkitscmpy import Commit, local, log, remote
 
 
 class Command(object):
@@ -36,7 +36,7 @@
     help = None
 
     @classmethod
-    def parser(cls, parser, repository):
+    def parser(cls, parser):
         if cls.name is None:
             raise NotImplementedError('Command does not have a name')
         if cls.help is None:
@@ -43,7 +43,7 @@
             raise NotImplementedError("'{}' does not have a help message")
 
     @classmethod
-    def main(cls, repository):
+    def main(cls, args, repository):
         sys.stderr.write('No command specified\n')
         return -1
 
@@ -53,7 +53,7 @@
     help = 'Given an identifier, revision or hash, normalize and print the commit'
 
     @classmethod
-    def parser(cls, parser, repository, loggers=None):
+    def parser(cls, parser, loggers=None):
         arguments.LoggingGroup(
             parser,
             loggers=loggers,
@@ -121,7 +121,7 @@
     help = 'Given an identifier, revision or hash, normalize and checkout that commit'
 
     @classmethod
-    def parser(cls, parser, repository, loggers=None):
+    def parser(cls, parser, loggers=None):
         arguments.LoggingGroup(
             parser,
             loggers=loggers,
@@ -136,6 +136,10 @@
 
     @classmethod
     def main(cls, args, repository):
+        if not repository.path:
+            sys.stderr.write("Cannot checkout on remote repository")
+            return 1
+
         try:
             commit = repository.checkout(args.argument[0])
         except (local.Scm.Exception, ValueError) as exception:
@@ -155,20 +159,32 @@
 
     loggers = [logging.getLogger(), webkitcorepy_log,  log] + (loggers or [])
 
-    repository = local.Scm.from_path(path=path or os.getcwd())
-
     parser = argparse.ArgumentParser(
         description='Custom git tooling from the WebKit team to interact with a ' +
                     'repository using identifers',
     )
     arguments.LoggingGroup(parser)
+
+    group = parser.add_argument_group('Repository')
+    group.add_argument(
+        '--path', '-p', '-C',
+        dest='repository', default=path or os.getcwd(),
+        help='Set the repository path or URL to be used',
+        action='',
+    )
+
     subparsers = parser.add_subparsers(help='sub-command help')
 
     for program in [Find, Checkout]:
         subparser = subparsers.add_parser(program.name, help=program.help)
         subparser.set_defaults(main=program.main)
-        program.parser(subparser, repository=repository, loggers=loggers)
+        program.parser(subparser, loggers=loggers)
 
     parsed = parser.parse_args(args=args)
 
+    if parsed.repository.startswith(('https://', 'http://')):
+        repository = remote.Scm.from_url(parsed.repository)
+    else:
+        repository = local.Scm.from_path(path=parsed.repository)
+
     return parsed.main(args=parsed, repository=repository)

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py (270253 => 270254)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py	2020-11-30 19:20:52 UTC (rev 270253)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py	2020-11-30 19:23:08 UTC (rev 270254)
@@ -62,3 +62,10 @@
             ))
 
             self.assertEqual(4, local.Svn(self.path).commit().revision)
+
+    def test_checkout_remote(self):
+        with mocks.remote.Svn(), OutputCapture():
+            self.assertEqual(1, program.main(
+                args=('-C', 'https://svn.webkit.org/repository/webkit', 'checkout', '3@trunk'),
+                path=self.path,
+            ))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py (270253 => 270254)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py	2020-11-30 19:20:52 UTC (rev 270253)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py	2020-11-30 19:23:08 UTC (rev 270254)
@@ -56,6 +56,14 @@
             ))
         self.assertEqual(captured.stdout.getvalue(), '4@trunk | r6 | 6th commit\n')
 
+    def test_basic_svn_remote(self):
+        with mocks.remote.Svn(), OutputCapture() as captured:
+            self.assertEqual(0, program.main(
+                args=('-C', 'https://svn.webkit.org/repository/webkit', 'find', 'HEAD', '-q'),
+                path=self.path,
+            ))
+        self.assertEqual(captured.stdout.getvalue(), '4@trunk | r6 | 6th commit\n')
+
     def test_branch_tilde(self):
         with mocks.local.Git(self.path, git_svn=True), mocks.local.Svn(), MockTime, OutputCapture() as captured:
             self.assertEqual(0, program.main(
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to