def main(): parser = make_parser() args = parser.parse_args() # if len(args) != 4: # parser.error("Incorrect number of arguments.") # setup the environment source = args.source module = args.module_name old = args.old_tag new = args.new_tag if args.area == "ioc": assert len(module.split('/')) > 1, "Missing Technical Area under Beamline" vendor = gitf.vendorModule(module, args.area) vendor_old = os.path.join(vendor, old) vendor_new = os.path.join(vendor, new) vendor_current = os.path.join(vendor, "current") trunk = gitf.devModule(module, args.area) disk_dir = module.split("/")[-1] svn.setLogMessage("Importing vendor source from: " + source) # The directory tree we are importing from must not contain any # .svn directories, otherwise "dls-svn_load_dirs" will fail with # a non-obvious error. for path, subdirs, files in os.walk(args[0]): for tt in subdirs: assert tt != '.svn', "An .svn directory has been found in " + \ source + ", cannot update from here!" # Check for existence of this module in vendor and trunk in the repository for dir in [vendor, trunk, vendor_old]: assert svn.pathcheck(dir), dir + " does not exist in the repository" assert not svn.pathcheck(vendor_new), vendor_new + " already exists in the repository" # check for diffs diffs = svn.diff('/tmp', vendor_current, svn.Revision(svn.opt_revision_kind.head), vendor_old, svn.Revision(svn.opt_revision_kind.head), True, True, True) assert args.force or not diffs, \ "Vendor 'current' of: " + vendor + " is not at revision: " + old + \ "\nUse the -f flag if you are sure you want to do this" print("Importing: " + module + " from: " + source + " to update from version: " + old + " to version: " + new) if os.system('dls-svn-load-dirs.pl -t ' + new + " " + vendor + " current " + source): print("dls-svn-load-dirs.pl command failed") else: print("") print("You probably now want to merge this update into the trunk.") print("Do this by issuing the following commands:") print("") print("svn checkout " + trunk + " " + disk_dir + " > /dev/null") print("svn merge " + vendor_old + " " + vendor_new + " " + disk_dir) print("")
def main(): parser = make_parser() args = parser.parse_args() # if len(args)!=3: # parser.error("Incorrect number of arguments.") # setup the environment source = args.source module = args.module_name version = args.release if args.area == "ioc": assert len(module.split('/')) > 1, "Missing Technical Area under Beamline" vendor = gitf.vendorModule(module, args.area) vendor_current = os.path.join(vendor, "current") vendor_version = os.path.join(vendor, version) trunk = gitf.devModule(module, args.area) disk_dir = module.split("/")[-1] svn.setLogMessage("Importing vendor source from: " + source) # Check for existence of this module in release, vendor and trunk in the repository check_dirs = [trunk, vendor, gitf.prodModule(module, args.area)] for dir in check_dirs: assert not svn.pathcheck(dir), dir + " already exists in the repository" assert os.path.isdir(source), source + " does not exist" assert not os.path.isdir(disk_dir), \ disk_dir + " exists on disk. Choose a different name or move elsewhere" print("Importing vendor source from: " + source) svn.import_(source, vendor_current, "Import of " + module + " from pristine " + version + " source", True) print("Tagging vendor source at version: " + version) svn.copy(vendor_current, vendor_version) # make directory tree if needed svn.mkdir(trunk[:trunk.rfind("/")]) print("Copying vendor source to trunk...") svn.copy(vendor_current, trunk) print("Checking out trunk...") svn.checkout(trunk, disk_dir) print("") print("Please now:") print("(1) Edit configure/RELEASE to put in correct paths") print("(2) Use make to check that it builds") print("(3) Commit with the following comment:") print("\"' + module + ': changed configure/RELEASE to reflect Diamond paths\"") print("")
def main(): parser = make_parser() args = parser.parse_args() # if len(args)!=2: # parser.error("Incorrect number of arguments.") # setup the environment module = args.module_name branch_name = args.branch_name svn.setLogMessage(module + ": creating feature branch " + branch_name) if args.area == "ioc": assert len(module.split('/')) > 1, "Missing Technical Area under Beamline" source = gitf.devModule(module, args.area) branch = os.path.join(svn.branchModule(module, args.area), branch_name) # Check for existence of release in svn, non-existence of branch in svn and current directory assert svn.pathcheck(source), 'Repository does not contain "' + source + '"' assert not svn.pathcheck(branch), 'Repository already contains "' + branch + '"' assert not os.path.isdir(branch.split("/")[-1]), \ branch.split("/")[-1] + " already exists in this directory. " \ "Please choose another name or move elsewhere." # make the branches directory svn.mkdir(gitf.branchModule(module, args.area)) svn.copy(source, branch) # checkout module tempdir = os.path.join('/tmp/svn', branch_name) if os.path.isdir(tempdir): shutil.rmtree(tempdir) svn.checkout(branch, tempdir) entry = svn.info(tempdir) # Find the revision number from "info" and set the property "dls:synced-from-trunk" # to this value. This property tells us how far up the trunk we have merged into # this branch. print('Setting "dls:synced-from-trunk" property for this branch') svn.propset('dls:synced-from-trunk', str(entry.revision.number), tempdir, svn.Revision(svn.opt_revision_kind.working)) mess = module + '/' + branch_name + ': Setting synced-from-trunk property' svn.checkin(tempdir, mess, True) shutil.rmtree(tempdir) print("") # Is the current directory a working SVN directory? isWC = svn.workingCopy() if isWC: if isWC.url == source: # if the directory is a WC of the source check for modified files status_list = svn.status('.', True, True, True, True) for x in status_list: if str(x.repos_text_status) == 'modified': print('The file "' + x.path + '" has been modified in the trunk,') print('therefore cannot switch this working SVN directory to the ' 'new branch') print("") print('To create a working directory from the new branch') print('change directories and run:') print('svn checkout ' + branch) return # if no files have been modified ask to switch the directory to the branch print('This is an SVN working directory for:') print('"' + source + '"') answer = raw_input("Do you want to switch this working directory onto the new branch? (Enter 'Y' or 'N'") if answer.upper() is "Y": print('Switching this working directory to the new branch ' + args.branch_name) svn.switch('.', branch) else: print('NOT switching this working directory to the new branch') print print('To create a working directory from this new branch,') print('change directories and run:') print('svn checkout ' + branch) else: # if it is a WC of somewhere else then just leave it print('This is an SVN working directory but not for:') print('"' + source + '"') print print('To create a working directory from this new branch,') print('change directories and run:') print('svn checkout ' + branch) else: # check out the branch to ./module/branch_name print('Checking out:') print(branch + '...') svn.checkout(branch, branch.split("/")[-1])