def create_tag(repourl, tagname, username): tags = svnbrowse.get_tags(repourl) if tagname in tags: raise TagExists("""'%s' is already tagged, please try using a different tag name""" % tagname) elif re.sub('[\w\.-]', '', tagname) != '': raise BadName("""'%s' is an invalid name. Try using just letters, numbers, dashes, underscores and periods.""" % tagname) reponame = svnbrowse.get_root_info(repourl)['repository_root'].split('/')[-1] #logging.debug("reponame %s" % (reponame,)) with TemporaryFile() as tmperr: with TemporaryFile() as tmpout: out = call(['svn', 'copy', '%s/trunk' % repourl, '%s/tags/%s' % (repourl, tagname), '-m', 'Tagging the %s release' % tagname], stderr=tmperr, stdout=tmpout) if out is not 0: tmperr.seek(0) msg = tmperr.read() logging.error(msg) raise Error(msg) tmpout.seek(0) rev = re.search('Committed revision (\d+)', tmpout.read()).groups()[0] logging.info("changing the author of %s r%s to %s" % (reponame, rev, username)) with NamedTemporaryFile() as tmpauthor: #logging.debug("tmperr %r, tmpout %r, tmpauthor %r" % (tmperr, tmpout, tmpauthor)) tmpauthor.write(username) tmpauthor.seek(0) out = call(['svnadmin', 'setrevprop', '/usr/local/svn/repositories/%s' % reponame, '-r', rev, 'svn:author', tmpauthor.name]) if out is not 0: raise Error("Failed to set the commit author") return True
def get(self): mc = memcache.Client(['127.0.0.1:11211'], debug=0) names = settings.repositories.keys() repos_list = mc.get_multi(names, 'repo_list_') missing = set(names) - set(repos_list.keys()) if len(missing) > 0: reload(settings) for name in missing: url = settings.repositories[name] repos_list[name] = svnbrowse.get_root_info(url) mc.set('repo_list_%s' % name, repos_list[name], time=36000) self.render("templates/repolist.html", repos=repos_list.values(), site_title=settings.SITE_TITLE)
def post(self): reponame = str(self.get_argument('reponame')) try: svnmanage.create_repo(reponame, str(self.get_current_user()['username'])) mc = memcache.Client(['127.0.0.1:11211'], debug=0) reload(settings) url = settings.repositories[reponame] mc.set('repo_list_%s' % reponame, svnbrowse.get_root_info(url), time=36000) mc.set('repo_log_%s' % reponame, list(reversed(svnbrowse.list_history(url))), time=36000) self.redirect("/%s" % reponame) except Exception, e: self.get([str(e)])