mercurial/dirstate.py
changeset 10968 7a0d096e221e
parent 10935 5f10634f9e68
child 11769 ca6cebd8734e
equal deleted inserted replaced
10967:479f15f3faa9 10968:7a0d096e221e
   283 
   283 
   284     def normallookup(self, f):
   284     def normallookup(self, f):
   285         '''Mark a file normal, but possibly dirty.'''
   285         '''Mark a file normal, but possibly dirty.'''
   286         if self._pl[1] != nullid and f in self._map:
   286         if self._pl[1] != nullid and f in self._map:
   287             # if there is a merge going on and the file was either
   287             # if there is a merge going on and the file was either
   288             # in state 'm' or dirty before being removed, restore that state.
   288             # in state 'm' (-1) or coming from other parent (-2) before
       
   289             # being removed, restore that state.
   289             entry = self._map[f]
   290             entry = self._map[f]
   290             if entry[0] == 'r' and entry[2] in (-1, -2):
   291             if entry[0] == 'r' and entry[2] in (-1, -2):
   291                 source = self._copymap.get(f)
   292                 source = self._copymap.get(f)
   292                 if entry[2] == -1:
   293                 if entry[2] == -1:
   293                     self.merge(f)
   294                     self.merge(f)
   294                 elif entry[2] == -2:
   295                 elif entry[2] == -2:
   295                     self.normaldirty(f)
   296                     self.otherparent(f)
   296                 if source:
   297                 if source:
   297                     self.copy(source, f)
   298                     self.copy(source, f)
   298                 return
   299                 return
   299             if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
   300             if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
   300                 return
   301                 return
   302         self._addpath(f)
   303         self._addpath(f)
   303         self._map[f] = ('n', 0, -1, -1)
   304         self._map[f] = ('n', 0, -1, -1)
   304         if f in self._copymap:
   305         if f in self._copymap:
   305             del self._copymap[f]
   306             del self._copymap[f]
   306 
   307 
   307     def normaldirty(self, f):
   308     def otherparent(self, f):
   308         '''Mark a file normal, but dirty.'''
   309         '''Mark as coming from the other parent, always dirty.'''
       
   310         if self._pl[1] == nullid:
       
   311             raise util.Abort(_("setting %r to other parent "
       
   312                                "only allowed in merges") % f)
   309         self._dirty = True
   313         self._dirty = True
   310         self._addpath(f)
   314         self._addpath(f)
   311         self._map[f] = ('n', 0, -2, -1)
   315         self._map[f] = ('n', 0, -2, -1)
   312         if f in self._copymap:
   316         if f in self._copymap:
   313             del self._copymap[f]
   317             del self._copymap[f]
   324         '''Mark a file removed.'''
   328         '''Mark a file removed.'''
   325         self._dirty = True
   329         self._dirty = True
   326         self._droppath(f)
   330         self._droppath(f)
   327         size = 0
   331         size = 0
   328         if self._pl[1] != nullid and f in self._map:
   332         if self._pl[1] != nullid and f in self._map:
       
   333             # backup the previous state
   329             entry = self._map[f]
   334             entry = self._map[f]
   330             if entry[0] == 'm':
   335             if entry[0] == 'm': # merge
   331                 size = -1
   336                 size = -1
   332             elif entry[0] == 'n' and entry[2] == -2:
   337             elif entry[0] == 'n' and entry[2] == -2: # other parent
   333                 size = -2
   338                 size = -2
   334         self._map[f] = ('r', 0, size, 0)
   339         self._map[f] = ('r', 0, size, 0)
   335         if size == 0 and f in self._copymap:
   340         if size == 0 and f in self._copymap:
   336             del self._copymap[f]
   341             del self._copymap[f]
   337 
   342 
   636                 dadd(fn)
   641                 dadd(fn)
   637             elif state == 'n':
   642             elif state == 'n':
   638                 if (size >= 0 and
   643                 if (size >= 0 and
   639                     (size != st.st_size
   644                     (size != st.st_size
   640                      or ((mode ^ st.st_mode) & 0100 and self._checkexec))
   645                      or ((mode ^ st.st_mode) & 0100 and self._checkexec))
   641                     or size == -2
   646                     or size == -2 # other parent
   642                     or fn in self._copymap):
   647                     or fn in self._copymap):
   643                     madd(fn)
   648                     madd(fn)
   644                 elif time != int(st.st_mtime):
   649                 elif time != int(st.st_mtime):
   645                     ladd(fn)
   650                     ladd(fn)
   646                 elif listclean:
   651                 elif listclean: