mercurial/dirstate.py
changeset 4525 78b6add1f966
parent 4507 289ec1f36b11
child 4527 b422b558015b
equal deleted inserted replaced
4524:6c58139f4eaa 4525:78b6add1f966
    41         if cwd.startswith(rootsep):
    41         if cwd.startswith(rootsep):
    42             return cwd[len(rootsep):]
    42             return cwd[len(rootsep):]
    43         else:
    43         else:
    44             # we're outside the repo. return an absolute path.
    44             # we're outside the repo. return an absolute path.
    45             return cwd
    45             return cwd
       
    46 
       
    47     def pathto(self, f, cwd=None):
       
    48         if cwd is None:
       
    49             cwd = self.getcwd()
       
    50         return util.pathto(self.root, cwd, f)
    46 
    51 
    47     def hgignore(self):
    52     def hgignore(self):
    48         '''return the contents of .hgignore files as a list of patterns.
    53         '''return the contents of .hgignore files as a list of patterns.
    49 
    54 
    50         the files parsed for patterns include:
    55         the files parsed for patterns include:
   401             if stat.S_ISCHR(st.st_mode): kind = _('character device')
   406             if stat.S_ISCHR(st.st_mode): kind = _('character device')
   402             elif stat.S_ISBLK(st.st_mode): kind = _('block device')
   407             elif stat.S_ISBLK(st.st_mode): kind = _('block device')
   403             elif stat.S_ISFIFO(st.st_mode): kind = _('fifo')
   408             elif stat.S_ISFIFO(st.st_mode): kind = _('fifo')
   404             elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
   409             elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
   405             elif stat.S_ISDIR(st.st_mode): kind = _('directory')
   410             elif stat.S_ISDIR(st.st_mode): kind = _('directory')
   406             self.ui.warn(_('%s: unsupported file type (type is %s)\n') % (
   411             self.ui.warn(_('%s: unsupported file type (type is %s)\n')
   407                 util.pathto(self.root, self.getcwd(), f),
   412                          % (self.pathto(f), kind))
   408                 kind))
       
   409         return False
   413         return False
   410 
   414 
   411     def walk(self, files=None, match=util.always, badmatch=None):
   415     def walk(self, files=None, match=util.always, badmatch=None):
   412         # filter out the stat
   416         # filter out the stat
   413         for src, f, st in self.statwalk(files, match, badmatch=badmatch):
   417         for src, f, st in self.statwalk(files, match, badmatch=badmatch):
   511                     if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'):
   515                     if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'):
   512                         found = True
   516                         found = True
   513                         break
   517                         break
   514                 if not found:
   518                 if not found:
   515                     if inst.errno != errno.ENOENT or not badmatch:
   519                     if inst.errno != errno.ENOENT or not badmatch:
   516                         self.ui.warn('%s: %s\n' % (
   520                         self.ui.warn('%s: %s\n' % (self.pathto(ff),
   517                             util.pathto(self.root, self.getcwd(), ff),
   521                                                    inst.strerror))
   518                             inst.strerror))
       
   519                     elif badmatch and badmatch(ff) and imatch(nf):
   522                     elif badmatch and badmatch(ff) and imatch(nf):
   520                         yield 'b', ff, None
   523                         yield 'b', ff, None
   521                 continue
   524                 continue
   522             if stat.S_ISDIR(st.st_mode):
   525             if stat.S_ISDIR(st.st_mode):
   523                 cmp1 = (lambda x, y: cmp(x[1], y[1]))
   526                 cmp1 = (lambda x, y: cmp(x[1], y[1]))