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

Side by Side Diff: apply_issue.py

Issue 11038002: Enforce the checkout object to use an absolute path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 2 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 | « no previous file | checkout.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 """Applies an issue from Rietveld. 6 """Applies an issue from Rietveld.
7 """ 7 """
8 8
9 import getpass 9 import getpass
10 import logging 10 import logging
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 # should get rid of those. 84 # should get rid of those.
85 except rietveld.upload.ClientLoginError, e: 85 except rietveld.upload.ClientLoginError, e:
86 # Fine, we'll do proper authentication. 86 # Fine, we'll do proper authentication.
87 pass 87 pass
88 if properties is None: 88 if properties is None:
89 if options.email is not None: 89 if options.email is not None:
90 try: 90 try:
91 obj = rietveld.Rietveld(options.server, options.email, options.password) 91 obj = rietveld.Rietveld(options.server, options.email, options.password)
92 except rietveld.upload.ClientLoginError, e: 92 except rietveld.upload.ClientLoginError, e:
93 if sys.stdout.closed: 93 if sys.stdout.closed:
94 print >> sys.stderr, 'Accessing the issue requires login.' 94 print('Accessing the issue requires proper credentials.')
95 return 1 95 return 1
96 print('Accessing the issue requires login.') 96 print('Accessing the issue requires login.')
97 obj = rietveld.Rietveld(options.server, None, None) 97 obj = rietveld.Rietveld(options.server, None, None)
98 properties = obj.get_issue_properties(options.issue, False) 98 properties = obj.get_issue_properties(options.issue, False)
99 99
100 if not options.patchset: 100 if not options.patchset:
101 options.patchset = properties['patchsets'][-1] 101 options.patchset = properties['patchsets'][-1]
102 print('No patchset specified. Using patchset %d' % options.patchset) 102 print('No patchset specified. Using patchset %d' % options.patchset)
103 103
104 print('Downloading the patch.') 104 print('Downloading the patch.')
105 try: 105 try:
106 patchset = obj.get_patch(options.issue, options.patchset) 106 patchset = obj.get_patch(options.issue, options.patchset)
107 except urllib2.HTTPError, e: 107 except urllib2.HTTPError, e:
108 print >> sys.stderr, ( 108 print(
109 'Failed to fetch the patch for issue %d, patchset %d.\n' 109 'Failed to fetch the patch for issue %d, patchset %d.\n'
110 'Try visiting %s/%d') % ( 110 'Try visiting %s/%d') % (
111 options.issue, options.patchset, 111 options.issue, options.patchset,
112 options.server, options.issue) 112 options.server, options.issue)
113 return 1 113 return 1
114 for patch in patchset.patches: 114 for patch in patchset.patches:
115 print(patch) 115 print(patch)
116 scm_type = scm.determine_scm(options.root_dir) 116 full_dir = os.path.abspath(options.root_dir)
117 scm_type = scm.determine_scm(full_dir)
117 if scm_type == 'svn': 118 if scm_type == 'svn':
118 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) 119 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
119 elif scm_type == 'git': 120 elif scm_type == 'git':
120 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) 121 scm_obj = checkout.GitCheckoutBase(full_dir, None, None)
121 elif scm_type == None: 122 elif scm_type == None:
122 scm_obj = checkout.RawCheckout(options.root_dir, None, None) 123 scm_obj = checkout.RawCheckout(full_dir, None, None)
123 else: 124 else:
124 parser.error('Couldn\'t determine the scm') 125 parser.error('Couldn\'t determine the scm')
125 126
126 # TODO(maruel): HACK, remove me. 127 # TODO(maruel): HACK, remove me.
127 # When run a build slave, make sure buildbot knows that the checkout was 128 # When run a build slave, make sure buildbot knows that the checkout was
128 # modified. 129 # modified.
129 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': 130 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
130 # See sourcedirIsPatched() in: 131 # See sourcedirIsPatched() in:
131 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ 132 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
132 # chromium_commands.py?view=markup 133 # chromium_commands.py?view=markup
133 open('.buildbot-patched', 'w').close() 134 open('.buildbot-patched', 'w').close()
134 135
135 print('\nApplying the patch.') 136 print('\nApplying the patch.')
136 try: 137 try:
137 scm_obj.apply_patch(patchset, verbose=True) 138 scm_obj.apply_patch(patchset, verbose=True)
138 except checkout.PatchApplicationFailed, e: 139 except checkout.PatchApplicationFailed, e:
139 print >> sys.stderr, str(e) 140 print(str(e))
141 print('CWD=%s' % os.getcwd())
142 print('Checkout path=%s' % scm_obj.project_path)
140 return 1 143 return 1
141 144
142 if 'DEPS' in map(os.path.basename, patchset.filenames): 145 if 'DEPS' in map(os.path.basename, patchset.filenames):
143 gclient_root = gclient_utils.FindGclientRoot(options.root_dir) 146 gclient_root = gclient_utils.FindGclientRoot(full_dir)
144 if gclient_root and scm_type: 147 if gclient_root and scm_type:
145 print( 148 print(
146 'A DEPS file was updated inside a gclient checkout, running gclient ' 149 'A DEPS file was updated inside a gclient checkout, running gclient '
147 'sync.') 150 'sync.')
148 base_rev = 'BASE' if scm_type == 'svn' else 'HEAD' 151 base_rev = 'BASE' if scm_type == 'svn' else 'HEAD'
149 gclient_path = os.path.join(BASE_DIR, 'gclient') 152 gclient_path = os.path.join(BASE_DIR, 'gclient')
150 if sys.platform == 'win32': 153 if sys.platform == 'win32':
151 gclient_path += '.bat' 154 gclient_path += '.bat'
152 return subprocess.call( 155 return subprocess.call(
153 [gclient_path, 'sync', '--revision', base_rev], cwd=gclient_root) 156 [gclient_path, 'sync', '--revision', base_rev], cwd=gclient_root)
154 return 0 157 return 0
155 158
156 159
157 if __name__ == "__main__": 160 if __name__ == "__main__":
158 fix_encoding.fix_encoding() 161 fix_encoding.fix_encoding()
159 sys.exit(main()) 162 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | checkout.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698