def makemovie(url, size): client = Client() images = [] r1 = "" log = client.log(url) versions = sorted([l['revision'].number for l in log]) for rev in versions: (r2, diff) = getrev(client, url, rev) if r2 and not diff: #really wish I had multiple dispatch here images.append(gen_one(r2, size)) elif r2 and diff: images.extend(gen_diff(r1, r2, diff, size)) r1 = r2 raw_input('<enter> to continue')
class SVNInterface: #XXX: for Testing pysvn, add new features as desired """ Provides an interface to SVN repositories """ def __init__(self, repo): self.repo = repo self.client = Client() def lastRev(self): ret = self.lastLog() if ret == 'Error connecting to SVN repo': return -1 else: return ret[0]['revision'] def lastLog(self, num=1, files=False): if num == 1: end = Revision(opt_revision_kind.head) else: end = Revision(opt_revision_kind.number, int(self.lastRev()) - (num - 1)) try: log = self.client.log(self.repo, revision_end=end, discover_changed_paths=files) except ClientError, message: msg = 'Error connecting to SVN repo: %s' % (message, ) print msg return 'Error connecting to SVN repo' for entry in log: entry['date'] = asctime(localtime(entry['date'])) # convert EPOCH seconds to human readable entry['revision'] = str(entry['revision'].number) # str -> converts int -> string entry['author'] = str(entry['author']) # str -> converts unicode -> ascii entry['message'] = str(entry['message']) # str -> converts unicode -> ascii if files: files = [] for file in entry['changed_paths']: filename = str(file['path']) mode = str(file['action']) files.append('%s (%s)' % (filename, mode)) entry['files'] = files return log
class SvnRepoMonitor(): def __init__(self, name, svn_root, svn_username, svn_password, config_file): self.name = name self.svn_root = svn_root self.svn_username = svn_username self.svn_password = svn_password self.client = Client() self.client.callback_get_login = self._credentials self.parser = ConfigParser() self.config_file = config_file def _notify(self, author, date, revision, message, paths): """Display the changed paths using libnotify""" title_string = 'New commit #%s in repository %s' % (revision, self.name) message_string = "<p>[%s] %s</p> <p><i>%s</i>" % \ (date.strftime("%d.%m %H:%M"), author, message) message_string += "<ul>" for p in paths[:5]: if len(p) > 50: p = "...%s" % p[-50:] message_string += "<li>%s</li>" % p if len(paths) > 6: message_string += "<li>...</li>" message_string += "</ul></p>" logging.debug("Open pynotify.Notification: %s | %s" % (title_string, message_string)) pynotify.Notification(title_string, message_string, "view-refresh").show() def _credentials(self, realm, username, may_save): """Return the default login credentials""" return True, self.svn_username, self.svn_password, False def discover_changes(self): """ Find out the changes occured since the last time this method is ran """ logging.debug("Discover Changes in %s" % self.name) self.parser.read(self.config_file) if self.parser.has_option(self.name, "last_revision"): last_revision = self.parser.get(self.name, "last_revision") else: last_revision = 0 log = self.client.log( self.svn_root, discover_changed_paths=True, revision_end=Revision(opt_revision_kind.number, last_revision) ) log = log[:-1] # Ignore last revision if len(log) > 0: logging.info("%s new commits in repository %s" % (len(log), self.name)) # update last revision in config file last_revision = log[0].revision.number self.parser.set(self.name, "last_revision", last_revision) self.parser.write(open(self.config_file, 'w')) log.reverse() if len(log) > 5: # Show only most recent commits pynotify.Notification("Even more commits in repository %s" % self.name, "There are %s more new commits in the repository" % (len(log) - 5), "view-refresh").show() log = log[-5:] for entry in log: author = entry.get('author') rev = entry.revision.number message = entry.message date = datetime.datetime.fromtimestamp(entry.date) paths = [] for change in entry.changed_paths: paths.append(change.path) self._notify(author, date, rev, message, paths) else: logging.debug("No new commits in repository %s" % self.name)
class SvnRepoMonitor(): def __init__(self, name, svn_root, svn_username, svn_password, config_file): self.name = name self.svn_root = svn_root self.svn_username = svn_username self.svn_password = svn_password self.client = Client() self.client.callback_get_login = self._credentials self.parser = ConfigParser() self.config_file = config_file def _notify(self, author, date, revision, message, paths): """Display the changed paths using libnotify""" title_string = 'New commit #%s in repository %s' % (revision, self.name) message_string = "<p>[%s] %s</p> <p><i>%s</i>" % \ (date.strftime("%d.%m %H:%M"), author, message) message_string += "<ul>" for p in paths[:5]: if len(p) > 50: p = "...%s" % p[-50:] message_string += "<li>%s</li>" % p if len(paths) > 6: message_string += "<li>...</li>" message_string += "</ul></p>" logging.debug("Open pynotify.Notification: %s | %s" % (title_string, message_string)) pynotify.Notification(title_string, message_string, "view-refresh").show() def _credentials(self, realm, username, may_save): """Return the default login credentials""" return True, self.svn_username, self.svn_password, False def discover_changes(self): """ Find out the changes occured since the last time this method is ran """ logging.debug("Discover Changes in %s" % self.name) self.parser.read(self.config_file) if self.parser.has_option(self.name, "last_revision"): last_revision = self.parser.get(self.name, "last_revision") else: last_revision = 0 log = self.client.log(self.svn_root, discover_changed_paths=True, revision_end=Revision(opt_revision_kind.number, last_revision)) log = log[:-1] # Ignore last revision if len(log) > 0: logging.info("%s new commits in repository %s" % (len(log), self.name)) # update last revision in config file last_revision = log[0].revision.number self.parser.set(self.name, "last_revision", last_revision) self.parser.write(open(self.config_file, 'w')) log.reverse() if len(log) > 5: # Show only most recent commits pynotify.Notification( "Even more commits in repository %s" % self.name, "There are %s more new commits in the repository" % (len(log) - 5), "view-refresh").show() log = log[-5:] for entry in log: author = entry.get('author') rev = entry.revision.number message = entry.message date = datetime.datetime.fromtimestamp(entry.date) paths = [] for change in entry.changed_paths: paths.append(change.path) self._notify(author, date, rev, message, paths) else: logging.debug("No new commits in repository %s" % self.name)
def get_revisions(since_revision): client = Client() end_rev = Revision(opt_revision_kind.number, since_revision) return client.log(app.config["SVN_URL"], Revision(opt_revision_kind.head), end_rev)[:-1]
def main(options): """docstring for main""" client = Client() client.callback_ssl_server_trust_prompt = ssl_trust_prompt if (options.verbose > 1): client.callback_notify = notify retcode = 0 # check out branch from subversion if (test_skip(options.branch_flags, update)): getSourceTree(options.workingDir + os.sep + "branch", options.branchUrl, client, options) elif (options.verbose): print "Skipping branch update" # compile branch if (test_skip(options.branch_flags, build)): print "Compiling branch" retcode = doCompile(options.workingDir + os.sep + "branch" + os.sep + "VS2005") elif (options.verbose): print "Skipping branch compile" # If compile successful, Run autotest if (retcode != 0): print "Failed to compile branch" return retcode if (test_skip(options.branch_flags, autotest)): print "Running branch autotest" retcode = doAutotest(options.workingDir + os.sep + "branch") elif (options.verbose): print "Skipping branch autotest" if (retcode != 0): print "Failed branch autotest" return retcode if (test_skip(options.trunk_flags, update)): getSourceTree(options.workingDir + os.sep + "trunk", options.trunkUrl, client, options) elif (options.verbose): print "Skipping trunk update" # Determine the revision number of the head of the branch if (options.endrev == 'HEAD'): if (options.verbose): print "Getting last revision number of branch" messages = client.log(branchUrl, revision_end=Revision( pysvn.opt_revision_kind.number, startrev)) endrev = messages[0].revision.number options.endrev = str(endrev) if (options.verbose): print "Revisions to merge", options.startrev + ":" + options.endrev # Merge changes from branch to trunk if (not options.skip_merge): if (options.verbose): print "Merging branch changes to trunk working directory" (retcode, conflicts) = doMerge(options.workingDir + os.sep + "trunk", endrev, options) elif (options.verbose): print "Skipping merge" # How do we tell if there were merge errors?!? if (retcode != 0): print "Merge to working directory failed with conflicts." printList(conflicts) return retcode # Compile trunk if (test_skip(options.trunk_flags, build)): print "Compiling trunk" retcode = doCompile(options.workingDir + os.sep + "trunk" + os.sep + "VS2005") elif (options.verbose): print "Skipping trunk compile" if (retcode != 0): print "Failed to compile merged trunk" return retcode # If compile successful, run autotest if (test_skip(options.trunk_flags, autotest)): print "Running trunk autotest" retcode = doAutotest(options.workingDir + os.sep + "trunk") elif (options.verbose): print "Skipping trunk autotest" if (retcode != 0): print "Failed in merged autotest" return retcode # TODO: If successful, commit. if (not options.skip_commit): pass # Write out new lastrev.py file fp = open("lastrev.py", 'w') fp.write("startrev = " + str(endrev) + "\n") fp.write("prevrev = " + str(startrev)) fp.close()