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

Side by Side Diff: tools/push-to-trunk/git_recipes.py

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/merge_to_branch.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following
11 # disclaimer in the documentation and/or other materials provided
12 # with the distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import re
30
31 def Strip(f):
32 def new_f(*args, **kwargs):
33 return f(*args, **kwargs).strip()
34 return new_f
35
36
37 def MakeArgs(l):
38 """['-a', '', 'abc', ''] -> '-a abc'"""
39 return " ".join(filter(None, l))
40
41
42 def Quoted(s):
43 return "\"%s\"" % s
44
45
46 class GitRecipesMixin(object):
47 def GitIsWorkdirClean(self):
48 return self.Git("status -s -uno").strip() == ""
49
50 @Strip
51 def GitBranch(self):
52 return self.Git("branch")
53
54 def GitCreateBranch(self, name, branch=""):
55 assert name
56 self.Git(MakeArgs(["checkout -b", name, branch]))
57
58 def GitDeleteBranch(self, name):
59 assert name
60 self.Git(MakeArgs(["branch -D", name]))
61
62 def GitCheckout(self, name):
63 assert name
64 self.Git(MakeArgs(["checkout -f", name]))
65
66 @Strip
67 def GitCurrentBranch(self):
68 for line in self.Git("status -s -b -uno").strip().splitlines():
69 match = re.match(r"^## (.+)", line)
70 if match: return match.group(1)
71 raise Exception("Couldn't find curent branch.")
72
73 @Strip
74 def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
75 branch="", reverse=False):
76 assert not (git_hash and parent_hash)
77 args = ["log"]
78 if n > 0:
79 args.append("-%d" % n)
80 if format:
81 args.append("--format=%s" % format)
82 if grep:
83 args.append("--grep=\"%s\"" % grep)
84 if reverse:
85 args.append("--reverse")
86 if git_hash:
87 args.append(git_hash)
88 if parent_hash:
89 args.append("%s^" % parent_hash)
90 args.append(branch)
91 return self.Git(MakeArgs(args))
92
93 def GitGetPatch(self, git_hash):
94 assert git_hash
95 return self.Git(MakeArgs(["log", "-1", "-p", git_hash]))
96
97 def GitAdd(self, name):
98 assert name
99 self.Git(MakeArgs(["add", Quoted(name)]))
100
101 def GitApplyPatch(self, patch_file, reverse=False):
102 assert patch_file
103 args = ["apply --index --reject"]
104 if reverse:
105 args.append("--reverse")
106 args.append(Quoted(patch_file))
107 self.Git(MakeArgs(args))
108
109 def GitUpload(self, reviewer="", author="", force=False):
110 args = ["cl upload --send-mail"]
111 if author:
112 args += ["--email", Quoted(author)]
113 if reviewer:
114 args += ["-r", Quoted(reviewer)]
115 if force:
116 args.append("-f")
117 # TODO(machenbach): Check output in forced mode. Verify that all required
118 # base files were uploaded, if not retry.
119 self.Git(MakeArgs(args), pipe=False)
120
121 def GitCommit(self, message="", file_name=""):
122 assert message or file_name
123 args = ["commit"]
124 if file_name:
125 args += ["-aF", Quoted(file_name)]
126 if message:
127 args += ["-am", Quoted(message)]
128 self.Git(MakeArgs(args))
129
130 def GitPresubmit(self):
131 self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"")
132
133 def GitDCommit(self):
134 self.Git("cl dcommit -f --bypass-hooks", retry_on=lambda x: x is None)
135
136 def GitDiff(self, loc1, loc2):
137 return self.Git(MakeArgs(["diff", loc1, loc2]))
138
139 def GitPull(self):
140 self.Git("pull")
141
142 def GitSVNFetch(self):
143 self.Git("svn fetch")
144
145 @Strip
146 def GitSVNLog(self):
147 return self.Git("svn log -1 --oneline")
148
149 @Strip
150 def GitSVNFindGitHash(self, revision, branch=""):
151 assert revision
152 return self.Git(MakeArgs(["svn find-rev", "r%s" % revision, branch]))
153
154 @Strip
155 def GitSVNFindSVNRev(self, git_hash, branch=""):
156 return self.Git(MakeArgs(["svn find-rev", git_hash, branch]))
157
158 def GitSVNDCommit(self):
159 return self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None)
160
161 def GitSVNTag(self, version):
162 self.Git(("svn tag %s -m \"Tagging version %s\"" % (version, version)),
163 retry_on=lambda x: x is None)
OLDNEW
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/merge_to_branch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698