diff options
Diffstat (limited to 'RepSys/rpmutil.py')
-rw-r--r-- | RepSys/rpmutil.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py index 39e78fc..40aa4fe 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -369,17 +369,23 @@ def checkout(pkgdirurl, path=None, revision=None): print "checking out from mirror", current svn.checkout(current, path, revision=SVN.makerev(revision), show=1) -def sync(dryrun=False): - svn = SVN() +def _getpkgtopdir(basedir=None): + if basedir is None: + basedir = os.getcwd() cwd = os.getcwd() dirname = os.path.basename(cwd) if dirname == "SPECS" or dirname == "SOURCES": topdir = os.pardir else: - topdir = "" + topdir = "." + return topdir + +def sync(dryrun=False): + svn = SVN() + topdir = _getpkgtopdir() # run svn info because svn st does not complain when topdir is not an # working copy - svn.info(topdir or ".") + svn.info(topdir) specsdir = os.path.join(topdir, "SPECS/") sourcesdir = os.path.join(topdir, "SOURCES/") for path in (specsdir, sourcesdir): @@ -426,11 +432,16 @@ def sync(dryrun=False): def commit(target=".", message=None): svn = SVN() + status = svn.status(target, silent=True) + if not status: + print "nothing to commit" + return info = svn.info(target) url = info.url if url is None: raise Error, "working copy URL not provided by svn info" - if mirror.enabled(): + mirrored = mirror.enabled(url) + if mirrored: newurl = mirror.switchto_parent(svn, url, target) print "relocated to", newurl try: @@ -440,10 +451,18 @@ def commit(target=".", message=None): mopt = "-m \"%s\"" % message os.system("svn ci %s %s" % (mopt, target)) finally: - if mirror.enabled(): + if mirrored: mirror.switchto_mirror(svn, newurl, target) print "relocated back to", url +def switch(mirrorurl=None): + svn = SVN() + topdir = _getpkgtopdir() + info = svn.info(topdir) + wcurl = info.url + newurl = mirror.autoswitch(svn, topdir, wcurl, mirrorurl) + print "switched to", newurl + def get_submit_info(path): path = os.path.abspath(path) |