Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: git_cl.py

Issue 2032433003: git cl issue 0 should really clear issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 """Set this branch's issue. If issue isn't given, clears the issue.""" 1248 """Set this branch's issue. If issue isn't given, clears the issue."""
1249 issue_setting = self._codereview_impl.IssueSetting(self.GetBranch()) 1249 issue_setting = self._codereview_impl.IssueSetting(self.GetBranch())
1250 codereview_setting = self._codereview_impl.GetCodereviewServerSetting() 1250 codereview_setting = self._codereview_impl.GetCodereviewServerSetting()
1251 if issue: 1251 if issue:
1252 self.issue = issue 1252 self.issue = issue
1253 RunGit(['config', issue_setting, str(issue)]) 1253 RunGit(['config', issue_setting, str(issue)])
1254 codereview_server = self._codereview_impl.GetCodereviewServer() 1254 codereview_server = self._codereview_impl.GetCodereviewServer()
1255 if codereview_server: 1255 if codereview_server:
1256 RunGit(['config', codereview_setting, codereview_server]) 1256 RunGit(['config', codereview_setting, codereview_server])
1257 else: 1257 else:
1258 current_issue = self.GetIssue() 1258 # Reset it regardless. It doesn't hurt.
1259 if current_issue: 1259 config_settings = [issue_setting, self._codereview_impl.PatchsetSetting()]
1260 RunGit(['config', '--unset', issue_setting]) 1260 for prop in (['last-upload-hash'] +
1261 self._codereview_impl._PostUnsetIssueProperties()):
1262 config_settings.append('branch.%s.%s' % (self.GetBranch(), prop))
1263 for setting in config_settings:
1264 RunGit(['config', '--unset', setting], error_ok=True)
1261 self.issue = None 1265 self.issue = None
1262 self.SetPatchset(None) 1266 self.patchset = None
1263 1267
1264 def GetChange(self, upstream_branch, author): 1268 def GetChange(self, upstream_branch, author):
1265 if not self.GitSanityChecks(upstream_branch): 1269 if not self.GitSanityChecks(upstream_branch):
1266 DieWithError('\nGit sanity check failure') 1270 DieWithError('\nGit sanity check failure')
1267 1271
1268 root = settings.GetRelativeRoot() 1272 root = settings.GetRelativeRoot()
1269 if not root: 1273 if not root:
1270 root = '.' 1274 root = '.'
1271 absroot = os.path.abspath(root) 1275 absroot = os.path.abspath(root)
1272 1276
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 @classmethod 1494 @classmethod
1491 def IssueSettingSuffix(cls): 1495 def IssueSettingSuffix(cls):
1492 """Returns name of git config setting which stores issue number for a given 1496 """Returns name of git config setting which stores issue number for a given
1493 branch.""" 1497 branch."""
1494 raise NotImplementedError() 1498 raise NotImplementedError()
1495 1499
1496 def PatchsetSetting(self): 1500 def PatchsetSetting(self):
1497 """Returns name of git config setting which stores issue number.""" 1501 """Returns name of git config setting which stores issue number."""
1498 raise NotImplementedError() 1502 raise NotImplementedError()
1499 1503
1504 def _PostUnsetIssueProperties(self):
1505 """Which branch-specific properties to erase when unsettin issue."""
1506 raise NotImplementedError()
1507
1500 def GetRieveldObjForPresubmit(self): 1508 def GetRieveldObjForPresubmit(self):
1501 # This is an unfortunate Rietveld-embeddedness in presubmit. 1509 # This is an unfortunate Rietveld-embeddedness in presubmit.
1502 # For non-Rietveld codereviews, this probably should return a dummy object. 1510 # For non-Rietveld codereviews, this probably should return a dummy object.
1503 raise NotImplementedError() 1511 raise NotImplementedError()
1504 1512
1505 def GetGerritObjForPresubmit(self): 1513 def GetGerritObjForPresubmit(self):
1506 # None is valid return value, otherwise presubmit_support.GerritAccessor. 1514 # None is valid return value, otherwise presubmit_support.GerritAccessor.
1507 return None 1515 return None
1508 1516
1509 def UpdateDescriptionRemote(self, description): 1517 def UpdateDescriptionRemote(self, description):
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 """Return the git setting that stores this change's most recent patchset.""" 1739 """Return the git setting that stores this change's most recent patchset."""
1732 return 'branch.%s.rietveldpatchset' % self.GetBranch() 1740 return 'branch.%s.rietveldpatchset' % self.GetBranch()
1733 1741
1734 def GetCodereviewServerSetting(self): 1742 def GetCodereviewServerSetting(self):
1735 """Returns the git setting that stores this change's rietveld server.""" 1743 """Returns the git setting that stores this change's rietveld server."""
1736 branch = self.GetBranch() 1744 branch = self.GetBranch()
1737 if branch: 1745 if branch:
1738 return 'branch.%s.rietveldserver' % branch 1746 return 'branch.%s.rietveldserver' % branch
1739 return None 1747 return None
1740 1748
1749 def _PostUnsetIssueProperties(self):
1750 """Which branch-specific properties to erase when unsetting issue."""
1751 return ['rietveldserver']
1752
1741 def GetRieveldObjForPresubmit(self): 1753 def GetRieveldObjForPresubmit(self):
1742 return self.RpcServer() 1754 return self.RpcServer()
1743 1755
1744 def SetCQState(self, new_state): 1756 def SetCQState(self, new_state):
1745 props = self.GetIssueProperties() 1757 props = self.GetIssueProperties()
1746 if props.get('private'): 1758 if props.get('private'):
1747 DieWithError('Cannot set-commit on private issue') 1759 DieWithError('Cannot set-commit on private issue')
1748 1760
1749 if new_state == _CQState.COMMIT: 1761 if new_state == _CQState.COMMIT:
1750 self.SetFlag('commit', '1') 1762 self.SetFlag('commit', '1')
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 """Return the git setting that stores this change's most recent patchset.""" 2099 """Return the git setting that stores this change's most recent patchset."""
2088 return 'branch.%s.gerritpatchset' % self.GetBranch() 2100 return 'branch.%s.gerritpatchset' % self.GetBranch()
2089 2101
2090 def GetCodereviewServerSetting(self): 2102 def GetCodereviewServerSetting(self):
2091 """Returns the git setting that stores this change's Gerrit server.""" 2103 """Returns the git setting that stores this change's Gerrit server."""
2092 branch = self.GetBranch() 2104 branch = self.GetBranch()
2093 if branch: 2105 if branch:
2094 return 'branch.%s.gerritserver' % branch 2106 return 'branch.%s.gerritserver' % branch
2095 return None 2107 return None
2096 2108
2109 def _PostUnsetIssueProperties(self):
2110 """Which branch-specific properties to erase when unsetting issue."""
2111 return [
2112 'gerritserver',
2113 'gerritsquashhash',
2114 ]
2115
2097 def GetRieveldObjForPresubmit(self): 2116 def GetRieveldObjForPresubmit(self):
2098 class ThisIsNotRietveldIssue(object): 2117 class ThisIsNotRietveldIssue(object):
2099 def __nonzero__(self): 2118 def __nonzero__(self):
2100 # This is a hack to make presubmit_support think that rietveld is not 2119 # This is a hack to make presubmit_support think that rietveld is not
2101 # defined, yet still ensure that calls directly result in a decent 2120 # defined, yet still ensure that calls directly result in a decent
2102 # exception message below. 2121 # exception message below.
2103 return False 2122 return False
2104 2123
2105 def __getattr__(self, attr): 2124 def __getattr__(self, attr):
2106 print( 2125 print(
(...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 if __name__ == '__main__': 4907 if __name__ == '__main__':
4889 # These affect sys.stdout so do it outside of main() to simplify mocks in 4908 # These affect sys.stdout so do it outside of main() to simplify mocks in
4890 # unit testing. 4909 # unit testing.
4891 fix_encoding.fix_encoding() 4910 fix_encoding.fix_encoding()
4892 setup_color.init() 4911 setup_color.init()
4893 try: 4912 try:
4894 sys.exit(main(sys.argv[1:])) 4913 sys.exit(main(sys.argv[1:]))
4895 except KeyboardInterrupt: 4914 except KeyboardInterrupt:
4896 sys.stderr.write('interrupted\n') 4915 sys.stderr.write('interrupted\n')
4897 sys.exit(1) 4916 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698