Show More
@@ -199,6 +199,74 b' def manifestmerge(ui, m1, m2, ma, overwr' | |||||
199 |
|
199 | |||
200 | return action |
|
200 | return action | |
201 |
|
201 | |||
|
202 | def applyupdates(repo, action, xp1, xp2): | |||
|
203 | updated, merged, removed, unresolved = 0, 0, 0, 0 | |||
|
204 | action.sort() | |||
|
205 | for a in action: | |||
|
206 | f, m = a[:2] | |||
|
207 | if f[0] == "/": | |||
|
208 | continue | |||
|
209 | if m == "r": # remove | |||
|
210 | repo.ui.note(_("removing %s\n") % f) | |||
|
211 | util.audit_path(f) | |||
|
212 | try: | |||
|
213 | util.unlink(repo.wjoin(f)) | |||
|
214 | except OSError, inst: | |||
|
215 | if inst.errno != errno.ENOENT: | |||
|
216 | repo.ui.warn(_("update failed to remove %s: %s!\n") % | |||
|
217 | (f, inst.strerror)) | |||
|
218 | removed +=1 | |||
|
219 | elif m == "m": # merge | |||
|
220 | flag, my, other = a[2:] | |||
|
221 | repo.ui.status(_("merging %s\n") % f) | |||
|
222 | if merge3(repo, f, my, other, xp1, xp2): | |||
|
223 | unresolved += 1 | |||
|
224 | util.set_exec(repo.wjoin(f), flag) | |||
|
225 | merged += 1 | |||
|
226 | elif m == "g": # get | |||
|
227 | flag, node = a[2:] | |||
|
228 | repo.ui.note(_("getting %s\n") % f) | |||
|
229 | t = repo.file(f).read(node) | |||
|
230 | repo.wwrite(f, t) | |||
|
231 | util.set_exec(repo.wjoin(f), flag) | |||
|
232 | updated += 1 | |||
|
233 | elif m == "e": # exec | |||
|
234 | flag = a[2:] | |||
|
235 | util.set_exec(repo.wjoin(f), flag) | |||
|
236 | ||||
|
237 | return updated, merged, removed, unresolved | |||
|
238 | ||||
|
239 | def recordupdates(repo, action, branchmerge): | |||
|
240 | for a in action: | |||
|
241 | f, m = a[:2] | |||
|
242 | if m == "r": # remove | |||
|
243 | if branchmerge: | |||
|
244 | repo.dirstate.update([f], 'r') | |||
|
245 | else: | |||
|
246 | repo.dirstate.forget([f]) | |||
|
247 | elif m == "f": # forget | |||
|
248 | repo.dirstate.forget([f]) | |||
|
249 | elif m == "g": # get | |||
|
250 | if branchmerge: | |||
|
251 | repo.dirstate.update([f], 'n', st_mtime=-1) | |||
|
252 | else: | |||
|
253 | repo.dirstate.update([f], 'n') | |||
|
254 | elif m == "m": # merge | |||
|
255 | flag, my, other = a[2:] | |||
|
256 | if branchmerge: | |||
|
257 | # We've done a branch merge, mark this file as merged | |||
|
258 | # so that we properly record the merger later | |||
|
259 | repo.dirstate.update([f], 'm') | |||
|
260 | else: | |||
|
261 | # We've update-merged a locally modified file, so | |||
|
262 | # we set the dirstate to emulate a normal checkout | |||
|
263 | # of that file some time in the past. Thus our | |||
|
264 | # merge will appear as a normal local file | |||
|
265 | # modification. | |||
|
266 | fl = repo.file(f) | |||
|
267 | f_len = fl.size(fl.rev(other)) | |||
|
268 | repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1) | |||
|
269 | ||||
202 | def update(repo, node, branchmerge=False, force=False, partial=None, |
|
270 | def update(repo, node, branchmerge=False, force=False, partial=None, | |
203 | wlock=None, show_stats=True, remind=True): |
|
271 | wlock=None, show_stats=True, remind=True): | |
204 |
|
272 | |||
@@ -268,73 +336,12 b' def update(repo, node, branchmerge=False' | |||||
268 |
|
336 | |||
269 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) |
|
337 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) | |
270 |
|
338 | |||
271 | # update files |
|
339 | updated, merged, removed, unresolved = applyupdates(repo, action, xp1, xp2) | |
272 | updated, merged, removed, unresolved = 0, 0, 0, 0 |
|
|||
273 | action.sort() |
|
|||
274 | for a in action: |
|
|||
275 | f, m = a[:2] |
|
|||
276 | if f[0] == "/": |
|
|||
277 | continue |
|
|||
278 | if m == "r": # remove |
|
|||
279 | repo.ui.note(_("removing %s\n") % f) |
|
|||
280 | util.audit_path(f) |
|
|||
281 | try: |
|
|||
282 | util.unlink(repo.wjoin(f)) |
|
|||
283 | except OSError, inst: |
|
|||
284 | if inst.errno != errno.ENOENT: |
|
|||
285 | repo.ui.warn(_("update failed to remove %s: %s!\n") % |
|
|||
286 | (f, inst.strerror)) |
|
|||
287 | removed +=1 |
|
|||
288 | elif m == "m": # merge |
|
|||
289 | flag, my, other = a[2:] |
|
|||
290 | repo.ui.status(_("merging %s\n") % f) |
|
|||
291 | if merge3(repo, f, my, other, xp1, xp2): |
|
|||
292 | unresolved += 1 |
|
|||
293 | util.set_exec(repo.wjoin(f), flag) |
|
|||
294 | merged += 1 |
|
|||
295 | elif m == "g": # get |
|
|||
296 | flag, node = a[2:] |
|
|||
297 | repo.ui.note(_("getting %s\n") % f) |
|
|||
298 | t = repo.file(f).read(node) |
|
|||
299 | repo.wwrite(f, t) |
|
|||
300 | util.set_exec(repo.wjoin(f), flag) |
|
|||
301 | updated += 1 |
|
|||
302 | elif m == "e": # exec |
|
|||
303 | flag = a[2:] |
|
|||
304 | util.set_exec(repo.wjoin(f), flag) |
|
|||
305 |
|
340 | |||
306 | # update dirstate |
|
341 | # update dirstate | |
307 | if not partial: |
|
342 | if not partial: | |
308 | repo.dirstate.setparents(p1, p2) |
|
343 | repo.dirstate.setparents(p1, p2) | |
309 | for a in action: |
|
344 | recordupdates(repo, action, branchmerge) | |
310 | f, m = a[:2] |
|
|||
311 | if m == "r": # remove |
|
|||
312 | if branchmerge: |
|
|||
313 | repo.dirstate.update([f], 'r') |
|
|||
314 | else: |
|
|||
315 | repo.dirstate.forget([f]) |
|
|||
316 | elif m == "f": # forget |
|
|||
317 | repo.dirstate.forget([f]) |
|
|||
318 | elif m == "g": # get |
|
|||
319 | if branchmerge: |
|
|||
320 | repo.dirstate.update([f], 'n', st_mtime=-1) |
|
|||
321 | else: |
|
|||
322 | repo.dirstate.update([f], 'n') |
|
|||
323 | elif m == "m": # merge |
|
|||
324 | flag, my, other = a[2:] |
|
|||
325 | if branchmerge: |
|
|||
326 | # We've done a branch merge, mark this file as merged |
|
|||
327 | # so that we properly record the merger later |
|
|||
328 | repo.dirstate.update([f], 'm') |
|
|||
329 | else: |
|
|||
330 | # We've update-merged a locally modified file, so |
|
|||
331 | # we set the dirstate to emulate a normal checkout |
|
|||
332 | # of that file some time in the past. Thus our |
|
|||
333 | # merge will appear as a normal local file |
|
|||
334 | # modification. |
|
|||
335 | fl = repo.file(f) |
|
|||
336 | f_len = fl.size(fl.rev(other)) |
|
|||
337 | repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1) |
|
|||
338 |
|
345 | |||
339 | if show_stats: |
|
346 | if show_stats: | |
340 | stats = ((updated, _("updated")), |
|
347 | stats = ((updated, _("updated")), |
General Comments 0
You need to be logged in to leave comments.
Login now