Changeset 270254 in webkit


Ignore:
Timestamp:
Nov 30, 2020 11:23:08 AM (3 years ago)
Author:
Jonathan Bedard
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):

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r270247 r270254  
     12020-11-30  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [webkitscmpy] Support remote repositories in git-webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=219172
     5        <rdar://problem/71594909>
     6
     7        Rubber-stamped by Aakash Jain.
     8
     9        * Scripts/libraries/webkitscmpy/webkitscmpy/program.py:
     10        (Command.parser): Remove repository, since it depends on the parser.
     11        (Command.main): Support arguments to main functions.
     12        (Find.parser): Remove repository, since it depends on the parser.
     13        (Checkout.parser): Ditto.
     14        (Checkout.main): Early return if specified repository is remote.
     15        (main): Construct repository based on path argument.
     16        * Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py:
     17        (TestCheckout):
     18        (TestCheckout.test_checkout_remote):
     19        * Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py:
     20        (TestFind.test_baisc_svn_remote):
     21
    1222020-11-30  Jonathan Bedard  <jbedard@apple.com>
    223
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py

    r270038 r270254  
    4747    )
    4848
    49 version = Version(0, 4, 0)
     49version = Version(0, 4, 1)
    5050
    5151AutoInstall.register(Package('dateutil', Version(2, 8, 1), pypi_name='python-dateutil'))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py

    r269401 r270254  
    2929from datetime import datetime
    3030from webkitcorepy import arguments, log as webkitcorepy_log
    31 from webkitscmpy import Commit, local, log
     31from webkitscmpy import Commit, local, log, remote
    3232
    3333
     
    3737
    3838    @classmethod
    39     def parser(cls, parser, repository):
     39    def parser(cls, parser):
    4040        if cls.name is None:
    4141            raise NotImplementedError('Command does not have a name')
     
    4444
    4545    @classmethod
    46     def main(cls, repository):
     46    def main(cls, args, repository):
    4747        sys.stderr.write('No command specified\n')
    4848        return -1
     
    5454
    5555    @classmethod
    56     def parser(cls, parser, repository, loggers=None):
     56    def parser(cls, parser, loggers=None):
    5757        arguments.LoggingGroup(
    5858            parser,
     
    122122
    123123    @classmethod
    124     def parser(cls, parser, repository, loggers=None):
     124    def parser(cls, parser, loggers=None):
    125125        arguments.LoggingGroup(
    126126            parser,
     
    137137    @classmethod
    138138    def main(cls, args, repository):
     139        if not repository.path:
     140            sys.stderr.write("Cannot checkout on remote repository")
     141            return 1
     142
    139143        try:
    140144            commit = repository.checkout(args.argument[0])
     
    156160    loggers = [logging.getLogger(), webkitcorepy_log,  log] + (loggers or [])
    157161
    158     repository = local.Scm.from_path(path=path or os.getcwd())
    159 
    160162    parser = argparse.ArgumentParser(
    161163        description='Custom git tooling from the WebKit team to interact with a ' +
     
    163165    )
    164166    arguments.LoggingGroup(parser)
     167
     168    group = parser.add_argument_group('Repository')
     169    group.add_argument(
     170        '--path', '-p', '-C',
     171        dest='repository', default=path or os.getcwd(),
     172        help='Set the repository path or URL to be used',
     173        action='store',
     174    )
     175
    165176    subparsers = parser.add_subparsers(help='sub-command help')
    166177
     
    168179        subparser = subparsers.add_parser(program.name, help=program.help)
    169180        subparser.set_defaults(main=program.main)
    170         program.parser(subparser, repository=repository, loggers=loggers)
     181        program.parser(subparser, loggers=loggers)
    171182
    172183    parsed = parser.parse_args(args=args)
    173184
     185    if parsed.repository.startswith(('https://', 'http://')):
     186        repository = remote.Scm.from_url(parsed.repository)
     187    else:
     188        repository = local.Scm.from_path(path=parsed.repository)
     189
    174190    return parsed.main(args=parsed, repository=repository)
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/checkout_unittest.py

    r269401 r270254  
    6363
    6464            self.assertEqual(4, local.Svn(self.path).commit().revision)
     65
     66    def test_checkout_remote(self):
     67        with mocks.remote.Svn(), OutputCapture():
     68            self.assertEqual(1, program.main(
     69                args=('-C', 'https://svn.webkit.org/repository/webkit', 'checkout', '3@trunk'),
     70                path=self.path,
     71            ))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/find_unittest.py

    r269117 r270254  
    5353            self.assertEqual(0, program.main(
    5454                args=('find', 'HEAD', '-q'),
     55                path=self.path,
     56            ))
     57        self.assertEqual(captured.stdout.getvalue(), '4@trunk | r6 | 6th commit\n')
     58
     59    def test_basic_svn_remote(self):
     60        with mocks.remote.Svn(), OutputCapture() as captured:
     61            self.assertEqual(0, program.main(
     62                args=('-C', 'https://svn.webkit.org/repository/webkit', 'find', 'HEAD', '-q'),
    5563                path=self.path,
    5664            ))
Note: See TracChangeset for help on using the changeset viewer.