summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorNico Sallembien <nsallembien@google.com>2010-04-06 10:40:01 -0700
committerNico Sallembien <nsallembien@google.com>2010-04-13 10:20:37 -0700
commita1bfd2cd7253b1662e08f5ec5be3d863430c756c (patch)
tree48cf4d0a983e37b50220cecc043793d6a5f0c319 /subcmds/sync.py
parent6d7508b3d52781a3f8170a4257c65e2de176cc68 (diff)
downloadgit-repo-a1bfd2cd7253b1662e08f5ec5be3d863430c756c.tar.gz
Add a 'smart sync' option to repo syncv1.6.9.2
This option allows the user to specify a manifest server to use when syncing. This manifest server will provide a manifest pegging each project to a known green build. This allows developers to work on a known good tree that is known to build and pass tests, preventing failed builds to hamper productivity. The manifest used is not "sticky" so as to allow subsequent 'repo sync' calls to sync to the tip of the tree. Change-Id: Id0a24ece20f5a88034ad364b416a1dd2e394226d
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index ceb81eaa..deff171a 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -17,9 +17,11 @@ from optparse import SUPPRESS_HELP
17import os 17import os
18import re 18import re
19import shutil 19import shutil
20import socket
20import subprocess 21import subprocess
21import sys 22import sys
22import time 23import time
24import xmlrpclib
23 25
24from git_command import GIT 26from git_command import GIT
25from project import HEAD 27from project import HEAD
@@ -57,6 +59,10 @@ back to the manifest revision. This option is especially helpful
57if the project is currently on a topic branch, but the manifest 59if the project is currently on a topic branch, but the manifest
58revision is temporarily needed. 60revision is temporarily needed.
59 61
62The -s/--smart-sync option can be used to sync to a known good
63build as specified by the manifest-server element in the current
64manifest.
65
60SSH Connections 66SSH Connections
61--------------- 67---------------
62 68
@@ -97,6 +103,9 @@ later is required to fix a server side protocol bug.
97 p.add_option('-d','--detach', 103 p.add_option('-d','--detach',
98 dest='detach_head', action='store_true', 104 dest='detach_head', action='store_true',
99 help='detach projects back to manifest revision') 105 help='detach projects back to manifest revision')
106 p.add_option('-s', '--smart-sync',
107 dest='smart_sync', action='store_true',
108 help='smart sync using manifest from a known good build')
100 109
101 g = p.add_option_group('repo Version options') 110 g = p.add_option_group('repo Version options')
102 g.add_option('--no-repo-verify', 111 g.add_option('--no-repo-verify',
@@ -182,6 +191,49 @@ uncommitted changes are present' % project.relpath
182 print >>sys.stderr, 'error: cannot combine -n and -l' 191 print >>sys.stderr, 'error: cannot combine -n and -l'
183 sys.exit(1) 192 sys.exit(1)
184 193
194 if opt.smart_sync:
195 if not self.manifest.manifest_server:
196 print >>sys.stderr, \
197 'error: cannot smart sync: no manifest server defined in manifest'
198 sys.exit(1)
199 try:
200 server = xmlrpclib.Server(self.manifest.manifest_server)
201 p = self.manifest.manifestProject
202 b = p.GetBranch(p.CurrentBranch)
203 branch = b.merge
204
205 env = dict(os.environ)
206 if (env.has_key('TARGET_PRODUCT') and
207 env.has_key('TARGET_BUILD_VARIANT')):
208 target = '%s-%s' % (env['TARGET_PRODUCT'],
209 env['TARGET_BUILD_VARIANT'])
210 [success, manifest_str] = server.GetApprovedManifest(branch, target)
211 else:
212 [success, manifest_str] = server.GetApprovedManifest(branch)
213
214 if success:
215 manifest_name = "smart_sync_override.xml"
216 manifest_path = os.path.join(self.manifest.manifestProject.worktree,
217 manifest_name)
218 try:
219 f = open(manifest_path, 'w')
220 try:
221 f.write(manifest_str)
222 self.manifest.Override(manifest_name)
223 finally:
224 f.close()
225 except IOError:
226 print >>sys.stderr, 'error: cannot write manifest to %s' % \
227 manifest_path
228 sys.exit(1)
229 else:
230 print >>sys.stderr, 'error: %s' % manifest_str
231 sys.exit(1)
232 except socket.error:
233 print >>sys.stderr, 'error: cannot connect to manifest server %s' % (
234 self.manifest.manifest_server)
235 sys.exit(1)
236
185 rp = self.manifest.repoProject 237 rp = self.manifest.repoProject
186 rp.PreSync() 238 rp.PreSync()
187 239