comparison mercurial/merge.py @ 3316:39fd6e82ea38

merge: pull user messages out to hg.py - add _update for shadowing in clone - add _showstats helper - remove update parameter defaults - move stats message and merge help messages
author Matt Mackall <mpm@selenic.com>
date Tue, 10 Oct 2006 03:39:44 -0500
parents 38be819a1225
children 8c36b33a27c7
comparison
equal deleted inserted replaced
3315:38be819a1225 3316:39fd6e82ea38
289 elif m == "m": # merge 289 elif m == "m": # merge
290 f2, fd, flag, move = a[2:] 290 f2, fd, flag, move = a[2:]
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)
306 t = mctx.filectx(f).data() 305 t = mctx.filectx(f).data()
307 repo.wwrite(f, t) 306 repo.wwrite(f, t)
350 if f != fd: 349 if f != fd:
351 repo.dirstate.copy(f, fd) 350 repo.dirstate.copy(f, fd)
352 else: 351 else:
353 repo.dirstate.copy(f2, fd) 352 repo.dirstate.copy(f2, fd)
354 353
355 def update(repo, node, branchmerge=False, force=False, partial=None, 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
360 branchmerge = whether to merge between branches 358 branchmerge = whether to merge between branches
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:
369 wlock = repo.wlock() 365 wlock = repo.wlock()
370 366
402 if not branchmerge: # just jump to the new rev 398 if not branchmerge: # just jump to the new rev
403 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, '' 399 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, ''
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 updated, merged, removed, unresolved = applyupdates(repo, action, wc, p2) 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=unresolved) 408 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
420 409
421 if branchmerge: 410 return stats
422 if unresolved: 411
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
434 return unresolved
435