def commit(target=".", message=None, logfile=None): svn = SVN() status = svn.status(target, quiet=True) if not status: print "nothing to commit" return info = svn.info2(target) url = info.get("URL") if url is None: raise Error, "working copy URL not provided by svn info" mirrored = mirror.using_on(url) if mirrored: newurl = mirror.switchto_parent(svn, url, target) print "relocated to", newurl # we can't use the svn object here because svn --non-interactive option # hides VISUAL opts = [] if message is not None: opts.append("-m \"%s\"" % message) if logfile is not None: opts.append("-F \"%s\"" % logfile) mopts = " ".join(opts) os.system("svn ci %s %s" % (mopts, target)) if mirrored: print "use \"repsys switch\" in order to switch back to mirror "\ "later"
def package_url(name_or_url, version=None, release=None, distro=None, mirrored=True): """Returns a tuple with the absolute package URL and its name @name_or_url: name, relative path, or URL of the package. In case it is a URL, the URL will just be 'normalized'. @version: the version to be fetched from releases/ (requires release) @release: the release number to be fetched from releases/$version/ @distro: the name of the repository branch inside updates/ @mirrored: return an URL based on the mirror repository, if enabled """ from RepSys import mirror if "://" in name_or_url: pkgdirurl = mirror.normalize_path(name_or_url) pkgdirurl = remove_current(pkgdirurl) if mirror.using_on(pkgdirurl) and not mirrored: pkgdirurl = mirror.relocate_path(mirror.mirror_url(), repository_url(), pkgdirurl) else: name = name_or_url devel_branch, branches_dir = layout_dirs() if distro or "/" in name: default_branch = branches_dir if distro: default_branch = os.path.join(default_branch, distro) else: default_branch = devel_branch # cooker path = os.path.join(default_branch, name) parsed = list(urlparse.urlparse(repository_url(mirrored=mirrored))) parsed[2] = os.path.join(parsed[2], path) pkgdirurl = urlparse.urlunparse(parsed) return pkgdirurl
def get_submit_info(path): path = os.path.abspath(path) # First, look for SPECS and SOURCES directories. found = False while path != "/": if os.path.isdir(path): specsdir = os.path.join(path, "SPECS") sourcesdir = os.path.join(path, "SOURCES") if os.path.isdir(specsdir) and os.path.isdir(sourcesdir): found = True break path = os.path.dirname(path) if not found: raise Error, "SPECS and/or SOURCES directories not found" # Then, check if this is really a subversion directory. if not os.path.isdir(os.path.join(path, ".svn")): raise Error, "subversion directory not found" svn = SVN() # Now, extract the package name. info = svn.info2(path) url = info.get("URL") if url is None: raise Error, "missing URL from svn info %s" % path toks = url.split("/") if len(toks) < 2 or toks[-1] != "current": raise Error, "unexpected URL received from 'svn info'" name = toks[-2] url = "/".join(toks[:-1]) # Finally, guess revision. max = -1 files = [] files.extend(glob.glob("%s/*" % specsdir)) files.extend(glob.glob("%s/*" % sourcesdir)) for file in files: try: info = svn.info2(file) except Error: # possibly not tracked continue if info is None: continue rawrev = info.get("Last Changed Rev") if rawrev: rev = int(rawrev) if rev > max: max = rev if max == -1: raise Error, "revision tag not found in 'svn info' output" if mirror.using_on(url): url = mirror.switchto_parent_url(url) return name, url, max