Home Download Buy Blog Forum Support

Structuring Packages into directory trees?

Re: Structuring Packages into directory trees?

Postby gpfsmurf on Wed Jul 08, 2009 3:08 am

I use tortoise so I just select all the directories and click on Update.
It opens a single dialog but issues separate SVN update commands.

I can see how more automation will be useful in the future when there are more plugins and more activity on the repo though; I especially like the idea off 'turning off' a particular package without removing the directory
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Structuring Packages into directory trees?

Postby SteveCooperOrg on Thu Jul 09, 2009 9:04 am

Here's what I've ended up doing.

- I'm checking out folders individually into my packages dir.
- I've written a script which will bulk-update and bulk-commit changes to the svn packages in the packages dir.
- I run the bulk-update whenever I want to update things.

It's multithreaded, so it's pretty fast at updating a lot of small package folders.

The library code (svnlib.py) is this;

Code: Select all
import os, sys, subprocess
from threading import Thread

#
# These directories contain subdirectories which are subversion repositories.
# These are, then, collections of SVN repos, rather than repos themselves.
#
dirs = [
    "c:\\usr",
    "c:\\missing",
    "C:\\Documents and Settings\\Steve\\Application Data\\Sublime Text\\Packages"
    ]

def exist(x): return os.path.exists(x) # does a file/folder x exist?
def children(d): return [os.path.join(d, x) for x in os.listdir(d)] # subdirs/files of d
def issvn(x): return exist(os.path.join(x, ".svn")) # is x a subversion folder?
def flatmap(f, L): # like map, but for a fn of type a->[b], converts [a]->[b], not [a]->[[b]]
  for l in L:
    for r in f(l):
      yield r

def update(direc):
  """starts a subversion update thread for the given directory"""
  updater = Updater(direc)
  updater.start()
  return updater

def commit(direc):
  """starts a subversion commit thread for the given directory"""
  committer = Committer(direc)
  committer.start()
  return committer

class Committer(Thread):
  """Commit thread"""
 
  def __init__(self, direc):
    Thread.__init__(self)
    self.direc = direc
   
  def run(self):
    print "Committing", self.direc
    self.result = subprocess.call(['svn', 'commit', '-m', '', self.direc ])

class Updater(Thread):
  """Update thread"""
  def __init__(self, direc):
    Thread.__init__(self)
    self.direc = direc
   
  def run(self):
    print "Updating", self.direc
    self.result = subprocess.call(['svn', 'up', self.direc ])

def existingSvnDirs(dirs):
  """gives subversion directories within the dirs directories."""
  subs = filter(issvn, flatmap(children, map(os.path.abspath, filter(exist,dirs))))
  return subs

def runSvnProcess(proc):
  """Run a subversion process (update, commit) against a set of subversion repos"""
 
  # start the update/commit process
  threads = []
  for sub in existingSvnDirs(dirs):
    threads.append(proc(sub))
 
  # wait for the threads to join and show the results. 
  for thread in threads:
    thread.join()
    print "finished", thread.direc, "with", thread.result



and it's invoked like this;

Code: Select all
import svnlib
svnlib.runSvnProcess(svnlib.update)


The top of the library contains a list of my subversion-controlled folders; you'll want to edit this before you use it.
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg
 
Posts: 193
Joined: Thu Mar 20, 2008 9:53 am

Previous

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 10 guests