##// END OF EJS Templates
Fix dir-changed-to-file updates on clean workdir....
Maxim Dounin -
r5516:f252ba97 default
parent child Browse files
Show More
@@ -185,16 +185,15 b' class dirstate(object):'
185 dirs[base] += 1
185 dirs[base] += 1
186
186
187 def _decpath(self, path):
187 def _decpath(self, path):
188 if "_dirs" in self.__dict__:
188 c = path.rfind('/')
189 c = path.rfind('/')
189 if c >= 0:
190 if c >= 0:
190 base = path[:c]
191 base = path[:c]
191 dirs = self._dirs
192 dirs = self._dirs
192 if dirs[base] == 1:
193 if dirs[base] == 1:
193 del dirs[base]
194 del dirs[base]
194 self._decpath(base)
195 self._decpath(base)
195 else:
196 else:
196 dirs[base] -= 1
197 dirs[base] -= 1
198
197
199 def _incpathcheck(self, f):
198 def _incpathcheck(self, f):
200 if '\r' in f or '\n' in f:
199 if '\r' in f or '\n' in f:
@@ -211,20 +210,29 b' class dirstate(object):'
211 (d, f))
210 (d, f))
212 self._incpath(f)
211 self._incpath(f)
213
212
214 def _changepath(self, f, newstate):
213 def _changepath(self, f, newstate, relaxed=False):
215 # handle upcoming path changes
214 # handle upcoming path changes
216 oldstate = self[f]
215 oldstate = self[f]
217 if oldstate not in "?r" and newstate in "?r":
216 if oldstate not in "?r" and newstate in "?r":
218 self._decpath(f)
217 if "_dirs" in self.__dict__:
218 self._decpath(f)
219 return
219 return
220 if oldstate in "?r" and newstate not in "?r":
220 if oldstate in "?r" and newstate not in "?r":
221 if relaxed and oldstate == '?':
222 # XXX
223 # in relaxed mode we assume the caller knows
224 # what it is doing, workaround for updating
225 # dir-to-file revisions
226 if "_dirs" in self.__dict__:
227 self._incpath(f)
228 return
221 self._incpathcheck(f)
229 self._incpathcheck(f)
222 return
230 return
223
231
224 def normal(self, f):
232 def normal(self, f):
225 'mark a file normal and clean'
233 'mark a file normal and clean'
226 self._dirty = True
234 self._dirty = True
227 self._changepath(f, 'n')
235 self._changepath(f, 'n', True)
228 s = os.lstat(self._join(f))
236 s = os.lstat(self._join(f))
229 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0)
237 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0)
230 if self._copymap.has_key(f):
238 if self._copymap.has_key(f):
@@ -233,7 +241,7 b' class dirstate(object):'
233 def normallookup(self, f):
241 def normallookup(self, f):
234 'mark a file normal, but possibly dirty'
242 'mark a file normal, but possibly dirty'
235 self._dirty = True
243 self._dirty = True
236 self._changepath(f, 'n')
244 self._changepath(f, 'n', True)
237 self._map[f] = ('n', 0, -1, -1, 0)
245 self._map[f] = ('n', 0, -1, -1, 0)
238 if f in self._copymap:
246 if f in self._copymap:
239 del self._copymap[f]
247 del self._copymap[f]
@@ -241,7 +249,7 b' class dirstate(object):'
241 def normaldirty(self, f):
249 def normaldirty(self, f):
242 'mark a file normal, but dirty'
250 'mark a file normal, but dirty'
243 self._dirty = True
251 self._dirty = True
244 self._changepath(f, 'n')
252 self._changepath(f, 'n', True)
245 self._map[f] = ('n', 0, -2, -1, 0)
253 self._map[f] = ('n', 0, -2, -1, 0)
246 if f in self._copymap:
254 if f in self._copymap:
247 del self._copymap[f]
255 del self._copymap[f]
@@ -266,7 +274,7 b' class dirstate(object):'
266 'mark a file merged'
274 'mark a file merged'
267 self._dirty = True
275 self._dirty = True
268 s = os.lstat(self._join(f))
276 s = os.lstat(self._join(f))
269 self._changepath(f, 'm')
277 self._changepath(f, 'm', True)
270 self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime, 0)
278 self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime, 0)
271 if f in self._copymap:
279 if f in self._copymap:
272 del self._copymap[f]
280 del self._copymap[f]
@@ -80,10 +80,15 b' hg rm --after d/d/d'
80
80
81 echo % should succeed - shadow removed
81 echo % should succeed - shadow removed
82 hg add d
82 hg add d
83 hg ci -md
83
84
84 #echo % update should work
85 echo % update should work at least with clean workdir
85 #
86
86 #hg up -r 0
87 rm -r a b d
87 #hg up -r 1
88 hg up -r 0
89 hg st --all
90 rm -r a b
91 hg up -r 1
92 hg st --all
88
93
89 exit 0
94 exit 0
@@ -40,3 +40,10 b' adding d/d/d'
40 abort: directory 'd' already in dirstate
40 abort: directory 'd' already in dirstate
41 % removing shadow
41 % removing shadow
42 % should succeed - shadow removed
42 % should succeed - shadow removed
43 % update should work at least with clean workdir
44 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
45 C a
46 C b/b
47 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 C a/a
49 C b
General Comments 0
You need to be logged in to leave comments. Login now