Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 18632:3e20079117c5
merge: handle subrepo merges and .hgsubstate specially
In an upcoming patch, we will update .hgsubstate in a non-interactive
worker process. Merges of subrepo contents will still need to occur in the
master process (since they may be interactive), so we move that code into
a place where it will always run in what will become the master process.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Sat, 09 Feb 2013 15:22:08 -0800 |
parents | 9b9e2d9e83a1 |
children | 6390dd22b12f |
comparison
equal
deleted
inserted
replaced
18631:e2dc5397bc82 | 18632:3e20079117c5 |
---|---|
340 return actions | 340 return actions |
341 | 341 |
342 def actionkey(a): | 342 def actionkey(a): |
343 return a[1] == "r" and -1 or 0, a | 343 return a[1] == "r" and -1 or 0, a |
344 | 344 |
345 def getremove(repo, wctx, mctx, overwrite, args): | 345 def getremove(repo, mctx, overwrite, args): |
346 """apply usually-non-interactive updates to the working directory | 346 """apply usually-non-interactive updates to the working directory |
347 | 347 |
348 wctx is the working copy context | |
349 mctx is the context to be merged into the working copy | 348 mctx is the context to be merged into the working copy |
350 | 349 |
351 yields tuples for progress updates | 350 yields tuples for progress updates |
352 """ | 351 """ |
353 audit = repo.wopener.audit | 352 audit = repo.wopener.audit |
354 for i, arg in enumerate(args): | 353 for i, arg in enumerate(args): |
355 f = arg[0] | 354 f = arg[0] |
356 if arg[1] == 'r': | 355 if arg[1] == 'r': |
357 repo.ui.note(_("removing %s\n") % f) | 356 repo.ui.note(_("removing %s\n") % f) |
358 if f == '.hgsubstate': # subrepo states need updating | |
359 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | |
360 audit(f) | 357 audit(f) |
361 try: | 358 try: |
362 util.unlinkpath(repo.wjoin(f), ignoremissing=True) | 359 util.unlinkpath(repo.wjoin(f), ignoremissing=True) |
363 except OSError, inst: | 360 except OSError, inst: |
364 repo.ui.warn(_("update failed to remove %s: %s!\n") % | 361 repo.ui.warn(_("update failed to remove %s: %s!\n") % |
365 (f, inst.strerror)) | 362 (f, inst.strerror)) |
366 else: | 363 else: |
367 repo.ui.note(_("getting %s\n") % f) | 364 repo.ui.note(_("getting %s\n") % f) |
368 repo.wwrite(f, mctx.filectx(f).data(), arg[2][0]) | 365 repo.wwrite(f, mctx.filectx(f).data(), arg[2][0]) |
369 if f == '.hgsubstate': # subrepo states need updating | |
370 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | |
371 yield i, f | 366 yield i, f |
372 | 367 |
373 def applyupdates(repo, actions, wctx, mctx, actx, overwrite): | 368 def applyupdates(repo, actions, wctx, mctx, actx, overwrite): |
374 """apply the merge action list to the working directory | 369 """apply the merge action list to the working directory |
375 | 370 |
424 workeractions = [a for a in actions if a[1] in 'gr'] | 419 workeractions = [a for a in actions if a[1] in 'gr'] |
425 updated = len([a for a in workeractions if a[1] == 'g']) | 420 updated = len([a for a in workeractions if a[1] == 'g']) |
426 removed = len([a for a in workeractions if a[1] == 'r']) | 421 removed = len([a for a in workeractions if a[1] == 'r']) |
427 actions = [a for a in actions if a[1] not in 'gr'] | 422 actions = [a for a in actions if a[1] not in 'gr'] |
428 | 423 |
429 for i, item in getremove(repo, wctx, mctx, overwrite, workeractions): | 424 hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] |
425 if hgsub and hgsub[0] == 'r': | |
426 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | |
427 | |
428 for i, item in getremove(repo, mctx, overwrite, workeractions): | |
430 repo.ui.progress(_('updating'), i + 1, item=item, total=numupdates, | 429 repo.ui.progress(_('updating'), i + 1, item=item, total=numupdates, |
431 unit=_('files')) | 430 unit=_('files')) |
431 | |
432 if hgsub and hgsub[0] == 'g': | |
433 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | |
432 | 434 |
433 z = len(workeractions) | 435 z = len(workeractions) |
434 | 436 |
435 for i, a in enumerate(actions): | 437 for i, a in enumerate(actions): |
436 f, m, args, msg = a | 438 f, m, args, msg = a |