Mercurial > hg
changeset 23641:a7a0f32a383f
merge: make calculateupdates() return file->action dict
This simplifies largefiles' overridecalculateupdates(), which no
longer has to do the conversion it started doing in 38e55e55ae4d
(largefiles: rewrite merge code using dictionary with entry per file,
2014-12-09).
To keep this patch small, we'll leave the name 'actionbyfile' in
overrides.py. It will be renamed in the next patch.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 Dec 2014 22:07:41 -0800 |
parents | b46b9865dd08 |
children | 7fd1a6c27e60 |
files | hgext/largefiles/overrides.py mercurial/merge.py |
diffstat | 2 files changed, 15 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Thu Dec 11 21:58:49 2014 -0800 +++ b/hgext/largefiles/overrides.py Thu Dec 11 22:07:41 2014 -0800 @@ -435,15 +435,13 @@ # Convert to dictionary with filename as key and action as value. lfiles = set() - actionbyfile = {} - for m, l in actions.iteritems(): - for f, args, msg in l: - actionbyfile[f] = m, args, msg - splitstandin = f and lfutil.splitstandin(f) - if splitstandin in p1: - lfiles.add(splitstandin) - elif lfutil.standin(f) in p1: - lfiles.add(f) + actionbyfile = actions + for f in actionbyfile: + splitstandin = f and lfutil.splitstandin(f) + if splitstandin in p1: + lfiles.add(splitstandin) + elif lfutil.standin(f) in p1: + lfiles.add(f) for lfile in lfiles: standin = lfutil.standin(lfile) @@ -489,14 +487,7 @@ actionbyfile[lfile] = ('g', largs, 'replaces standin') actionbyfile[standin] = ('r', None, 'replaced by non-standin') - # Convert back to dictionary-of-lists format - for l in actions.itervalues(): - l[:] = [] - actions['lfmr'] = [] - for f, (m, args, msg) in actionbyfile.iteritems(): - actions[m].append((f, args, msg)) - - return actions, diverge, renamedelete + return actionbyfile, diverge, renamedelete def mergerecordupdates(orig, repo, actions, branchmerge): if 'lfmr' in actions:
--- a/mercurial/merge.py Thu Dec 11 21:58:49 2014 -0800 +++ b/mercurial/merge.py Thu Dec 11 22:07:41 2014 -0800 @@ -621,12 +621,6 @@ fractions = _forgetremoved(wctx, mctx, branchmerge) actions.update(fractions) - # Convert to dictionary-of-lists format - actionbyfile = actions - actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split()) - for f, (m, args, msg) in actionbyfile.iteritems(): - actions[m].append((f, args, msg)) - return actions, diverge, renamedelete def batchremove(repo, actions): @@ -1069,9 +1063,15 @@ followcopies = True ### calculate phase - actions, diverge, renamedelete = calculateupdates( + actionbyfile, diverge, renamedelete = calculateupdates( repo, wc, p2, pas, branchmerge, force, partial, mergeancestor, followcopies) + # Convert to dictionary-of-lists format + actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split()) + for f, (m, args, msg) in actionbyfile.iteritems(): + if m not in actions: + actions[m] = [] + actions[m].append((f, args, msg)) if not util.checkcase(repo.path): # check collision between files only in p2 for clean update