示例#1
0
    def __init__(self, name, log, options):
        log.debug("*** __init__ repository (is init: %d)" %
                  (self.__class__.p4init))
        Repository.__init__(self, name, None, log)
        if self.__class__.p4init == 0:
            self.__class__.p4init = 1
            self.__class__.p4c = p4.P4()
            self.__class__.p4c.port = options['port']
            self.__class__.p4c.user = options['user']
            self.__class__.p4c.client = options['client']
            self.__class__.p4c.password = options['passwd']
            self.__class__.p4c.parse_forms()
            try:
                self.__class__.p4c.connect()
                log.debug("*** __init__ repository connected !!!")
            except self.__class__.p4c.P4Error:
                for e in p4.errors:
                    self.log.debug(e)
                self.__class__.p4init = 0

        try:
            # cache the first few changes
            self.__class__.history = []
            changes = self.__class__.p4c.run_changes("-m", "10", "-s",
                                                     "submitted")
            for change in changes:
                self.__class__.history.append(change['change'])

        except:
            for e in self.__class__.p4c.errors:
                self.log.debug(e)
            self.__class__.p4init = 0
示例#2
0
    def __init__(self, name, log, options):
        Repository.__init__(self, name, None, log)
        self.p4c = p4.P4()
        self.p4c.port = options['port']
        self.p4c.user = options['user']
        self.p4c.client = options['client']
        self.p4c.password = options['passwd']
        self.p4c.parse_forms()
        try:
            self.p4c.connect()
            # cache the first few changes
            self.history = []
            changes = self.p4c.run("changes", "-m", "options['maxItems']",
                                   "-s", "submitted")
            for change in changes:
                self.history.append(change['change'])

        except self.p4c.P4Error:
            for e in p4.errors:
                self.log.debug(e)
示例#3
0
import os, string, shutil, sys, re, p4

perforce = p4.P4()
perforce.connect()


def OpenForEdit(filename):
    success = len(perforce.run_edit(filename)) >= 1
    if not success:
        print(('Error while opening %s for edit.' % filename))
    return success


def RecurseDirectory(dir, function):
    paths = []
    for root, dirs, files in os.walk(dir):
        for file in files:
            if not function or function(os.path.join(root, file)):
                paths.append(os.path.join(root, file))
    return paths


def IsProjectFile(file):
    return not re.search('wsfiles', file, re.I) and re.match(
        r'^.*\.vcproj$', file, re.I)


def EnsureConfigIsCorrect(config):
    if config.lower() != 'debug' and config.lower() != 'release':
        assert (False and 'Unknown configuration')