def setacl(f, acl): oldacl = getacl(f) logging.info("putting acl %s on %s" % (acl, f)) dryfunc(settings.dry, getPipedCommandOut, "echo %s | chmod -E %s" % (acl, f)) if len(oldacl) > 0: undo.push(setacl, f, oldacl) undo.push(removeacl, f)
def remove(filetoversionpath): with open(settings.syncdbpath, 'r') as db: before = db.read() dbwithfileremoved = before.replace(filetoversionpath + os.linesep, "") with open(settings.syncdbpath, 'w') as db: dryfunc(settings.dry, db.write, dbwithfileremoved) logging.info("removed %s from db", filetoversionpath) undo.push(add, filetoversionpath)
def removeacl(f): acl = getacl(f) if len(acl) > 0: logging.info("removing acl %s from %s" % (acl, f)) cmd = "chmod -N %s" % f dryfunc(settings.dry, getCommandOut, cmd) undo.push(setacl, f, acl) return acl
def commit(commitme, comment): if not isinstance(commitme, list): commitme = [commitme] commitus = ["\"%s\"" % f for f in commitme] cmd = "svn ci -m \"%s\" %s" % (comment, " ".join(commitus)) out = dryfunc(settings.dry, getPipedCommandOut, cmd) logging.info("RESULTS of %s : %s" % (cmd, out))
def getacl(f): cmd = "ls -lde \"%s\" | tail +2 | sed 's/^ [0-9]*: //'" % f out = dryfunc(False, getPipedCommandOut, cmd) logging.debug("acl: %s = %s" % (cmd, out)) if out: out = out.strip() return out
def isinsvn(f): cmd = "svn info \"%s\"" % f try: out = dryfunc(False, getPipedCommandOut, cmd) if out.find("not a working copy") >= 0: return False if out.find("Not a versioned resource") >= 0: return False except: return False return True
def deleteinreposonly(f): cmd = "svn del --force --keep-local \"%s\"" % f out = dryfunc(settings.dry, getPipedCommandOut, cmd) logging.info("RESULTS of %s : %s" % (cmd, out)) undo.push(add, f)
def add(f): cmd = "svn add \"%s\"" % f out = dryfunc(settings.dry, getPipedCommandOut, cmd) logging.info("RESULTS of %s : %s" % (cmd, out)) undo.push(deleteinreposonly, f)
def add(filetoversionpath): with open(settings.syncdbpath, 'a') as db: dryfunc(settings.dry, db.write, filetoversionpath + os.linesep) logging.info("appended %s to db", filetoversionpath) undo.push(remove, filetoversionpath)