Mercurial > hg-stable
changeset 49983:7b474609f199
merge: avoid dereferencing repo fields repeatedly
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Wed, 04 Jan 2023 19:30:47 +0000 |
parents | b7cf91ef03ba |
children | c7a04bfabd4d |
files | hgext/largefiles/overrides.py mercurial/merge.py |
diffstat | 2 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Fri Jan 06 18:09:19 2023 +0000 +++ b/hgext/largefiles/overrides.py Wed Jan 04 19:30:47 2023 +0000 @@ -511,10 +511,12 @@ # largefiles. This makes the merge proceed and we can then handle this # case further in the overridden calculateupdates function below. @eh.wrapfunction(merge, b'_checkunknownfile') -def overridecheckunknownfile(origfn, repo, wctx, mctx, f, f2=None): - if lfutil.standin(repo.dirstate.normalize(f)) in wctx: +def overridecheckunknownfile( + origfn, dirstate, wvfs, dircache, wctx, mctx, f, f2=None +): + if lfutil.standin(dirstate.normalize(f)) in wctx: return False - return origfn(repo, wctx, mctx, f, f2) + return origfn(dirstate, wvfs, dircache, wctx, mctx, f, f2) # The manifest merge handles conflicts on the manifest level. We want
--- a/mercurial/merge.py Fri Jan 06 18:09:19 2023 +0000 +++ b/mercurial/merge.py Wed Jan 04 19:30:47 2023 +0000 @@ -46,7 +46,7 @@ return config -def _checkunknownfile(repo, dircache, wctx, mctx, f, f2=None): +def _checkunknownfile(dirstate, wvfs, dircache, wctx, mctx, f, f2=None): if wctx.isinmemory(): # Nothing to do in IMM because nothing in the "working copy" can be an # unknown file. @@ -58,8 +58,8 @@ if f2 is None: f2 = f return ( - repo.wvfs.isfileorlink_checkdir(dircache, f) - and repo.dirstate.normalize(f) not in repo.dirstate + wvfs.isfileorlink_checkdir(dircache, f) + and dirstate.normalize(f) not in dirstate and mctx[f2].cmp(wctx[f]) ) @@ -136,6 +136,8 @@ b'experimental', b'merge.checkpathconflicts' ) dircache = dict() + dirstate = repo.dirstate + wvfs = repo.wvfs if not force: def collectconflicts(conflicts, config): @@ -151,7 +153,7 @@ mergestatemod.ACTION_DELETED_CHANGED, ) ): - if _checkunknownfile(repo, dircache, wctx, mctx, f): + if _checkunknownfile(dirstate, wvfs, dircache, wctx, mctx, f): fileconflicts.add(f) elif pathconfig and f not in wctx: path = checkunknowndirs(repo, wctx, f) @@ -160,7 +162,9 @@ for f, args, msg in mresult.getactions( [mergestatemod.ACTION_LOCAL_DIR_RENAME_GET] ): - if _checkunknownfile(repo, wctx, mctx, f, args[0]): + if _checkunknownfile( + dirstate, wvfs, dircache, wctx, mctx, f, args[0] + ): fileconflicts.add(f) allconflicts = fileconflicts | pathconflicts @@ -173,7 +177,9 @@ mresult.getactions([mergestatemod.ACTION_CREATED_MERGE]) ): fl2, anc = args - different = _checkunknownfile(repo, wctx, mctx, f) + different = _checkunknownfile( + dirstate, wvfs, dircache, wctx, mctx, f + ) if repo.dirstate._ignore(f): config = ignoredconfig else: