def update_sandbox(sb, branch=None, aspect=None, new_branch=False): sys.stdout.write('Getting %s \n' % sb.get_name()) sys.stdout.flush() err = 0 try: top = sb.get_top_component() wr = vcs.get_working_repository() old_srr = None if not branch: branch = sb.get_branch() try: location = sb.get_code_root() if not aspect: aspect = sb.get_component_reused_aspect(sb.get_top_component()) deps = metadata.get_components_inv_dep_order(wr, sb.get_targeted_platform_variant(), top, location, branch, aspect=aspect, use_master=new_branch) for comp in deps: aspects = [comp.reused_aspect, component.TEST_ASPECT_NAME] if comp.name == sb.get_top_component(): for br, c, asp, revid in wr.localbranches: if br == branch and c == comp.name and asp == component.REPORT_ASPECT_NAME: aspects.append(component.REPORT_ASPECT_NAME) break if component.REPORT_ASPECT_NAME not in aspects: rbranches = vcs.get_branches(wr.master_reporoot, aspect=component.REPORT_ASPECT_NAME) rbranches = [x[1] for x in rbranches if x[0] == branch] if comp.name in rbranches: aspects.append(component.REPORT_ASPECT_NAME) for a in aspects: # TODO: warn if component reused aspect has changed if update_component_aspect(comp, sb, a, new_branch): err = 1 except KeyboardInterrupt: sys.exit(1) except: print(sys.exc_info()[1]) finally: if old_srr: wr.source_reporoot = old_srr if not err: bad_status = get_sandbox_status(sb, status_filter=lambda lbl: lbl.startswith('conflict')) if bad_status: print(format_sandbox_status(sb, bad_status)) print('Manual intervention needed to resolve conflicts.') err = 1 # Record our dependencies for later use. with open(sb.get_dependencies_file_path(), 'w') as f: for comp in deps: f.write(str(comp) + '\r\n') finally: print('') return err
def update_sandbox(sb, branch=None, aspect=None, new_branch=False): sys.stdout.write('Getting %s \n' % sb.get_name()) sys.stdout.flush() err = 0 try: top = sb.get_top_component() wr = vcs.get_working_repository() old_srr = None if not branch: branch = sb.get_branch() try: location = sb.get_code_root() if not aspect: aspect = sb.get_component_reused_aspect(sb.get_top_component()) deps = metadata.get_components_inv_dep_order( wr, sb.get_targeted_platform_variant(), top, location, branch, aspect=aspect, use_master=new_branch) for comp in deps: aspects = [comp.reused_aspect, component.TEST_ASPECT_NAME] if comp.name == sb.get_top_component(): for br, c, asp, revid in wr.localbranches: if br == branch and c == comp.name and asp == component.REPORT_ASPECT_NAME: aspects.append(component.REPORT_ASPECT_NAME) break if component.REPORT_ASPECT_NAME not in aspects: rbranches = vcs.get_branches( wr.master_reporoot, aspect=component.REPORT_ASPECT_NAME) rbranches = [x[1] for x in rbranches if x[0] == branch] if comp.name in rbranches: aspects.append(component.REPORT_ASPECT_NAME) for a in aspects: # TODO: warn if component reused aspect has changed if update_component_aspect(comp, sb, a, new_branch): err = 1 except KeyboardInterrupt: sys.exit(1) except: print(sys.exc_info()[1]) finally: if old_srr: wr.source_reporoot = old_srr if not err: bad_status = get_sandbox_status( sb, status_filter=lambda lbl: lbl.startswith('conflict')) if bad_status: print(format_sandbox_status(sb, bad_status)) print('Manual intervention needed to resolve conflicts.') err = 1 # Record our dependencies for later use. with open(sb.get_dependencies_file_path(), 'w') as f: for comp in deps: f.write(str(comp) + '\r\n') finally: print('') return err
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order(working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order( working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)