mercurial/dirstate.py
changeset 4949 fc61495ea9cf
parent 4948 6fd953d5faea
child 4950 30847b8af7ca
equal deleted inserted replaced
4948:6fd953d5faea 4949:fc61495ea9cf
    50             self._dirs = {}
    50             self._dirs = {}
    51             for f in self._map:
    51             for f in self._map:
    52                 self._incpath(f)
    52                 self._incpath(f)
    53             return self._dirs
    53             return self._dirs
    54         elif name == '_ignore':
    54         elif name == '_ignore':
    55             files = [self.wjoin('.hgignore')]
    55             files = [self._join('.hgignore')]
    56             for name, path in self._ui.configitems("ui"):
    56             for name, path in self._ui.configitems("ui"):
    57                 if name == 'ignore' or name.startswith('ignore.'):
    57                 if name == 'ignore' or name.startswith('ignore.'):
    58                     files.append(os.path.expanduser(path))
    58                     files.append(os.path.expanduser(path))
    59             self._ignore = ignore.ignore(self._root, files, self._ui.warn)
    59             self._ignore = ignore.ignore(self._root, files, self._ui.warn)
    60             return self._ignore
    60             return self._ignore
    62             self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/'
    62             self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/'
    63             return self._slash
    63             return self._slash
    64         else:
    64         else:
    65             raise AttributeError, name
    65             raise AttributeError, name
    66 
    66 
    67     def wjoin(self, f):
    67     def _join(self, f):
    68         return os.path.join(self._root, f)
    68         return os.path.join(self._root, f)
    69 
    69 
    70     def getcwd(self):
    70     def getcwd(self):
    71         cwd = os.getcwd()
    71         cwd = os.getcwd()
    72         if cwd == self._root: return ''
    72         if cwd == self._root: return ''
   203         self._incpath(f)
   203         self._incpath(f)
   204 
   204 
   205     def normal(self, f):
   205     def normal(self, f):
   206         'mark a file normal'
   206         'mark a file normal'
   207         self._dirty = True
   207         self._dirty = True
   208         s = os.lstat(self.wjoin(f))
   208         s = os.lstat(self._join(f))
   209         self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime)
   209         self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime)
   210         if self._copymap.has_key(f):
   210         if self._copymap.has_key(f):
   211             del self._copymap[f]
   211             del self._copymap[f]
   212 
   212 
   213     def normaldirty(self, f):
   213     def normaldirty(self, f):
   214         'mark a file normal, but possibly dirty'
   214         'mark a file normal, but possibly dirty'
   215         self._dirty = True
   215         self._dirty = True
   216         s = os.lstat(self.wjoin(f))
   216         s = os.lstat(self._join(f))
   217         self._map[f] = ('n', s.st_mode, -1, -1)
   217         self._map[f] = ('n', s.st_mode, -1, -1)
   218         if f in self._copymap:
   218         if f in self._copymap:
   219             del self._copymap[f]
   219             del self._copymap[f]
   220 
   220 
   221     def add(self, f):
   221     def add(self, f):
   222         'mark a file added'
   222         'mark a file added'
   223         self._dirty = True
   223         self._dirty = True
   224         self._incpathcheck(f)
   224         self._incpathcheck(f)
   225         s = os.lstat(self.wjoin(f))
   225         s = os.lstat(self._join(f))
   226         self._map[f] = ('a', s.st_mode, s.st_size, s.st_mtime)
   226         self._map[f] = ('a', s.st_mode, s.st_size, s.st_mtime)
   227         if f in self._copymap:
   227         if f in self._copymap:
   228             del self._copymap[f]
   228             del self._copymap[f]
   229 
   229 
   230     def remove(self, f):
   230     def remove(self, f):
   236             del self._copymap[f]
   236             del self._copymap[f]
   237 
   237 
   238     def merge(self, f):
   238     def merge(self, f):
   239         'mark a file merged'
   239         'mark a file merged'
   240         self._dirty = True
   240         self._dirty = True
   241         s = os.lstat(self.wjoin(f))
   241         s = os.lstat(self._join(f))
   242         self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime)
   242         self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime)
   243         if f in self._copymap:
   243         if f in self._copymap:
   244             del self._copymap[f]
   244             del self._copymap[f]
   245 
   245 
   246     def forget(self, f):
   246     def forget(self, f):
   414 
   414 
   415         # step one, find all files that match our criteria
   415         # step one, find all files that match our criteria
   416         files.sort()
   416         files.sort()
   417         for ff in files:
   417         for ff in files:
   418             nf = util.normpath(ff)
   418             nf = util.normpath(ff)
   419             f = self.wjoin(ff)
   419             f = self._join(ff)
   420             try:
   420             try:
   421                 st = os.lstat(f)
   421                 st = os.lstat(f)
   422             except OSError, inst:
   422             except OSError, inst:
   423                 found = False
   423                 found = False
   424                 for fn in dc:
   424                 for fn in dc:
   469                 continue
   469                 continue
   470             if src == 'm':
   470             if src == 'm':
   471                 nonexistent = True
   471                 nonexistent = True
   472                 if not st:
   472                 if not st:
   473                     try:
   473                     try:
   474                         st = os.lstat(self.wjoin(fn))
   474                         st = os.lstat(self._join(fn))
   475                     except OSError, inst:
   475                     except OSError, inst:
   476                         if inst.errno != errno.ENOENT:
   476                         if inst.errno != errno.ENOENT:
   477                             raise
   477                             raise
   478                         st = None
   478                         st = None
   479                     # We need to re-check that it is a valid file
   479                     # We need to re-check that it is a valid file
   485                     deleted.append(fn)
   485                     deleted.append(fn)
   486                     continue
   486                     continue
   487             # check the common case first
   487             # check the common case first
   488             if type_ == 'n':
   488             if type_ == 'n':
   489                 if not st:
   489                 if not st:
   490                     st = os.lstat(self.wjoin(fn))
   490                     st = os.lstat(self._join(fn))
   491                 if (size >= 0 and (size != st.st_size
   491                 if (size >= 0 and (size != st.st_size
   492                                    or (mode ^ st.st_mode) & 0100)
   492                                    or (mode ^ st.st_mode) & 0100)
   493                     or fn in self._copymap):
   493                     or fn in self._copymap):
   494                     modified.append(fn)
   494                     modified.append(fn)
   495                 elif time != int(st.st_mtime):
   495                 elif time != int(st.st_mtime):