Exemplo n.º 1
0
    def _walkexplicit(self, match, subrepos):
        '''Get stat data about the files explicitly specified by match.

        Return a triple (results, dirsfound, dirsnotfound).
        - results is a mapping from filename to stat result. It also contains
          listings mapping subrepos and .hg to None.
        - dirsfound is a list of files found to be directories.
        - dirsnotfound is a list of files that the dirstate thinks are
          directories and that were not found.'''
        def badtype(mode):
            kind = _('unknown')
            if stat.S_ISCHR(mode):
                kind = _('character device')
            elif stat.S_ISBLK(mode):
                kind = _('block device')
            elif stat.S_ISFIFO(mode):
                kind = _('fifo')
            elif stat.S_ISSOCK(mode):
                kind = _('socket')
            elif stat.S_ISDIR(mode):
                kind = _('directory')
            return _('unsupported file type (type is %s)') % kind

        matchedir = match.explicitdir
        badfn = match.bad
        dmap = self._map
        normpath = util.normpath
        lstat = os.lstat
        getkind = stat.S_IFMT
        dirkind = stat.S_IFDIR
        regkind = stat.S_IFREG
        lnkkind = stat.S_IFLNK
        join = self._join
        dirsfound = []
        foundadd = dirsfound.append
        dirsnotfound = []
        notfoundadd = dirsnotfound.append

        if match.matchfn != match.exact and self._checkcase:
            normalize = self._normalize
        else:
            normalize = None

        files = sorted(match.files())
        subrepos.sort()
        i, j = 0, 0
        while i < len(files) and j < len(subrepos):
            subpath = subrepos[j] + "/"
            if files[i] < subpath:
                i += 1
                continue
            while i < len(files) and files[i].startswith(subpath):
                del files[i]
            j += 1

        if not files or '.' in files:
            files = ['']
        results = dict.fromkeys(subrepos)
        results['.hg'] = None

        alldirs = None
        for ff in files:
            if normalize:
                nf = normalize(normpath(ff), False, True)
            else:
                nf = normpath(ff)
            if nf in results:
                continue

            try:
                st = lstat(join(nf))
                kind = getkind(st.st_mode)
                if kind == dirkind:
                    if nf in dmap:
                        # file replaced by dir on disk but still in dirstate
                        results[nf] = None
                    if matchedir:
                        matchedir(nf)
                    foundadd(nf)
                elif kind == regkind or kind == lnkkind:
                    results[nf] = st
                else:
                    badfn(ff, badtype(kind))
                    if nf in dmap:
                        results[nf] = None
            except OSError, inst:  # nf not found on disk - it is dirstate only
                if nf in dmap:  # does it exactly match a missing file?
                    results[nf] = None
                else:  # does it match a missing directory?
                    if alldirs is None:
                        alldirs = scmutil.dirs(dmap)
                    if nf in alldirs:
                        if matchedir:
                            matchedir(nf)
                        notfoundadd(nf)
                    else:
                        badfn(ff, inst.strerror)
Exemplo n.º 2
0
 def _dirs(self):
     return scmutil.dirs(self._map, 'r')
Exemplo n.º 3
0
 def _dirs(self):
     return scmutil.dirs(self._map, 'r')
Exemplo n.º 4
0
 def _dirs(self):
     return scmutil.dirs(self._manifest)
Exemplo n.º 5
0
 def _dirs(self):
     return scmutil.dirs(self._manifest)
Exemplo n.º 6
0
    def _walkexplicit(self, match, subrepos):
        '''Get stat data about the files explicitly specified by match.

        Return a triple (results, dirsfound, dirsnotfound).
        - results is a mapping from filename to stat result. It also contains
          listings mapping subrepos and .hg to None.
        - dirsfound is a list of files found to be directories.
        - dirsnotfound is a list of files that the dirstate thinks are
          directories and that were not found.'''

        def badtype(mode):
            kind = _('unknown')
            if stat.S_ISCHR(mode):
                kind = _('character device')
            elif stat.S_ISBLK(mode):
                kind = _('block device')
            elif stat.S_ISFIFO(mode):
                kind = _('fifo')
            elif stat.S_ISSOCK(mode):
                kind = _('socket')
            elif stat.S_ISDIR(mode):
                kind = _('directory')
            return _('unsupported file type (type is %s)') % kind

        matchedir = match.explicitdir
        badfn = match.bad
        dmap = self._map
        normpath = util.normpath
        lstat = os.lstat
        getkind = stat.S_IFMT
        dirkind = stat.S_IFDIR
        regkind = stat.S_IFREG
        lnkkind = stat.S_IFLNK
        join = self._join
        dirsfound = []
        foundadd = dirsfound.append
        dirsnotfound = []
        notfoundadd = dirsnotfound.append

        if match.matchfn != match.exact and self._checkcase:
            normalize = self._normalize
        else:
            normalize = None

        files = sorted(match.files())
        subrepos.sort()
        i, j = 0, 0
        while i < len(files) and j < len(subrepos):
            subpath = subrepos[j] + "/"
            if files[i] < subpath:
                i += 1
                continue
            while i < len(files) and files[i].startswith(subpath):
                del files[i]
            j += 1

        if not files or '.' in files:
            files = ['']
        results = dict.fromkeys(subrepos)
        results['.hg'] = None

        alldirs = None
        for ff in files:
            if normalize:
                nf = normalize(normpath(ff), False, True)
            else:
                nf = normpath(ff)
            if nf in results:
                continue

            try:
                st = lstat(join(nf))
                kind = getkind(st.st_mode)
                if kind == dirkind:
                    if nf in dmap:
                        # file replaced by dir on disk but still in dirstate
                        results[nf] = None
                    if matchedir:
                        matchedir(nf)
                    foundadd((nf, ff))
                elif kind == regkind or kind == lnkkind:
                    results[nf] = st
                else:
                    badfn(ff, badtype(kind))
                    if nf in dmap:
                        results[nf] = None
            except OSError, inst: # nf not found on disk - it is dirstate only
                if nf in dmap: # does it exactly match a missing file?
                    results[nf] = None
                else: # does it match a missing directory?
                    if alldirs is None:
                        alldirs = scmutil.dirs(dmap)
                    if nf in alldirs:
                        if matchedir:
                            matchedir(nf)
                        notfoundadd(nf)
                    else:
                        badfn(ff, inst.strerror)
Exemplo n.º 7
0
 def _alldirs(self):
     return scmutil.dirs(self)
Exemplo n.º 8
0
 def _dirs(self):
     return scmutil.dirs(self)