Show More
@@ -201,30 +201,55 b' def clone(ui, source, dest=None, pull=Fa' | |||||
201 | dest_lock.release() |
|
201 | dest_lock.release() | |
202 |
|
202 | |||
203 | if update: |
|
203 | if update: | |
204 |
_ |
|
204 | _update(dest_repo, dest_repo.changelog.tip()) | |
205 | if dir_cleanup: |
|
205 | if dir_cleanup: | |
206 | dir_cleanup.close() |
|
206 | dir_cleanup.close() | |
207 |
|
207 | |||
208 | return src_repo, dest_repo |
|
208 | return src_repo, dest_repo | |
209 |
|
209 | |||
|
210 | def _showstats(repo, stats): | |||
|
211 | stats = ((stats[0], _("updated")), | |||
|
212 | (stats[1], _("merged")), | |||
|
213 | (stats[2], _("removed")), | |||
|
214 | (stats[3], _("unresolved"))) | |||
|
215 | note = ", ".join([_("%d files %s") % s for s in stats]) | |||
|
216 | repo.ui.status("%s\n" % note) | |||
|
217 | ||||
|
218 | def _update(repo, node): return update(repo, node) | |||
|
219 | ||||
210 | def update(repo, node): |
|
220 | def update(repo, node): | |
211 | """update the working directory to node, merging linear changes""" |
|
221 | """update the working directory to node, merging linear changes""" | |
212 |
|
|
222 | stats = _merge.update(repo, node, False, False, None, None) | |
|
223 | _showstats(repo, stats) | |||
|
224 | if stats[3]: | |||
|
225 | repo.ui.status(_("There are unresolved merges with" | |||
|
226 | " locally modified files.\n")) | |||
|
227 | return stats[3] | |||
213 |
|
228 | |||
214 | def clean(repo, node, wlock=None, show_stats=True): |
|
229 | def clean(repo, node, wlock=None, show_stats=True): | |
215 | """forcibly switch the working directory to node, clobbering changes""" |
|
230 | """forcibly switch the working directory to node, clobbering changes""" | |
216 |
|
|
231 | stats = _merge.update(repo, node, False, True, None, wlock) | |
217 | show_stats=show_stats) |
|
232 | if show_stats: _showstats(repo, stats) | |
|
233 | return stats[3] | |||
218 |
|
234 | |||
219 | def merge(repo, node, force=None, remind=True, wlock=None): |
|
235 | def merge(repo, node, force=None, remind=True, wlock=None): | |
220 | """branch merge with node, resolving changes""" |
|
236 | """branch merge with node, resolving changes""" | |
221 |
|
|
237 | stats = _merge.update(repo, node, True, force, False, wlock) | |
222 | remind=remind, wlock=wlock) |
|
238 | _showstats(repo, stats) | |
|
239 | if stats[3]: | |||
|
240 | pl = repo.parents() | |||
|
241 | repo.ui.status(_("There are unresolved merges," | |||
|
242 | " you can redo the full merge using:\n" | |||
|
243 | " hg update -C %s\n" | |||
|
244 | " hg merge %s\n" | |||
|
245 | % (pl[0].rev(), pl[1].rev()))) | |||
|
246 | elif remind: | |||
|
247 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) | |||
|
248 | return stats[3] | |||
223 |
|
249 | |||
224 | def revert(repo, node, choose, wlock): |
|
250 | def revert(repo, node, choose, wlock): | |
225 | """revert changes to revision in node without updating dirstate""" |
|
251 | """revert changes to revision in node without updating dirstate""" | |
226 |
return _merge.update(repo, node, |
|
252 | return _merge.update(repo, node, False, True, choose, wlock)[3] | |
227 | show_stats=False, wlock=wlock) |
|
|||
228 |
|
253 | |||
229 | def verify(repo): |
|
254 | def verify(repo): | |
230 | """verify the consistency of a repository""" |
|
255 | """verify the consistency of a repository""" |
@@ -291,15 +291,14 b' def applyupdates(repo, action, wctx, mct' | |||||
291 | if filemerge(repo, f, f2, wctx, mctx): |
|
291 | if filemerge(repo, f, f2, wctx, mctx): | |
292 | unresolved += 1 |
|
292 | unresolved += 1 | |
293 | else: |
|
293 | else: | |
|
294 | merged += 1 | |||
294 | if f != fd: |
|
295 | if f != fd: | |
295 | repo.ui.debug(_("copying %s to %s\n") % (f, fd)) |
|
296 | repo.ui.debug(_("copying %s to %s\n") % (f, fd)) | |
296 | repo.wwrite(fd, repo.wread(f)) |
|
297 | repo.wwrite(fd, repo.wread(f)) | |
297 | if move: |
|
298 | if move: | |
298 | repo.ui.debug(_("removing %s\n") % f) |
|
299 | repo.ui.debug(_("removing %s\n") % f) | |
299 | os.unlink(repo.wjoin(f)) |
|
300 | os.unlink(repo.wjoin(f)) | |
300 |
|
||||
301 | util.set_exec(repo.wjoin(fd), flag) |
|
301 | util.set_exec(repo.wjoin(fd), flag) | |
302 | merged += 1 |
|
|||
303 | elif m == "g": # get |
|
302 | elif m == "g": # get | |
304 | flag = a[2] |
|
303 | flag = a[2] | |
305 | repo.ui.note(_("getting %s\n") % f) |
|
304 | repo.ui.note(_("getting %s\n") % f) | |
@@ -352,8 +351,7 b' def recordupdates(repo, action, branchme' | |||||
352 | else: |
|
351 | else: | |
353 | repo.dirstate.copy(f2, fd) |
|
352 | repo.dirstate.copy(f2, fd) | |
354 |
|
353 | |||
355 |
def update(repo, node, branchmerge |
|
354 | def update(repo, node, branchmerge, force, partial, wlock): | |
356 | wlock=None, show_stats=True, remind=True): |
|
|||
357 | """ |
|
355 | """ | |
358 | Perform a merge between the working directory and the given node |
|
356 | Perform a merge between the working directory and the given node | |
359 |
|
357 | |||
@@ -361,8 +359,6 b' def update(repo, node, branchmerge=False' | |||||
361 | force = whether to force branch merging or file overwriting |
|
359 | force = whether to force branch merging or file overwriting | |
362 | partial = a function to filter file lists (dirstate not updated) |
|
360 | partial = a function to filter file lists (dirstate not updated) | |
363 | wlock = working dir lock, if already held |
|
361 | wlock = working dir lock, if already held | |
364 | show_stats = whether to report merge statistics |
|
|||
365 | remind = whether to remind about merge |
|
|||
366 | """ |
|
362 | """ | |
367 |
|
363 | |||
368 | if not wlock: |
|
364 | if not wlock: | |
@@ -404,32 +400,12 b' def update(repo, node, branchmerge=False' | |||||
404 | if not partial: |
|
400 | if not partial: | |
405 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) |
|
401 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) | |
406 |
|
402 | |||
407 |
|
|
403 | stats = applyupdates(repo, action, wc, p2) | |
408 |
|
404 | |||
409 | if show_stats: |
|
|||
410 | stats = ((updated, _("updated")), |
|
|||
411 | (merged - unresolved, _("merged")), |
|
|||
412 | (removed, _("removed")), |
|
|||
413 | (unresolved, _("unresolved"))) |
|
|||
414 | note = ", ".join([_("%d files %s") % s for s in stats]) |
|
|||
415 | repo.ui.status("%s\n" % note) |
|
|||
416 | if not partial: |
|
405 | if not partial: | |
417 | recordupdates(repo, action, branchmerge, p2) |
|
406 | recordupdates(repo, action, branchmerge, p2) | |
418 | repo.dirstate.setparents(fp1, fp2) |
|
407 | repo.dirstate.setparents(fp1, fp2) | |
419 |
repo.hook('update', parent1=xp1, parent2=xp2, error= |
|
408 | repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) | |
420 |
|
409 | |||
421 | if branchmerge: |
|
410 | return stats | |
422 | if unresolved: |
|
|||
423 | repo.ui.status(_("There are unresolved merges," |
|
|||
424 | " you can redo the full merge using:\n" |
|
|||
425 | " hg update -C %s\n" |
|
|||
426 | " hg merge %s\n" |
|
|||
427 | % (p1.rev(), p2.rev()))) |
|
|||
428 | elif remind: |
|
|||
429 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
|||
430 | elif unresolved: |
|
|||
431 | repo.ui.status(_("There are unresolved merges with" |
|
|||
432 | " locally modified files.\n")) |
|
|||
433 |
|
411 | |||
434 | return unresolved |
|
|||
435 |
|
General Comments 0
You need to be logged in to leave comments.
Login now