Mercurial > hg
changeset 23541:495bc1b65d25
merge: move cd/dc prompts after largefiles prompts
By moving the cd/dc prompts out of calculateupdates(), we let
largefiles' overridecalculateupdates() so the unresolved values
(i.e. 'cd' or 'dc' rather than 'g', 'r', 'a' and missing). This allows
overridecalculateupdates() to ask the user whether to keep the normal
file or the largefile before the user gets the cd/dc prompt. Whichever
answer the user gives, we make overridecalculateupdates() replace 'cd'
or 'dc' action, saving the user one annoying (and less clear)
question.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 Dec 2014 21:21:21 -0800 |
parents | f274d27f1994 |
children | 8b5adc6b72ae |
files | hgext/largefiles/overrides.py mercurial/merge.py tests/test-issue3084.t tests/test-largefiles-update.t |
diffstat | 4 files changed, 36 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Sun Nov 30 22:47:53 2014 -0500 +++ b/hgext/largefiles/overrides.py Thu Dec 11 21:21:21 2014 -0800 @@ -440,9 +440,9 @@ for lfile in lfiles: standin = lfutil.standin(lfile) - lm = actionbyfile.get(lfile, (None, None, None))[0] - sm = actionbyfile.get(standin, (None, None, None))[0] - if sm == 'g' and lm != 'r': + (lm, largs, lmsg) = actionbyfile.get(lfile, (None, None, None)) + (sm, sargs, smsg) = actionbyfile.get(standin, (None, None, None)) + if sm in ('g', 'dc') and lm != 'r': # Case 1: normal file in the working copy, largefile in # the second parent usermsg = _('remote turned local normal file %s into a largefile\n' @@ -450,14 +450,16 @@ '$$ &Largefile $$ &Normal file') % lfile if repo.ui.promptchoice(usermsg, 0) == 0: # pick remote largefile actionbyfile[lfile] = ('r', None, 'replaced by standin') + actionbyfile[standin] = ('g', sargs, 'replaces standin') else: # keep local normal file + actionbyfile[lfile] = ('k', None, 'replaces standin') if branchmerge: actionbyfile[standin] = ('k', None, 'replaced by non-standin') else: actionbyfile[standin] = ('r', None, 'replaced by non-standin') - elif lm == 'g' and sm != 'r': + elif lm in ('g', 'dc') and sm != 'r': # Case 2: largefile in the working copy, normal file in # the second parent usermsg = _('remote turned local largefile %s into a normal file\n' @@ -467,6 +469,7 @@ if branchmerge: # largefile can be restored from standin safely actionbyfile[lfile] = ('k', None, 'replaced by standin') + actionbyfile[standin] = ('k', None, 'replaces standin') else: # "lfile" should be marked as "removed" without # removal of itself @@ -476,6 +479,7 @@ # linear-merge should treat this largefile as 're-added' actionbyfile[standin] = ('a', None, 'keep standin') else: # pick remote normal file + actionbyfile[lfile] = ('g', largs, 'replaces standin') actionbyfile[standin] = ('r', None, 'replaced by non-standin') # Convert back to dictionary-of-lists format
--- a/mercurial/merge.py Sun Nov 30 22:47:53 2014 -0500 +++ b/mercurial/merge.py Thu Dec 11 21:21:21 2014 -0800 @@ -640,26 +640,6 @@ _resolvetrivial(repo, wctx, mctx, ancestors[0], actions) - # Prompt and create actions. TODO: Move this towards resolve phase. - for f, args, msg in sorted(actions['cd']): - if repo.ui.promptchoice( - _("local changed %s which remote deleted\n" - "use (c)hanged version or (d)elete?" - "$$ &Changed $$ &Delete") % f, 0): - actions['r'].append((f, None, "prompt delete")) - else: - actions['a'].append((f, None, "prompt keep")) - del actions['cd'][:] - - for f, args, msg in sorted(actions['dc']): - flags, = args - if repo.ui.promptchoice( - _("remote changed %s which local deleted\n" - "use (c)hanged version or leave (d)eleted?" - "$$ &Changed $$ &Deleted") % f, 0) == 0: - actions['g'].append((f, (flags,), "prompt recreating")) - del actions['dc'][:] - if wctx.rev() is None: ractions, factions = _forgetremoved(wctx, mctx, branchmerge) actions['r'].extend(ractions) @@ -1111,6 +1091,26 @@ repo, wc, p2, pas, branchmerge, force, partial, mergeancestor, followcopies) + # Prompt and create actions. TODO: Move this towards resolve phase. + for f, args, msg in sorted(actions['cd']): + if repo.ui.promptchoice( + _("local changed %s which remote deleted\n" + "use (c)hanged version or (d)elete?" + "$$ &Changed $$ &Delete") % f, 0): + actions['r'].append((f, None, "prompt delete")) + else: + actions['a'].append((f, None, "prompt keep")) + del actions['cd'][:] + + for f, args, msg in sorted(actions['dc']): + flags, = args + if repo.ui.promptchoice( + _("remote changed %s which local deleted\n" + "use (c)hanged version or leave (d)eleted?" + "$$ &Changed $$ &Deleted") % f, 0) == 0: + actions['g'].append((f, (flags,), "prompt recreating")) + del actions['dc'][:] + ### apply phase if not branchmerge: # just jump to the new rev fp1, fp2, xp1, xp2 = fp2, nullid, xp2, ''
--- a/tests/test-issue3084.t Sun Nov 30 22:47:53 2014 -0500 +++ b/tests/test-issue3084.t Thu Dec 11 21:21:21 2014 -0800 @@ -283,8 +283,6 @@ $ hg up -Cqr normal2 $ hg merge -r large - local changed f which remote deleted - use (c)hanged version or (d)elete? c remote turned local normal file f into a largefile use (l)argefile or keep (n)ormal file? l getting changed largefiles @@ -295,9 +293,7 @@ large $ hg up -Cqr normal2 - $ ( echo c; echo n ) | hg merge -r large --config ui.interactive=Yes - local changed f which remote deleted - use (c)hanged version or (d)elete? c + $ echo n | hg merge -r large --config ui.interactive=Yes remote turned local normal file f into a largefile use (l)argefile or keep (n)ormal file? n 0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -305,23 +301,10 @@ $ cat f normal2 - $ hg up -Cqr normal2 - $ echo d | hg merge -r large --config ui.interactive=Yes - local changed f which remote deleted - use (c)hanged version or (d)elete? d - getting changed largefiles - 1 largefiles updated, 0 removed - 1 files updated, 0 files merged, 1 files removed, 0 files unresolved - (branch merge, don't forget to commit) - $ cat f - large - swap $ hg up -Cqr large $ hg merge -r normal2 - remote changed f which local deleted - use (c)hanged version or leave (d)eleted? c remote turned local largefile f into a normal file keep (l)argefile or use (n)ormal file? l getting changed largefiles @@ -332,9 +315,7 @@ large $ hg up -Cqr large - $ ( echo c; echo n ) | hg merge -r normal2 --config ui.interactive=Yes - remote changed f which local deleted - use (c)hanged version or leave (d)eleted? c + $ echo n | hg merge -r normal2 --config ui.interactive=Yes remote turned local largefile f into a normal file keep (l)argefile or use (n)ormal file? n getting changed largefiles @@ -344,17 +325,6 @@ $ cat f normal2 - $ hg up -Cqr large - $ echo d | hg merge -r normal2 --config ui.interactive=Yes - remote changed f which local deleted - use (c)hanged version or leave (d)eleted? d - getting changed largefiles - 0 largefiles updated, 0 removed - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - (branch merge, don't forget to commit) - $ cat f - large - Ancestor: large Parent: large-id Parent: normal result: normal $ hg up -Cqr large-id @@ -400,8 +370,6 @@ $ hg up -Cqr large2 $ hg merge -r normal - local changed .hglf/f which remote deleted - use (c)hanged version or (d)elete? c remote turned local largefile f into a normal file keep (l)argefile or use (n)ormal file? l getting changed largefiles @@ -412,9 +380,9 @@ large2 $ hg up -Cqr large2 - $ echo d | hg merge -r normal --config ui.interactive=Yes - local changed .hglf/f which remote deleted - use (c)hanged version or (d)elete? d + $ echo n | hg merge -r normal --config ui.interactive=Yes + remote turned local largefile f into a normal file + keep (l)argefile or use (n)ormal file? n getting changed largefiles 0 largefiles updated, 0 removed 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -426,8 +394,6 @@ $ hg up -Cqr normal $ hg merge -r large2 - remote changed .hglf/f which local deleted - use (c)hanged version or leave (d)eleted? c remote turned local normal file f into a largefile use (l)argefile or keep (n)ormal file? l getting changed largefiles @@ -438,9 +404,9 @@ large2 $ hg up -Cqr normal - $ echo d | hg merge -r large2 --config ui.interactive=Yes - remote changed .hglf/f which local deleted - use (c)hanged version or leave (d)eleted? d + $ echo n | hg merge -r large2 --config ui.interactive=Yes + remote turned local normal file f into a largefile + use (l)argefile or keep (n)ormal file? n 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ cat f
--- a/tests/test-largefiles-update.t Sun Nov 30 22:47:53 2014 -0500 +++ b/tests/test-largefiles-update.t Thu Dec 11 21:21:21 2014 -0800 @@ -320,8 +320,6 @@ $ hg update -q -C 2 $ echo 'modified large2 for linear merge' > large2 $ hg update -q 5 - local changed .hglf/large2 which remote deleted - use (c)hanged version or (d)elete? c remote turned local largefile large2 into a normal file keep (l)argefile or use (n)ormal file? l $ hg debugdirstate --nodates | grep large2 @@ -368,8 +366,6 @@ adding manifests adding file changes added 3 changesets with 5 changes to 5 files - local changed .hglf/large2 which remote deleted - use (c)hanged version or (d)elete? c remote turned local largefile large2 into a normal file keep (l)argefile or use (n)ormal file? l largefile large1 has a merge conflict @@ -403,8 +399,6 @@ adding manifests adding file changes added 3 changesets with 5 changes to 5 files - local changed .hglf/large2 which remote deleted - use (c)hanged version or (d)elete? c remote turned local largefile large2 into a normal file keep (l)argefile or use (n)ormal file? l largefile large1 has a merge conflict @@ -451,7 +445,6 @@ $ hg update --config ui.interactive=True --config debug.dirstate.delaywrite=2 <<EOF > m > r - > c > l > l > EOF @@ -459,8 +452,6 @@ (M)erge, keep (l)ocal or keep (r)emote? m subrepository sources for sub differ (in checked out version) use (l)ocal source (f74e50bd9e55) or (r)emote source (d65e59e952a9)? r - local changed .hglf/large2 which remote deleted - use (c)hanged version or (d)elete? c remote turned local largefile large2 into a normal file keep (l)argefile or use (n)ormal file? l largefile large1 has a merge conflict