WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
215960
[webkitscmpy] Add root, branch and remote for local SCM repositories
https://bugs.webkit.org/show_bug.cgi?id=215960
Summary
[webkitscmpy] Add root, branch and remote for local SCM repositories
Jonathan Bedard
Reported
2020-08-28 16:47:05 PDT
Start the task of creating local SCM objects to represent git and svn checkouts. The goal here is create a shared API between SVN and Git, along with remote representations of those same repositories.
Attachments
Patch
(36.07 KB, patch)
2020-08-28 16:57 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(36.73 KB, patch)
2020-08-31 09:55 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(37.91 KB, patch)
2020-08-31 15:26 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(37.26 KB, patch)
2020-09-02 16:55 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(38.31 KB, patch)
2020-09-03 15:40 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch for landing
(38.95 KB, patch)
2020-09-04 11:45 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2020-08-28 16:47:25 PDT
<
rdar://problem/67968919
>
Jonathan Bedard
Comment 2
2020-08-28 16:57:32 PDT
Created
attachment 407517
[details]
Patch
Jonathan Bedard
Comment 3
2020-08-31 09:55:26 PDT
Created
attachment 407608
[details]
Patch
Zhifei Fang
Comment 4
2020-08-31 10:55:50 PDT
Comment on
attachment 407608
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407608&action=review
> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:42 > + def root(self):
Not sure if "root" is the right name, this is returning top level directory path of a working tree (git) or a working copy (svn), maybe top_level_path / root_path ? Besides do we consider to make this an argument ?
> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:50 > + result = run([self.executable, 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=self.root, capture_output=True, encoding='utf-8')
This won't work in detached head state, for example you directly checkout with commit hash, we need to detect this state, otherwise it will return "HEAD" instead of an empty string, "git branch --show-current" will return an empty string, and should make this method failed quickly
> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:33 > + self.remote = remote or '
git@github.org
:/mock/{}'.format(os.path.basename(path))
maybe we shouldn't use GitHub in the mock path
Jonathan Bedard
Comment 5
2020-08-31 15:21:24 PDT
Comment on
attachment 407608
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407608&action=review
>> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:42 >> + def root(self): > > Not sure if "root" is the right name, this is returning top level directory path of a working tree (git) or a working copy (svn), maybe top_level_path / root_path ? > Besides do we consider to make this an argument ?
The point of this is so that if a user constructs a repository at a location, we know what the root of the working tree is (basically, making it so that "Git(os.path.dirname(__file__))" works.
Jonathan Bedard
Comment 6
2020-08-31 15:26:17 PDT
Created
attachment 407630
[details]
Patch
dewei_zhu
Comment 7
2020-09-02 16:08:08 PDT
Comment on
attachment 407630
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407630&action=review
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:32 > + self.cached = cached
What's the purpose of this variable? Why do we want a memoizer that does not cache result?
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:37 > + timeout = kwargs.get('timeout', self.timeout) > + cached = kwargs.get('cached', self.cached)
What happens if the wrapped function actually uses `timeout` and `cached` for different purpose?
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:48 > + cache = function(*args)
Also, I think we should pass '**kwargs' here?
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:53 > + decorator.clear = lambda: self.clear()
Why not just decorator.clear = self.clear?
Jonathan Bedard
Comment 8
2020-09-02 16:19:12 PDT
Comment on
attachment 407630
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407630&action=review
>> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:32 >> + self.cached = cached > > What's the purpose of this variable? Why do we want a memoizer that does not cache result?
We may want a memoizer which does not cache by default. That would allow you to have a function call which explicitly opted in to the cached behavior. It's basically the reverse of what I would imagine most usages of the class will be: default caching, except for some calls which opt out of caching. We don't have to keep this, it just seemed silly not to given how decorator was implemented.
>> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:37 >> + cached = kwargs.get('cached', self.cached) > > What happens if the wrapped function actually uses `timeout` and `cached` for different purpose?
We would be passing those arguments in both spots. Suppose we should probably pop them instead, so they don't get forwarded.
>> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:48 >> + cache = function(*args) > > Also, I think we should pass '**kwargs' here?
Oops, yes!
Jonathan Bedard
Comment 9
2020-09-02 16:55:49 PDT
Created
attachment 407833
[details]
Patch
dewei_zhu
Comment 10
2020-09-03 15:02:42 PDT
Comment on
attachment 407833
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407833&action=review
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:46 > + if cache: > + return cache
Does this mean a function that returns None will always not cached even when 'None' is a valid return of the function? We may want to differentiate that in the code.
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/decorators_unittest.py:31 > +
It would be great to test a function that throws an exception and the exception should be raised as expected.
Jonathan Bedard
Comment 11
2020-09-03 15:30:15 PDT
Comment on
attachment 407833
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407833&action=review
>> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/decorators.py:46 >> + return cache > > Does this mean a function that returns None will always not cached even when 'None' is a valid return of the function? > We may want to differentiate that in the code.
Oops! Yes it does
Jonathan Bedard
Comment 12
2020-09-03 15:40:54 PDT
Created
attachment 407923
[details]
Patch
Jonathan Bedard
Comment 13
2020-09-04 11:45:15 PDT
Created
attachment 408007
[details]
Patch for landing
EWS
Comment 14
2020-09-04 12:12:21 PDT
Committed
r266628
: <
https://trac.webkit.org/changeset/266628
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 408007
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug