Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 18540:139529b0a191
merge: make all action tuples have the same length - keep args as tuple
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 24 Jan 2013 23:57:44 +0100 |
parents | cf25e4efd685 |
children | 5ed6a375e9ca |
comparison
equal
deleted
inserted
replaced
18539:cf25e4efd685 | 18540:139529b0a191 |
---|---|
174 | 174 |
175 actions = [] | 175 actions = [] |
176 state = branchmerge and 'r' or 'f' | 176 state = branchmerge and 'r' or 'f' |
177 for f in wctx.deleted(): | 177 for f in wctx.deleted(): |
178 if f not in mctx: | 178 if f not in mctx: |
179 actions.append((f, state)) | 179 actions.append((f, state, None)) |
180 | 180 |
181 if not branchmerge: | 181 if not branchmerge: |
182 for f in wctx.removed(): | 182 for f in wctx.removed(): |
183 if f not in mctx: | 183 if f not in mctx: |
184 actions.append((f, "f")) | 184 actions.append((f, "f", None)) |
185 | 185 |
186 return actions | 186 return actions |
187 | 187 |
188 def manifestmerge(repo, p1, p2, pa, overwrite, partial): | 188 def manifestmerge(repo, p1, p2, pa, overwrite, partial): |
189 """ | 189 """ |
193 partial = function to filter file lists | 193 partial = function to filter file lists |
194 """ | 194 """ |
195 | 195 |
196 def act(msg, m, f, *args): | 196 def act(msg, m, f, *args): |
197 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) | 197 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) |
198 actions.append((f, m) + args) | 198 actions.append((f, m, args)) |
199 | 199 |
200 actions, copy, movewithdir = [], {}, {} | 200 actions, copy, movewithdir = [], {}, {} |
201 | 201 |
202 if overwrite: | 202 if overwrite: |
203 pa = p1 | 203 pa = p1 |
340 moves = [] | 340 moves = [] |
341 actions.sort(key=actionkey) | 341 actions.sort(key=actionkey) |
342 | 342 |
343 # prescan for merges | 343 # prescan for merges |
344 for a in actions: | 344 for a in actions: |
345 f, m = a[:2] | 345 f, m, args = a |
346 if m == "m": # merge | 346 if m == "m": # merge |
347 f2, fd, move = a[2:] | 347 f2, fd, move = args |
348 if fd == '.hgsubstate': # merged internally | 348 if fd == '.hgsubstate': # merged internally |
349 continue | 349 continue |
350 repo.ui.debug("preserving %s for resolve of %s\n" % (f, fd)) | 350 repo.ui.debug("preserving %s for resolve of %s\n" % (f, fd)) |
351 fcl = wctx[f] | 351 fcl = wctx[f] |
352 fco = mctx[f2] | 352 fco = mctx[f2] |
372 audit(f) | 372 audit(f) |
373 util.unlinkpath(repo.wjoin(f)) | 373 util.unlinkpath(repo.wjoin(f)) |
374 | 374 |
375 numupdates = len(actions) | 375 numupdates = len(actions) |
376 for i, a in enumerate(actions): | 376 for i, a in enumerate(actions): |
377 f, m = a[:2] | 377 f, m, args = a |
378 repo.ui.progress(_('updating'), i + 1, item=f, total=numupdates, | 378 repo.ui.progress(_('updating'), i + 1, item=f, total=numupdates, |
379 unit=_('files')) | 379 unit=_('files')) |
380 if m == "r": # remove | 380 if m == "r": # remove |
381 repo.ui.note(_("removing %s\n") % f) | 381 repo.ui.note(_("removing %s\n") % f) |
382 audit(f) | 382 audit(f) |
391 elif m == "m": # merge | 391 elif m == "m": # merge |
392 if fd == '.hgsubstate': # subrepo states need updating | 392 if fd == '.hgsubstate': # subrepo states need updating |
393 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), | 393 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
394 overwrite) | 394 overwrite) |
395 continue | 395 continue |
396 f2, fd, move = a[2:] | 396 f2, fd, move = args |
397 audit(fd) | 397 audit(fd) |
398 r = ms.resolve(fd, wctx, mctx) | 398 r = ms.resolve(fd, wctx, mctx) |
399 if r is not None and r > 0: | 399 if r is not None and r > 0: |
400 unresolved += 1 | 400 unresolved += 1 |
401 else: | 401 else: |
402 if r is None: | 402 if r is None: |
403 updated += 1 | 403 updated += 1 |
404 else: | 404 else: |
405 merged += 1 | 405 merged += 1 |
406 elif m == "g": # get | 406 elif m == "g": # get |
407 flags = a[2] | 407 flags, = args |
408 repo.ui.note(_("getting %s\n") % f) | 408 repo.ui.note(_("getting %s\n") % f) |
409 repo.wwrite(f, mctx.filectx(f).data(), flags) | 409 repo.wwrite(f, mctx.filectx(f).data(), flags) |
410 updated += 1 | 410 updated += 1 |
411 if f == '.hgsubstate': # subrepo states need updating | 411 if f == '.hgsubstate': # subrepo states need updating |
412 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | 412 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
413 elif m == "d": # directory rename | 413 elif m == "d": # directory rename |
414 f2, fd, flags = a[2:] | 414 f2, fd, flags = args |
415 if f: | 415 if f: |
416 repo.ui.note(_("moving %s to %s\n") % (f, fd)) | 416 repo.ui.note(_("moving %s to %s\n") % (f, fd)) |
417 audit(f) | 417 audit(f) |
418 repo.wwrite(fd, wctx.filectx(f).data(), flags) | 418 repo.wwrite(fd, wctx.filectx(f).data(), flags) |
419 util.unlinkpath(repo.wjoin(f)) | 419 util.unlinkpath(repo.wjoin(f)) |
420 if f2: | 420 if f2: |
421 repo.ui.note(_("getting %s to %s\n") % (f2, fd)) | 421 repo.ui.note(_("getting %s to %s\n") % (f2, fd)) |
422 repo.wwrite(fd, mctx.filectx(f2).data(), flags) | 422 repo.wwrite(fd, mctx.filectx(f2).data(), flags) |
423 updated += 1 | 423 updated += 1 |
424 elif m == "dr": # divergent renames | 424 elif m == "dr": # divergent renames |
425 fl = a[2] | 425 fl, = args |
426 repo.ui.warn(_("note: possible conflict - %s was renamed " | 426 repo.ui.warn(_("note: possible conflict - %s was renamed " |
427 "multiple times to:\n") % f) | 427 "multiple times to:\n") % f) |
428 for nf in fl: | 428 for nf in fl: |
429 repo.ui.warn(" %s\n" % nf) | 429 repo.ui.warn(" %s\n" % nf) |
430 elif m == "rd": # rename and delete | 430 elif m == "rd": # rename and delete |
431 fl = a[2] | 431 fl, = args |
432 repo.ui.warn(_("note: possible conflict - %s was deleted " | 432 repo.ui.warn(_("note: possible conflict - %s was deleted " |
433 "and renamed to:\n") % f) | 433 "and renamed to:\n") % f) |
434 for nf in fl: | 434 for nf in fl: |
435 repo.ui.warn(" %s\n" % nf) | 435 repo.ui.warn(" %s\n" % nf) |
436 elif m == "e": # exec | 436 elif m == "e": # exec |
437 flags = a[2] | 437 flags, = args |
438 audit(f) | 438 audit(f) |
439 util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) | 439 util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) |
440 updated += 1 | 440 updated += 1 |
441 ms.commit() | 441 ms.commit() |
442 repo.ui.progress(_('updating'), None, total=numupdates, unit=_('files')) | 442 repo.ui.progress(_('updating'), None, total=numupdates, unit=_('files')) |
466 | 466 |
467 def recordupdates(repo, actions, branchmerge): | 467 def recordupdates(repo, actions, branchmerge): |
468 "record merge actions to the dirstate" | 468 "record merge actions to the dirstate" |
469 | 469 |
470 for a in actions: | 470 for a in actions: |
471 f, m = a[:2] | 471 f, m, args = a |
472 if m == "r": # remove | 472 if m == "r": # remove |
473 if branchmerge: | 473 if branchmerge: |
474 repo.dirstate.remove(f) | 474 repo.dirstate.remove(f) |
475 else: | 475 else: |
476 repo.dirstate.drop(f) | 476 repo.dirstate.drop(f) |
485 if branchmerge: | 485 if branchmerge: |
486 repo.dirstate.otherparent(f) | 486 repo.dirstate.otherparent(f) |
487 else: | 487 else: |
488 repo.dirstate.normal(f) | 488 repo.dirstate.normal(f) |
489 elif m == "m": # merge | 489 elif m == "m": # merge |
490 f2, fd, move = a[2:] | 490 f2, fd, move = args |
491 if branchmerge: | 491 if branchmerge: |
492 # We've done a branch merge, mark this file as merged | 492 # We've done a branch merge, mark this file as merged |
493 # so that we properly record the merger later | 493 # so that we properly record the merger later |
494 repo.dirstate.merge(fd) | 494 repo.dirstate.merge(fd) |
495 if f != f2: # copy/rename | 495 if f != f2: # copy/rename |
508 if f2 == fd: # file not locally copied/moved | 508 if f2 == fd: # file not locally copied/moved |
509 repo.dirstate.normallookup(fd) | 509 repo.dirstate.normallookup(fd) |
510 if move: | 510 if move: |
511 repo.dirstate.drop(f) | 511 repo.dirstate.drop(f) |
512 elif m == "d": # directory rename | 512 elif m == "d": # directory rename |
513 f2, fd, flag = a[2:] | 513 f2, fd, flag = args |
514 if not f2 and f not in repo.dirstate: | 514 if not f2 and f not in repo.dirstate: |
515 # untracked file moved | 515 # untracked file moved |
516 continue | 516 continue |
517 if branchmerge: | 517 if branchmerge: |
518 repo.dirstate.add(fd) | 518 repo.dirstate.add(fd) |