OLD | NEW |
1 # coding=utf-8 | 1 # coding=utf-8 |
2 # (The line above is necessary so that I can use 世界 in the | 2 # (The line above is necessary so that I can use 世界 in the |
3 # *comment* below without Python getting all bent out of shape.) | 3 # *comment* below without Python getting all bent out of shape.) |
4 | 4 |
5 # Copyright 2007-2009 Google Inc. | 5 # Copyright 2007-2009 Google Inc. |
6 # | 6 # |
7 # Licensed under the Apache License, Version 2.0 (the "License"); | 7 # Licensed under the Apache License, Version 2.0 (the "License"); |
8 # you may not use this file except in compliance with the License. | 8 # you may not use this file except in compliance with the License. |
9 # You may obtain a copy of the License at | 9 # You may obtain a copy of the License at |
10 # | 10 # |
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 files = ChangedExistingFiles(ui, repo, pats, opts) | 1765 files = ChangedExistingFiles(ui, repo, pats, opts) |
1766 files = gofmt_required(files) | 1766 files = gofmt_required(files) |
1767 if not files: | 1767 if not files: |
1768 return "no modified go files" | 1768 return "no modified go files" |
1769 cwd = os.getcwd() | 1769 cwd = os.getcwd() |
1770 files = [RelativePath(repo.root + '/' + f, cwd) for f in files] | 1770 files = [RelativePath(repo.root + '/' + f, cwd) for f in files] |
1771 try: | 1771 try: |
1772 cmd = ["gofmt", "-l"] | 1772 cmd = ["gofmt", "-l"] |
1773 if not opts["list"]: | 1773 if not opts["list"]: |
1774 cmd += ["-w"] | 1774 cmd += ["-w"] |
1775 » » if os.spawnvp(os.P_WAIT, "gofmt", cmd + files) != 0: | 1775 » » if subprocess.call(cmd + files) != 0: |
1776 raise hg_util.Abort("gofmt did not exit cleanly") | 1776 raise hg_util.Abort("gofmt did not exit cleanly") |
1777 except hg_error.Abort, e: | 1777 except hg_error.Abort, e: |
1778 raise | 1778 raise |
1779 except: | 1779 except: |
1780 raise hg_util.Abort("gofmt: " + ExceptionDetail()) | 1780 raise hg_util.Abort("gofmt: " + ExceptionDetail()) |
1781 return | 1781 return |
1782 | 1782 |
1783 def gofmt_required(files): | 1783 def gofmt_required(files): |
1784 return [f for f in files if (not f.startswith('test/') or f.startswith('
test/bench/')) and f.endswith('.go')] | 1784 return [f for f in files if (not f.startswith('test/') or f.startswith('
test/bench/')) and f.endswith('.go')] |
1785 | 1785 |
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 ctype, body = EncodeMultipartFormData(form_fields, files) | 3540 ctype, body = EncodeMultipartFormData(form_fields, files) |
3541 url = "/%d/upload_patch/%d" % (int(issue), int(patchset)) | 3541 url = "/%d/upload_patch/%d" % (int(issue), int(patchset)) |
3542 print "Uploading patch for " + patch[0] | 3542 print "Uploading patch for " + patch[0] |
3543 response_body = rpc_server.Send(url, body, content_type=ctype) | 3543 response_body = rpc_server.Send(url, body, content_type=ctype) |
3544 lines = response_body.splitlines() | 3544 lines = response_body.splitlines() |
3545 if not lines or lines[0] != "OK": | 3545 if not lines or lines[0] != "OK": |
3546 StatusUpdate(" --> %s" % response_body) | 3546 StatusUpdate(" --> %s" % response_body) |
3547 sys.exit(1) | 3547 sys.exit(1) |
3548 rv.append([lines[1], patch[0]]) | 3548 rv.append([lines[1], patch[0]]) |
3549 return rv | 3549 return rv |
OLD | NEW |