def checkout(self, checkout_dir, checkout_mode, verbose=True, test_mode=False): """ check out stuff TODO: add comments """ if self.excludes != []: raise Excepion('call expand before checkout') cmd = ['svn'] if not verbose: cmd.append('-Q') update_mode = True if os.path.exists(os.path.join(checkout_dir, self.get_path())): if checkout_mode == 'clean': sub_cmd = ['svn revert -R'] sub_cmd.append(os.path.join(checkout_dir, self.get_path())) return_code, out = util.execute(sub_cmd, cwd=checkout_dir, return_out=True, test_mode=test_mode) cmd.append('update') cmd.append(self.get_path()) else: cmd.append('checkout') update_mode = False cmd.append(self.url + '/' + self.get_path()) #cmd.append('-r ' + self.revision) # revision, if not head cmd = ' '.join(cmd) return_code, out = util.execute(cmd, cwd=checkout_dir, return_out=True, test_mode=test_mode)
def checkout(self, checkout_dir, checkout_mode, verbose=True, test_mode=False): cwd = os.path.join(checkout_dir, self.repo_name) if not os.path.exists( os.path.join(cwd, '.git') ): cmd = ['git'] cmd.append('clone') if not verbose: cmd.append('-q') cmd.append(self.module) if not test_mode and not os.path.exists(cwd): os.makedirs(cwd) util.execute(cmd, cwd=cwd, verbose=verbose,test_mode=test_mode) cmd = ['git'] cmd.append('checkout') if not verbose: cmd.append('-q') # If checkout_mode is clean, throw away local changes if checkout_mode == 'clean': cmd.append('-f') cmd.append(self.revision) util.execute(cmd, cwd=cwd, verbose=verbose, test_mode=test_mode)
def list_contents(path, root): """ @return list of relative paths rooted at "root" """ cmd = "svn ls %s/%s" % (root, path) code, out = util.execute(cmd, return_out=True) dirs = out.strip().split('\n') return dirs
def checkout(self, checkout_dir, checkout_mode, verbose=True, test_mode=False): """ check out stuff TODO: add comments """ cmd = ['cvs'] if not verbose: cmd.append('-Q') update_mode = True # if the path exists, but it's not a cvs working copy, # we need to checkout instead of updating. # that's why we append 'CVS' to the path module_dir = os.path.join(checkout_dir, self.get_path(), 'CVS') if os.path.exists(module_dir): cmd.append('update -d') if checkout_mode == 'clean': cmd.append('-C') else: cmd.append('checkout') update_mode = False cmd.append('-P') # prune empty dirs if self.revision.lower() == 'head': cmd.append('-A') # Reset sticky tags else: cmd.append('-r ' + self.revision) # revision, if not head # build the command specification if update_mode: # we can't easily exclude things from the checkout here, cmd.append(self.module) else: # when checkouting, put the module path first, # then use !directory/path to exclude portions cmd.append(self.module) cmd.extend(['!%s' % exclude for exclude in self.excludes]) return_code, out = util.execute(cmd, cwd=checkout_dir, verbose=verbose, test_mode=test_mode, return_out=True) if return_code != 0: # sometimes CVS screws up when replacing old files. the known # erroring case is when a file exists in the local filesystem # that was not in the previously-checked-out rover config (branch, # etc) but is in the currently-being-checked-out config. # # in this case, we try to identify those files which are in the way, # move them out of the way, and issue the command again one time. in_the_way = re.compile( r"move away `?([^;]+)'; it is in the way" ) for line in out: m = in_the_way.search(line) if m: dirname, filename = os.path.split(m.group(1)) # FIXME: Do we want to append the date/time as well? # Otherwise, only one backup is allowed # back up the file as .rover.<filename> old = os.path.abspath( os.path.join( checkout_dir, dirname, filename ) ) new = os.path.abspath( os.path.join( checkout_dir, dirname, '.%s.rover' % filename ) ) #if verbose: print "* Backing up %(old)s to %(new)s" % locals() shutil.move(old, new) out = util.execute(cmd, cwd=checkout_dir, verbose=verbose, test_mode=test_mode)