diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-06-05 19:17:27 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-06-05 19:17:27 +0000 |
commit | 5f1a15b9c7b253c0267d05613683ac1fb5f88e6c (patch) | |
tree | 691b3689c17df655db9a075c5d4853b99e217d42 /RepSys/rpmutil.py | |
parent | 5c221808ecb832d3419bb96002ede1a553ed7b73 (diff) | |
download | mgarepo-5f1a15b9c7b253c0267d05613683ac1fb5f88e6c.tar mgarepo-5f1a15b9c7b253c0267d05613683ac1fb5f88e6c.tar.gz mgarepo-5f1a15b9c7b253c0267d05613683ac1fb5f88e6c.tar.bz2 mgarepo-5f1a15b9c7b253c0267d05613683ac1fb5f88e6c.tar.xz mgarepo-5f1a15b9c7b253c0267d05613683ac1fb5f88e6c.zip |
Improved (and fixed) the support to mirrors and "switch" subcommand
- added the switch subcommand to quickly switch between the default and the
mirrored repositories
- fixed bug of generating bogus mirror URLs
- make "ci" smarter by only relocation if something has been changed in the
working copy and it is not already relocated.
Diffstat (limited to 'RepSys/rpmutil.py')
-rw-r--r-- | RepSys/rpmutil.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py index a0eb22e..413c152 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -368,14 +368,20 @@ def checkout(pkgdirurl, path=None, revision=None): print "checking out from mirror", current svn.checkout(current, path, rev=revision, show=1) -def sync(dryrun=False): - svn = SVN(noauth=True) +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 = "" + return topdir + +def sync(dryrun=False): + svn = SVN(noauth=True) + topdir = _getpkgtopdir() # run svn info because svn st does not complain when topdir is not an # working copy svn.info(topdir or ".") @@ -425,11 +431,16 @@ def sync(dryrun=False): def commit(target=".", message=None): svn = SVN(noauth=True) + 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" - if mirror.enabled(): + mirrored = mirror.enabled(url) + if mirrored: newurl = mirror.switchto_parent(svn, url, target) print "relocated to", newurl try: @@ -439,10 +450,20 @@ 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(noauth=True) + topdir = _getpkgtopdir() + info = svn.info2(topdir) + wcurl = info.get("URL") + if wcurl is None: + raise Error, "working copy URL not provided by svn info" + newurl = mirror.autoswitch(svn, topdir, wcurl, mirrorurl) + print "switched to", newurl + def get_submit_info(path): path = os.path.abspath(path) |