Commit fa3fb615 authored by tandrii@chromium.org's avatar tandrii@chromium.org

Revert of git cl: Rework Changelist class for Rietveld/Gerrit use. (patchset...

Revert of git cl: Rework Changelist class for Rietveld/Gerrit use. (patchset #1 id:1 of https://codereview.chromium.org/1844523002/ )

Reason for revert:
argh, CQ is way too quick.

Original issue's description:
> Reland of git cl: Rework Changelist class for Rietveld/Gerrit use. (patchset #1 id:1 of https://codereview.chromium.org/1840833002/ )
> 
> Reason for revert:
> with a fix.
> 
> Original issue's description:
> > Revert of git cl: Rework Changelist class for Rietveld/Gerrit use. (patchset #3 id:40001 of https://codereview.chromium.org/1830973003/ )
> > 
> > Reason for revert:
> > Speculative revert, see crbug.com/598428.
> > 
> > Original issue's description:
> > > git cl: Rework Changelist class for Rietveld/Gerrit use.
> > > 
> > > This adds pluggable codereview-specific implementations into
> > > Changelist class. The specific implementation is chosen at
> > > Changelist automatically, with Rietveld being default for
> > > backwards compatibility.
> > > 
> > > Gerrit implementation for Gerrit is incomplete, and will be
> > > added in later CLs. However, it is sufficient to ensure
> > > current functionality of this tool is not diminished.
> > > 
> > > Sadly, the base class isn't completely free from Rietveld
> > > assumptions because of presubmit_support. Apparently, PRESUBMIT
> > > scripts can make use of Rietveld instance for RPCs directly.
> > > This use doesn't make sense for Gerrit, which substitutes
> > > rietveld instance with a dummy object, which raises exception
> > > on any attribute access with a diagnostic message.
> > > 
> > > This also includes refactoring of some related code which
> > > (ab)used ChangeList. Overall, this CL adds a few extra call to
> > > git config in order to determine which codereview to use, but
> > > but it shouldn't have any performance impact.
> > > 
> > > 
> > > 
> > > These is a reland of these 4 CLs + a fix.
> > > patch from issue 1827523003 at patchset 20001 (http://crrev.com/1827523003#ps20001)
> > > patch from issue 1830703004 at patchset 1 (http://crrev.com/1830703004#ps1)
> > > patch from issue 1830923002 at patchset 60001 (http://crrev.com/1830923002#ps60001)
> > > patch from issue 1805193002 at patchset 380001 (http://crrev.com/1805193002#ps380001)
> > > 
> > > 
> > > 
> > > R=machenbach@chromium.org,sergiyb@chromium.org,andybons@chromium.org
> > > BUG=579160,597638
> > > 
> > > Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=299506
> > 
> > TBR=andybons@chromium.org,machenbach@chromium.org,sergiyb@chromium.org,tandrii@chromium.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=579160,597638
> > 
> > Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=299515
> 
> TBR=andybons@chromium.org,machenbach@chromium.org,sergiyb@chromium.org,dnj@chromium.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=579160,597638
> 
> Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=299528

TBR=andybons@chromium.org,machenbach@chromium.org,sergiyb@chromium.org,dnj@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=579160,597638

Review URL: https://codereview.chromium.org/1839973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299529 0039d316-1c4b-4281-b951-d872f2087c98
parent 278a25d2
This diff is collapsed.
...@@ -163,21 +163,20 @@ class TestGitCl(TestCase): ...@@ -163,21 +163,20 @@ class TestGitCl(TestCase):
'-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat') '-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat')
return [ return [
((['git', 'config', 'rietveld.autoupdate'],), ''),
((['git', 'config', 'rietveld.server'],),
'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
similarity_call, similarity_call,
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
find_copies_call, find_copies_call,
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.rietveldissue'],), ''),
((['git', 'config', 'branch.master.gerritissue'],), ''),
((['git', 'config', 'rietveld.autoupdate'],), ''),
((['git', 'config', 'gerrit.host'],), ''),
((['git', 'config', 'rietveld.server'],),
'codereview.example.com'),
((['git', 'config', 'branch.master.merge'],), 'master'), ((['git', 'config', 'branch.master.merge'],), 'master'),
((['git', 'config', 'branch.master.remote'],), 'origin'), ((['git', 'config', 'branch.master.remote'],), 'origin'),
((['get_or_create_merge_base', 'master', 'master'],), ((['get_or_create_merge_base', 'master', 'master'],),
'fake_ancestor_sha'), 'fake_ancestor_sha'),
((['git', 'config', 'gerrit.host'],), ''),
((['git', 'config', 'branch.master.rietveldissue'],), ''),
] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [
((['git', 'rev-parse', '--show-cdup'],), ''), ((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'rev-parse', 'HEAD'],), '12345'), ((['git', 'rev-parse', 'HEAD'],), '12345'),
...@@ -280,6 +279,8 @@ class TestGitCl(TestCase): ...@@ -280,6 +279,8 @@ class TestGitCl(TestCase):
'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'),
None), None),
0)), 0)),
((['git',
'config', 'rietveld.server'],), 'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'),
((['git', 'config', '--int', '--get', ((['git', 'config', '--int', '--get',
'branch.working.git-cl-similarity'],), ''), 'branch.working.git-cl-similarity'],), ''),
...@@ -287,10 +288,6 @@ class TestGitCl(TestCase): ...@@ -287,10 +288,6 @@ class TestGitCl(TestCase):
((['git', 'config', '--int', '--get', ((['git', 'config', '--int', '--get',
'branch.working.git-find-copies'],), ''), 'branch.working.git-find-copies'],), ''),
((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'),
((['git',
'config', 'branch.working.rietveldissue'],), '12345'),
((['git',
'config', 'rietveld.server'],), 'codereview.example.com'),
((['git', ((['git',
'config', 'branch.working.merge'],), 'refs/heads/master'), 'config', 'branch.working.merge'],), 'refs/heads/master'),
((['git', 'config', 'branch.working.remote'],), 'origin'), ((['git', 'config', 'branch.working.remote'],), 'origin'),
...@@ -324,6 +321,8 @@ class TestGitCl(TestCase): ...@@ -324,6 +321,8 @@ class TestGitCl(TestCase):
'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...',
'.'],), '.'],),
'M\tPRESUBMIT.py'), 'M\tPRESUBMIT.py'),
((['git',
'config', 'branch.working.rietveldissue'],), '12345'),
((['git', ((['git',
'config', 'branch.working.rietveldpatchset'],), '31137'), 'config', 'branch.working.rietveldpatchset'],), '31137'),
((['git', 'config', 'branch.working.rietveldserver'],), ((['git', 'config', 'branch.working.rietveldserver'],),
...@@ -335,6 +334,8 @@ class TestGitCl(TestCase): ...@@ -335,6 +334,8 @@ class TestGitCl(TestCase):
@classmethod @classmethod
def _dcommit_calls_bypassed(cls): def _dcommit_calls_bypassed(cls):
return [ return [
((['git',
'config', 'branch.working.rietveldissue'],), '12345'),
((['git', 'config', 'branch.working.rietveldserver'],), ((['git', 'config', 'branch.working.rietveldserver'],),
'codereview.example.com'), 'codereview.example.com'),
] ]
...@@ -342,6 +343,7 @@ class TestGitCl(TestCase): ...@@ -342,6 +343,7 @@ class TestGitCl(TestCase):
@classmethod @classmethod
def _dcommit_calls_3(cls): def _dcommit_calls_3(cls):
return [ return [
((['git', 'config', 'gerrit.host'],), ''),
((['git', ((['git',
'diff', '--no-ext-diff', '--stat', '--find-copies-harder', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder',
'-l100000', '-C50', 'fake_ancestor_sha', '-l100000', '-C50', 'fake_ancestor_sha',
...@@ -544,6 +546,10 @@ class TestGitCl(TestCase): ...@@ -544,6 +546,10 @@ class TestGitCl(TestCase):
@classmethod @classmethod
def _gerrit_base_calls(cls): def _gerrit_base_calls(cls):
return [ return [
((['git', 'config', 'rietveld.autoupdate'],),
''),
((['git',
'config', 'rietveld.server'],), 'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', '--int', '--get', ((['git', 'config', '--int', '--get',
'branch.master.git-cl-similarity'],), ''), 'branch.master.git-cl-similarity'],), ''),
...@@ -551,22 +557,21 @@ class TestGitCl(TestCase): ...@@ -551,22 +557,21 @@ class TestGitCl(TestCase):
((['git', 'config', '--int', '--get', ((['git', 'config', '--int', '--get',
'branch.master.git-find-copies'],), ''), 'branch.master.git-find-copies'],), ''),
((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.rietveldissue'],), ''),
((['git', 'config', 'branch.master.gerritissue'],), ''),
((['git', 'config', 'rietveld.autoupdate'],), ''),
((['git', 'config', 'gerrit.host'],), 'True'),
((['git', 'config', 'branch.master.merge'],), 'master'), ((['git', 'config', 'branch.master.merge'],), 'master'),
((['git', 'config', 'branch.master.remote'],), 'origin'), ((['git', 'config', 'branch.master.remote'],), 'origin'),
((['get_or_create_merge_base', 'master', 'master'],), ((['get_or_create_merge_base', 'master', 'master'],),
'fake_ancestor_sha'), 'fake_ancestor_sha'),
] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ ((['git', 'config', 'gerrit.host'],), 'True'),
] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [
((['git', 'rev-parse', '--show-cdup'],), ''), ((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'rev-parse', 'HEAD'],), '12345'), ((['git', 'rev-parse', 'HEAD'],), '12345'),
((['git', ((['git',
'diff', '--name-status', '--no-renames', '-r', 'diff', '--name-status', '--no-renames', '-r',
'fake_ancestor_sha...', '.'],), 'fake_ancestor_sha...', '.'],),
'M\t.gitignore\n'), 'M\t.gitignore\n'),
((['git', 'config', 'branch.master.gerritpatchset'],), ''), ((['git', 'config', 'branch.master.rietveldissue'],), ''),
((['git',
'config', 'branch.master.rietveldpatchset'],), ''),
((['git', ((['git',
'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],),
'foo'), 'foo'),
...@@ -575,7 +580,7 @@ class TestGitCl(TestCase): ...@@ -575,7 +580,7 @@ class TestGitCl(TestCase):
'diff', '--no-ext-diff', '--stat', '--find-copies-harder', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder',
'-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],), '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],),
'+dat'), '+dat'),
] ]
@classmethod @classmethod
def _gerrit_upload_calls(cls, description, reviewers, squash, def _gerrit_upload_calls(cls, description, reviewers, squash,
...@@ -657,12 +662,7 @@ class TestGitCl(TestCase): ...@@ -657,12 +662,7 @@ class TestGitCl(TestCase):
] ]
if squash: if squash:
calls += [ calls += [
((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), ((['git', 'config', 'branch.master.rietveldissue', '123456'],), ''),
((['git', 'config', 'branch.master.gerritserver'],), ''),
((['git', 'config', 'remote.origin.url'],),
'https://chromium.googlesource.com/my/repo.git'),
((['git', 'config', 'branch.master.gerritserver',
'https://chromium-review.googlesource.com'],), ''),
((['git', 'rev-parse', 'HEAD'],), 'abcdef0123456789'), ((['git', 'rev-parse', 'HEAD'],), 'abcdef0123456789'),
((['git', 'update-ref', '-m', 'Uploaded abcdef0123456789', ((['git', 'update-ref', '-m', 'Uploaded abcdef0123456789',
'refs/heads/git_cl_uploads/master', 'abcdef0123456789'],), 'refs/heads/git_cl_uploads/master', 'abcdef0123456789'],),
...@@ -886,12 +886,9 @@ class TestGitCl(TestCase): ...@@ -886,12 +886,9 @@ class TestGitCl(TestCase):
self.assertNotEqual(git_cl.main(['diff']), 0) self.assertNotEqual(git_cl.main(['diff']), 0)
def _patch_common(self): def _patch_common(self):
self.mock(git_cl._RietveldChangelistImpl, 'GetMostRecentPatchset', self.mock(git_cl.Changelist, 'GetMostRecentPatchset', lambda x: '60001')
lambda x: '60001') self.mock(git_cl.Changelist, 'GetPatchSetDiff', lambda *args: None)
self.mock(git_cl._RietveldChangelistImpl, 'GetPatchSetDiff', self.mock(git_cl.Changelist, 'GetDescription', lambda *args: 'Description')
lambda *args: None)
self.mock(git_cl.Changelist, 'GetDescription',
lambda *args: 'Description')
self.mock(git_cl.Changelist, 'SetIssue', lambda *args: None) self.mock(git_cl.Changelist, 'SetIssue', lambda *args: None)
self.mock(git_cl.Changelist, 'SetPatchset', lambda *args: None) self.mock(git_cl.Changelist, 'SetPatchset', lambda *args: None)
self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True) self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True)
...@@ -911,8 +908,6 @@ class TestGitCl(TestCase): ...@@ -911,8 +908,6 @@ class TestGitCl(TestCase):
'Description\n\n' + 'Description\n\n' +
'patch from issue 123456 at patchset 60001 ' + 'patch from issue 123456 at patchset 60001 ' +
'(http://crrev.com/123456#ps60001)'],), ''), '(http://crrev.com/123456#ps60001)'],), ''),
((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.rietveldserver'],), ''),
] ]
self.assertEqual(git_cl.main(['patch', '123456']), 0) self.assertEqual(git_cl.main(['patch', '123456']), 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment