コード例 #1
0
    def _get_dirsandfiles(self, directory, dirs, files):
        tree = self._get_tree_cache(directory)

        retfiles = []
        retdirs = []
        bzrfiles = {}
        for path, state in tree.iteritems():
            mydir, name = os.path.split(path)
            if path.endswith('/'):
                mydir, name = os.path.split(mydir)
            if mydir != directory:
                continue
            rev, options, tag = "", "", ""
            if path.endswith('/'):
                retdirs.append(_vc.Dir(path[:-1], name, state))
            else:
                retfiles.append(_vc.File(path, name, state, rev, tag, options))
            bzrfiles[name] = 1
        for f, path in files:
            if f not in bzrfiles:
                #state = ignore_re.match(f) is None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in bzrfiles:
                #state = ignore_re.match(f) is None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))
        return retdirs, retfiles
コード例 #2
0
ファイル: monotone.py プロジェクト: BackupTheBerlios/pida-svn
    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        tree = self.get_tree()
        if len(files):
            directory = os.path.dirname(files[0][1])
        elif len(dirs):
            directory = os.path.dirname(dirs[0][1])
        else:
            return [], []

        retfiles = []
        retdirs = []
        vcfiles = {}

        for path, state in tree.iteritems():
            mydir, name = os.path.split(path)
            if path.endswith('/'):
                mydir, name = os.path.split(mydir)
            if mydir != directory:
                continue
            rev, date, options, tag = "", "", "", ""
            if path.endswith('/'):
                retdirs.append(_vc.Dir(path[:-1], name, state))
            else:
                retfiles.append(_vc.File(path, name, state, rev, tag, options))
            vcfiles[name] = 1
        for f, path in files:
            if f not in vcfiles:
                # if the ignore MT filter is not enabled these will crop up
                ignorelist = ['log', 'options', 'revision', 'work']

                if f not in ignorelist:
                    print "WARNING: '%s' was not listed by 'automate inventory'" % f

                # if it ain't listed by the inventory it's not under version
                # control
                state = _vc.STATE_NONE
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in vcfiles:
                # if the ignore MT filter is not enabled these will crop up
                ignorelist = ['MT']
                if d in ignorelist:
                    state = _vc.STATE_NONE
                else:
                    # monotone does not version (or inventory) directories
                    # so these are always normal
                    state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))
        return retdirs, retfiles
コード例 #3
0
    def _get_dirsandfiles(self, directory, dirs, files):
        tree = self._get_tree_cache(directory)

        if not directory in tree:
            return [], []

        retfiles = []
        retdirs = []

        dirtree = tree[directory]

        for name in sorted(dirtree.keys()):
            svn_state, rev = dirtree[name]
            path = os.path.join(directory, name)

            isdir = os.path.isdir(path)
            options = ""
            if isdir:
                if os.path.exists(path):
                    state = _vc.STATE_NORMAL
                else:
                    state = _vc.STATE_MISSING
                # svn adds the directory reported to the status list we get.
                if name != directory:
                    retdirs.append(_vc.Dir(path, name, state))
            else:
                state = self.state_map.get(svn_state, _vc.STATE_NONE)
                retfiles.append(_vc.File(path, name, state, rev, "", options))

        return retdirs, retfiles
コード例 #4
0
ファイル: rcs.py プロジェクト: mpjmuniz/meld
    def _get_dirsandfiles(self, directory, dirs, files):
        "files is array of (name, path). Assume all files in same dir."

        retfiles = []
        retdirs = [_vc.Dir(x[1], x[0], _vc.STATE_NONE) for x in dirs]
        rcscontents = os.listdir(os.path.join(directory, self.VC_DIR))

        for name, path in files:
            assert path.startswith(directory)

            if name + ",v" not in rcscontents:
                # not versioned
                state = _vc.STATE_NONE
            else:
                cmd = "rcsdiff -q --brief %s > /dev/null 2>&1" % path
                result = os.system(cmd)
                sysresult = (result & 0x00FF)
                cmdresult = (result & 0xFF00) >> 8
                if sysresult != 0:
                    print "Error getting state of file %s (exec error %d)" % (
                        path, sysresult)
                    state = _vc.STATE_ERROR
                elif cmdresult == 0:
                    state = _vc.STATE_NORMAL
                elif cmdresult == 1:
                    state = _vc.STATE_MODIFIED
                else:
                    print "Error getting state of file %s: %d" % (path, result)
                    state = _vc.STATE_ERROR

            retfiles.append(_vc.File(path, name, state, "", "", ""))

        return retdirs, retfiles
コード例 #5
0
ファイル: monotone.py プロジェクト: mpjmuniz/meld
    def _get_dirsandfiles(self, directory, dirs, files):

        tree = self._get_tree_cache(directory)

        retfiles = []
        retdirs = []
        vcfiles = {}

        for path, state in tree.iteritems():
            mydir, name = os.path.split(path)
            if path.endswith('/'):
                mydir, name = os.path.split(mydir)
            if mydir != directory:
                continue
            rev, options, tag = "", "", ""
            if path.endswith('/'):
                retdirs.append(_vc.Dir(path[:-1], name, state))
            else:
                retfiles.append(_vc.File(path, name, state, rev, tag, options))
            vcfiles[name] = 1
        for f, path in files:
            if f not in vcfiles:
                # if the ignore MT filter is not enabled these will crop up
                ignorelist = [
                    'format', 'log', 'options', 'revision', 'work', 'debug',
                    'inodeprints'
                ]

                if f not in ignorelist:
                    print "WARNING: '%s' was not listed by 'automate inventory'" % f

                # if it ain't listed by the inventory it's not under version
                # control
                state = _vc.STATE_NONE
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in vcfiles:
                # if the ignore MT filter is not enabled these will crop up
                ignorelist = ['MT']
                if d in ignorelist:
                    state = _vc.STATE_NONE
                else:
                    # monotone does not version (or inventory) directories
                    # so these are always normal
                    state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))
        return retdirs, retfiles
コード例 #6
0
ファイル: _null.py プロジェクト: mpjmuniz/meld
    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        if len(files) == 0 and len(dirs) == 0:
            return [], []

        d = map(lambda x: _vc.Dir(x[1], x[0], _vc.STATE_NONE), dirs)
        f = map(lambda x: _vc.File(x[1], x[0], _vc.STATE_NONE, None), files)
        return d, f
コード例 #7
0
    def _get_dirsandfiles(self, directory, dirs, files):

        try:
            entries = open(os.path.join(directory, self.VC_DIR, "Entries")).read()
            # poor mans universal newline
            entries = entries.replace("\r","\n").replace("\n\n","\n")
        except IOError, e: # no cvs dir
            d = map(lambda x: _vc.Dir(x[1],x[0], _vc.STATE_NONE), dirs)
            f = map(lambda x: _vc.File(x[1],x[0], _vc.STATE_NONE, None), files)
            return d,f
コード例 #8
0
ファイル: bzr.py プロジェクト: BackupTheBerlios/pida-svn
    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        tree = self.get_tree()
        if len(files):
            directory = os.path.dirname(files[0][1])
        elif len(dirs):
            directory = os.path.dirname(dirs[0][1])
        else:
            return [], []

        retfiles = []
        retdirs = []
        bzrfiles = {}
        for path, state in tree.iteritems():
            mydir, name = os.path.split(path)
            if path.endswith('/'):
                mydir, name = os.path.split(mydir)
            if mydir != directory:
                continue
            rev, date, options, tag = "", "", "", ""
            if path.endswith('/'):
                retdirs.append(_vc.Dir(path[:-1], name, state))
            else:
                retfiles.append(_vc.File(path, name, state, rev, tag, options))
            bzrfiles[name] = 1
        for f, path in files:
            if f not in bzrfiles:
                #state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in bzrfiles:
                #state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))
        return retdirs, retfiles
コード例 #9
0
ファイル: cvs.py プロジェクト: BackupTheBerlios/pida-svn
    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        if len(files):
            directory = os.path.dirname(files[0][1])
        elif len(dirs):
            directory = os.path.dirname(dirs[0][1])
        else:
            return [],[]

        try:
            entries = open( os.path.join(directory, "CVS/Entries")).read()
            # poor mans universal newline
            entries = entries.replace("\r","\n").replace("\n\n","\n")
        except IOError, e: # no cvs dir
            d = map(lambda x: _vc.Dir(x[1],x[0], _vc.STATE_NONE), dirs)
            f = map(lambda x: _vc.File(x[1],x[0], _vc.STATE_NONE, None), files)
            return d,f
コード例 #10
0
    def _get_dirsandfiles(self, directory, dirs, files):

        tree = self._get_tree_cache(directory)

        retfiles = []
        retdirs = []
        for name, path in files:
            state = tree.get(path, _vc.STATE_NORMAL)
            retfiles.append(_vc.File(path, name, state))
        for name, path in dirs:
            # git does not operate on dirs, just files
            retdirs.append(_vc.Dir(path, name, _vc.STATE_NORMAL))
        for path, state in tree.iteritems():
            # removed files are not in the filesystem, so must be added here
            if state is _vc.STATE_REMOVED:
                folder, name = os.path.split(path)
                if folder == directory:
                    retfiles.append(_vc.File(path, name, state))
        return retdirs, retfiles
コード例 #11
0
ファイル: svn.py プロジェクト: mpjmuniz/meld
    def _get_dirsandfiles(self, directory, dirs, files):
        retfiles = []
        retdirs = []

        for match in self._get_matches(directory):
            name = match[0]
            isdir = os.path.isdir(name)
            path = os.path.join(directory, name)
            rev = match[2]
            options = ""
            if isdir:
                if os.path.exists(path):
                    state = _vc.STATE_NORMAL
                else:
                    state = _vc.STATE_MISSING
                # svn adds the directory reported to the status list we get.
                if name != directory:
                    retdirs.append(_vc.Dir(path, name, state))
            else:
                state = self.state_map.get(match[1], _vc.STATE_NONE)
                retfiles.append(_vc.File(path, name, state, rev, "", options))

        return retdirs, retfiles
コード例 #12
0
    def _get_dirsandfiles(self, directory, dirs, files):

        tree = self._get_tree_cache(directory)

        retfiles = []
        retdirs = []
        vcfiles = {}

        for path, state in tree.iteritems():
            mydir, name = os.path.split(path)
            if path.endswith('/'):
                mydir, name = os.path.split(mydir)
            if mydir != directory:
                continue

            rev = ""
            while True:
                try:
                    entries = _vc.popen([self.CMD, "finfo", "-s", path],
                                        cwd=self.root).read().split(" ", 1)
                    # Process entries which have revision numbers.
                    if entries[0] in [
                            'renamed', 'edited', 'deleted', 'unchanged'
                    ]:
                        rev = entries[1].strip()
                    break
                except OSError, e:
                    if e.errno != errno.EAGAIN:
                        raise

            options, tag = "", ""
            if path.endswith('/'):
                retdirs.append(_vc.Dir(path[:-1], name, state))
            else:
                retfiles.append(_vc.File(path, name, state, rev, tag, options))
            vcfiles[name] = 1
コード例 #13
0
class Vc(_vc.Vc):

    CMD = "hg"
    NAME = "Mercurial"
    PATCH_STRIP_NUM = 1
    PATCH_INDEX_RE = "^diff(.*)$"

    def __init__(self, location):
        while location != "/":
            if os.path.isdir("%s/.hg" % location):
                self.root = location
                return
            location = os.path.dirname(location)
        raise ValueError()

    def commit_command(self, message):
        return [self.CMD, "commit", "-m", message]

    def diff_command(self):
        return [self.CMD, "diff"]

    def update_command(self):
        return [self.CMD, "update"]

    def add_command(self, binary=0):
        return [self.CMD, "add"]

    def remove_command(self, force=0):
        return [self.CMD, "rm"]

    def revert_command(self):
        return [self.CMD, "revert"]

    def get_working_directory(self, workdir):
        return self.root

    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        if len(files):
            directory = os.path.dirname(files[0][1])
        elif len(dirs):
            directory = os.path.dirname(dirs[0][1])
        else:
            return [], []

        while 1:
            try:
                entries = os.popen("cd %s && hg status " %
                                   directory).read().split("\n")[:-1]
                break
            except OSError, e:
                if e.errno != errno.EAGAIN:
                    raise

        retfiles = []
        retdirs = []
        statemap = {
            "?": _vc.STATE_NONE,
            "A": _vc.STATE_NEW,
            " ": _vc.STATE_NORMAL,
            "!": _vc.STATE_MISSING,
            "I": _vc.STATE_IGNORED,
            "M": _vc.STATE_MODIFIED,
            "C": _vc.STATE_CONFLICT
        }
        hgfiles = {}
        for statekey, name in [(entry[0], entry[2:]) for entry in entries
                               if entry.find("/") == -1]:
            path = os.path.join(directory, name)
            rev, date, options, tag = "", "", "", ""
            state = statemap.get(statekey, _vc.STATE_NONE)
            retfiles.append(_vc.File(path, name, state, rev, tag, options))
            hgfiles[name] = 1
        for f, path in files:
            if f not in hgfiles:
                #state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in hgfiles:
                #state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))

        return retdirs, retfiles
コード例 #14
0
ファイル: cvs.py プロジェクト: BackupTheBerlios/pida-svn
        matches = re.findall("^(D?)/([^/]+)/(.+)$(?m)", entries)
        matches.sort()

        for match in matches:
            isdir = match[0]
            name = match[1]
            path = os.path.join(directory, name)
            rev, date, options, tag = match[2].split("/")
            if tag:
                tag = tag[1:]
            if isdir:
                if os.path.exists(path):
                    state = _vc.STATE_NORMAL
                else:
                    state = _vc.STATE_MISSING
                retdirs.append( _vc.Dir(path,name,state) )
            else:
                if rev.startswith("-"):
                    state = _vc.STATE_REMOVED
                elif date=="dummy timestamp":
                    if rev[0] == "0":
                        state = _vc.STATE_NEW
                    else:
                        print "Revision '%s' not understood" % rev
                elif date=="dummy timestamp from new-entry":
                    state = _vc.STATE_MODIFIED
                else:
                    date = re.sub(r"\s*\d+", lambda x : "%3i" % int(x.group()), date, 1)
                    plus = date.find("+")
                    if plus >= 0:
                        state = _vc.STATE_CONFLICT
コード例 #15
0
ファイル: svn.py プロジェクト: BackupTheBerlios/pida-svn
class Vc(_vc.Vc):

    CMD = "svn"
    NAME = "Subversion"
    PATCH_INDEX_RE = "^Index:(.*)$"

    def __init__(self, location):
        if not os.path.exists("%s/.svn"%location):
            raise ValueError()

    def commit_command(self, message):
        return [self.CMD,"commit","-m",message]
    def diff_command(self):
        return [self.CMD,"diff"]
    def update_command(self):
        return [self.CMD,"update"]
    def add_command(self, binary=0):
        if binary:
            return [self.CMD,"add","-kb"]
        return [self.CMD,"add"]
    def remove_command(self, force=0):
        return [self.CMD,"rm","--force"]
    def revert_command(self):
        return [self.CMD,"revert"]

    def lookup_files(self, dirs, files):
        "files is array of (name, path). assume all files in same dir"
        if len(files):
            directory = os.path.dirname(files[0][1])
        elif len(dirs):
            directory = os.path.dirname(dirs[0][1])
        else:
            return [],[]

        while 1:
            try:
                entries = os.popen("svn status -Nv --no-ignore "+directory).read()
                break
            except OSError, e:
                if e.errno != errno.EAGAIN:
                    raise

        retfiles = []
        retdirs = []
        matches = re.findall("^(.)....\s*\d*\s*(\d*)\s*\w*\s*(.*?)$(?m)", entries)
        matches = [ (m[2].split()[-1],m[0],m[1]) for m in matches]
        matches.sort()

        for match in matches:
            name = match[0]
            if(match[1] == "!" or match[1] == "A"):
                # for new or missing files, the findall expression
                # does not supply the correct name 
                name = re.sub(r'^[?]\s*(.*)$', r'\1', name)
            isdir = os.path.isdir(name)
            path = os.path.join(directory, name)
            rev = match[2]
            options = ""
            tag = ""
            if tag:
                tag = tag[1:]
            if isdir:
                if os.path.exists(path):
                    state = _vc.STATE_NORMAL
                else:
                    state = _vc.STATE_MISSING
                # svn adds the directory reported to the status list we get.
                if name != directory:
                    retdirs.append( _vc.Dir(path,name,state) )
            else:
                state = { "?": _vc.STATE_NONE,
                          "A": _vc.STATE_NEW,
                          " ": _vc.STATE_NORMAL,
                          "!": _vc.STATE_MISSING,
                          "I": _vc.STATE_IGNORED,
                          "M": _vc.STATE_MODIFIED,
                          "D":_vc.STATE_REMOVED,
                          "C": _vc.STATE_CONFLICT }.get(match[1], _vc.STATE_NONE)
                retfiles.append( _vc.File(path, name, state, rev, tag, options) )

        return retdirs, retfiles
コード例 #16
0
class Vc(_vc.Vc):

    CMD = "hg"
    NAME = "Mercurial"
    VC_DIR = ".hg"
    PATCH_STRIP_NUM = 1
    # Mercurial diffs can be run in "git" mode
    PATCH_INDEX_RE = "^diff (?:-r \w+ |--git a/.* b/)(.*)$"
    DIFF_GIT_MODE = False
    state_map = {
        "?": _vc.STATE_NONE,
        "A": _vc.STATE_NEW,
        "C": _vc.STATE_NORMAL,
        "!": _vc.STATE_MISSING,
        "I": _vc.STATE_IGNORED,
        "M": _vc.STATE_MODIFIED,
        "R": _vc.STATE_REMOVED,
    }

    def commit_command(self, message):
        return [self.CMD, "commit", "-m", message]

    def diff_command(self):
        ret = [self.CMD, "diff"]
        if self.DIFF_GIT_MODE:
            ret.append("--git")
        return ret

    def update_command(self):
        return [self.CMD, "update"]

    def add_command(self, binary=0):
        return [self.CMD, "add"]

    def remove_command(self, force=0):
        return [self.CMD, "rm"]

    def revert_command(self):
        return [self.CMD, "revert"]

    def valid_repo(self):
        if _vc.call([self.CMD, "root"], cwd=self.root):
            return False
        else:
            return True

    def get_working_directory(self, workdir):
        return self.root

    def _get_dirsandfiles(self, directory, dirs, files):

        while 1:
            try:
                entries = _vc.popen([self.CMD, "status", "-A", "."],
                                    cwd=directory).read().split("\n")[:-1]
                break
            except OSError, e:
                if e.errno != errno.EAGAIN:
                    raise

        retfiles = []
        retdirs = []
        hgfiles = {}
        for statekey, name in [(entry[0], entry[2:]) for entry in entries
                               if entry.find("/") == -1]:
            path = os.path.join(directory, name)
            rev, options, tag = "", "", ""
            state = self.state_map.get(statekey, _vc.STATE_NONE)
            retfiles.append(_vc.File(path, name, state, rev, tag, options))
            hgfiles[name] = 1
        for f, path in files:
            if f not in hgfiles:
                #state = ignore_re.match(f) is None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retfiles.append(_vc.File(path, f, state, ""))
        for d, path in dirs:
            if d not in hgfiles:
                #state = ignore_re.match(f) is None and _vc.STATE_NONE or _vc.STATE_IGNORED
                state = _vc.STATE_NORMAL
                retdirs.append(_vc.Dir(path, d, state))

        return retdirs, retfiles