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

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

Issue 101763002: Make squash commits step more pythony in push-to-trunk script. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.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 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 class SquashCommits(Step): 250 class SquashCommits(Step):
251 MESSAGE = "Squash commits into one." 251 MESSAGE = "Squash commits into one."
252 252
253 def RunStep(self): 253 def RunStep(self):
254 # Instead of relying on "git rebase -i", we'll just create a diff, because 254 # Instead of relying on "git rebase -i", we'll just create a diff, because
255 # that's easier to automate. 255 # that's easier to automate.
256 self.RestoreIfUnset("prepare_commit_hash") 256 self.RestoreIfUnset("prepare_commit_hash")
257 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"] 257 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"]
258 TextToFile(self.Git(args), self.Config(PATCH_FILE)) 258 TextToFile(self.Git(args), self.Config(PATCH_FILE))
259 259
260 # Convert the ChangeLog entry to commit message format: 260 # Convert the ChangeLog entry to commit message format.
261 # - remove date
262 # - remove indentation
263 # - merge paragraphs into single long lines, keeping empty lines between
264 # them.
265 self.RestoreIfUnset("date") 261 self.RestoreIfUnset("date")
266 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) 262 text = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
267 263
268 # TODO(machenbach): This could create a problem if the changelog contained 264 # Remove date and trailing white space.
269 # any quotation marks. 265 text = re.sub(r"^%s: " % self._state["date"], "", text.rstrip())
270 text = Command("echo \"%s\" \ 266
271 | sed -e \"s/^%s: //\" \ 267 # Remove indentation and merge paragraphs into single long lines, keeping
272 | sed -e 's/^ *//' \ 268 # empty lines between them.
273 | awk '{ \ 269 def SplitMapJoin(split_text, fun, join_text):
274 if (need_space == 1) {\ 270 return lambda text: join_text.join(map(fun, text.split(split_text)))
275 printf(\" \");\ 271 strip = lambda line: line.strip()
276 };\ 272 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text)
277 printf(\"%%s\", $0);\
278 if ($0 ~ /^$/) {\
279 printf(\"\\n\\n\");\
280 need_space = 0;\
281 } else {\
282 need_space = 1;\
283 }\
284 }'" % (changelog_entry, self._state["date"]))
285 273
286 if not text: 274 if not text:
287 self.Die("Commit message editing failed.") 275 self.Die("Commit message editing failed.")
288 TextToFile(text, self.Config(COMMITMSG_FILE)) 276 TextToFile(text, self.Config(COMMITMSG_FILE))
289 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) 277 os.remove(self.Config(CHANGELOG_ENTRY_FILE))
290 278
291 279
292 class NewBranch(Step): 280 class NewBranch(Step):
293 MESSAGE = "Create a new branch from trunk." 281 MESSAGE = "Create a new branch from trunk."
294 282
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 def Main(): 566 def Main():
579 parser = BuildOptions() 567 parser = BuildOptions()
580 (options, args) = parser.parse_args() 568 (options, args) = parser.parse_args()
581 if not ProcessOptions(options): 569 if not ProcessOptions(options):
582 parser.print_help() 570 parser.print_help()
583 return 1 571 return 1
584 RunPushToTrunk(CONFIG, options) 572 RunPushToTrunk(CONFIG, options)
585 573
586 if __name__ == "__main__": 574 if __name__ == "__main__":
587 sys.exit(Main()) 575 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698