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

Unified Diff: trychange.py

Issue 509020: Small cleanups in trychange.py (Closed)
Patch Set: Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trychange.py
diff --git a/trychange.py b/trychange.py
index 35a57433fd16455da69fe5ee5f3f310aefa37ade..cbb99a99b00477ea49ffac6dd3d0cc3f83397622 100755
--- a/trychange.py
+++ b/trychange.py
@@ -116,6 +116,7 @@ class SVN(SCM):
def GetBots(self):
try:
+ # Try to search on the subversion repository for the file.
import gcl
return gcl.GetCachedFile('PRESUBMIT.py', use_root=True)
except ImportError:
@@ -131,7 +132,7 @@ class GIT(SCM):
def __init__(self, *args, **kwargs):
SCM.__init__(self, *args, **kwargs)
self.checkout_root = os.path.abspath(
- gclient_utils.CheckCall(['git', 'rev-parse', '--show-cdup']).strip())
+ scm.GIT.Capture(['rev-parse', '--show-cdup']).strip())
if not self.options.diff:
self.options.diff = self._GenerateDiff()
if not self.options.name:
@@ -145,13 +146,10 @@ class GIT(SCM):
def _GetPatchName(self):
"""Construct a name for this patch."""
- # TODO: perhaps include the hash of the current commit, to distinguish
- # patches?
- branch = gclient_utils.CheckCall(['git', 'symbolic-ref', 'HEAD']).strip()
- if not branch.startswith('refs/heads/'):
- # TODO(maruel): Find a better type.
+ branch_ref = scm.GIT.GetBranchRef(self.checkout_root)
+ branch = scm.GIT.ShortBranchName(branch_ref)
+ if branch == branch_ref:
raise NoTryServerAccess("Couldn't figure out branch name")
- branch = branch[len('refs/heads/'):]
return branch
def GetLocalRoot(self):
@@ -160,6 +158,7 @@ class GIT(SCM):
def GetBots(self):
try:
+ # A git checkout is always a full checkout.
return gclient_utils.FileRead(os.path.join(self.checkout_root,
'PRESUBMIT.py'))
except (IOError, OSError):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698