mercurial/dirstate.py
changeset 4948 6fd953d5faea
parent 4947 81078e177266
child 4949 fc61495ea9cf
equal deleted inserted replaced
4947:81078e177266 4948:6fd953d5faea
   116     def setbranch(self, branch):
   116     def setbranch(self, branch):
   117         self._branch = branch
   117         self._branch = branch
   118         self._opener("branch", "w").write(branch + '\n')
   118         self._opener("branch", "w").write(branch + '\n')
   119 
   119 
   120     def state(self, key):
   120     def state(self, key):
       
   121         ''' current states:
       
   122         n  normal
       
   123         m  needs merging
       
   124         r  marked for removal
       
   125         a  marked for addition'''
   121         return self._map.get(key, ("?",))[0]
   126         return self._map.get(key, ("?",))[0]
   122 
   127 
   123     def _read(self):
   128     def _read(self):
   124         self._map = {}
   129         self._map = {}
   125         self._copymap = {}
   130         self._copymap = {}
   195                 break
   200                 break
   196             if d in self._map:
   201             if d in self._map:
   197                 raise util.Abort(_('file named %r already in dirstate') % d)
   202                 raise util.Abort(_('file named %r already in dirstate') % d)
   198         self._incpath(f)
   203         self._incpath(f)
   199 
   204 
   200     def update(self, files, state, **kw):
   205     def normal(self, f):
   201         ''' current states:
   206         'mark a file normal'
   202         n  normal
   207         self._dirty = True
   203         m  needs merging
   208         s = os.lstat(self.wjoin(f))
   204         r  marked for removal
   209         self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime)
   205         a  marked for addition'''
   210         if self._copymap.has_key(f):
   206 
   211             del self._copymap[f]
   207         if not files: return
   212 
   208         self._dirty = True
   213     def normaldirty(self, f):
   209         for f in files:
   214         'mark a file normal, but possibly dirty'
   210             if self._copymap.has_key(f):
   215         self._dirty = True
   211                 del self._copymap[f]
   216         s = os.lstat(self.wjoin(f))
   212 
   217         self._map[f] = ('n', s.st_mode, -1, -1)
   213             if state == "r":
   218         if f in self._copymap:
   214                 self._map[f] = ('r', 0, 0, 0)
   219             del self._copymap[f]
   215                 self._decpath(f)
   220 
   216                 continue
   221     def add(self, f):
   217             else:
   222         'mark a file added'
   218                 if state == "a":
   223         self._dirty = True
   219                     self._incpathcheck(f)
   224         self._incpathcheck(f)
   220                 s = os.lstat(self.wjoin(f))
   225         s = os.lstat(self.wjoin(f))
   221                 st_size = kw.get('st_size', s.st_size)
   226         self._map[f] = ('a', s.st_mode, s.st_size, s.st_mtime)
   222                 st_mtime = kw.get('st_mtime', s.st_mtime)
   227         if f in self._copymap:
   223                 self._map[f] = (state, s.st_mode, st_size, st_mtime)
   228             del self._copymap[f]
   224 
   229 
   225     def forget(self, files):
   230     def remove(self, f):
   226         if not files: return
   231         'mark a file removed'
   227         self._dirty = True
   232         self._dirty = True
   228         for f in files:
   233         self._map[f] = ('r', 0, 0, 0)
   229             try:
   234         self._decpath(f)
   230                 del self._map[f]
   235         if f in self._copymap:
   231                 self._decpath(f)
   236             del self._copymap[f]
   232             except KeyError:
   237 
   233                 self._ui.warn(_("not in dirstate: %s!\n") % f)
   238     def merge(self, f):
   234                 pass
   239         'mark a file merged'
       
   240         self._dirty = True
       
   241         s = os.lstat(self.wjoin(f))
       
   242         self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime)
       
   243         if f in self._copymap:
       
   244             del self._copymap[f]
       
   245 
       
   246     def forget(self, f):
       
   247         'forget a file'
       
   248         self._dirty = True
       
   249         try:
       
   250             del self._map[f]
       
   251             self._decpath(f)
       
   252         except KeyError:
       
   253             self._ui.warn(_("not in dirstate: %s!\n") % f)
   235 
   254 
   236     def rebuild(self, parent, files):
   255     def rebuild(self, parent, files):
   237         self.invalidate()
   256         self.invalidate()
   238         for f in files:
   257         for f in files:
   239             if files.execf(f):
   258             if files.execf(f):