diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1583,8 +1583,7 @@ class memctx(committablectx): p1, p2 = parents self._parents = [changectx(self._repo, p) for p in (p1, p2)] files = sorted(set(files)) - self._status = scmutil.status(files, [], [], [], [], [], []) - self._filectxfn = filectxfn + self._files = files self.substate = {} # if store is not callable, wrap it in a function @@ -1600,6 +1599,10 @@ class memctx(committablectx): islink=fctx.islink(), isexec=fctx.isexec(), copied=copied, memctx=memctx) self._filectxfn = getfilectx + else: + # "util.cachefunc" reduces invocation of possibly expensive + # "filectxfn" for performance (e.g. converting from another VCS) + self._filectxfn = util.cachefunc(filectxfn) self._extra = extra and extra.copy() or {} if self._extra.get('branch', '') == '': @@ -1645,6 +1648,31 @@ class memctx(committablectx): return man + @propertycache + def _status(self): + """Calculate exact status from ``files`` specified at construction + """ + man1 = self.p1().manifest() + p2 = self._parents[1] + # "1 < len(self._parents)" can't be used for checking + # existence of the 2nd parent, because "memctx._parents" is + # explicitly initialized by the list, of which length is 2. + if p2.node() != nullid: + man2 = p2.manifest() + managing = lambda f: f in man1 or f in man2 + else: + managing = lambda f: f in man1 + + modified, added, removed = [], [], [] + for f in self._files: + if not managing(f): + added.append(f) + elif self[f]: + modified.append(f) + else: + removed.append(f) + + return scmutil.status(modified, added, removed, [], [], [], []) class memfilectx(committablefilectx): """memfilectx represents an in-memory file to commit. diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -842,6 +842,8 @@ Test that amend with --edit invokes edit $ hg parents --template "{desc}\n" editor should be suppressed + $ hg status --rev '.^1::.' + A foo $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit editor should be invoked @@ -851,7 +853,7 @@ Test that amend with --edit invokes edit HG: -- HG: user: test HG: branch 'silliness' - HG: changed foo + HG: added foo $ hg parents --template "{desc}\n" editor should be invoked diff --git a/tests/test-convert-svn-encoding.t b/tests/test-convert-svn-encoding.t --- a/tests/test-convert-svn-encoding.t +++ b/tests/test-convert-svn-encoding.t @@ -78,13 +78,11 @@ Convert while testing all possible outpu reparent to file://*/svn-repo/trunk (glob) scanning paths: /trunk/\xc3\xb9 3/4 (75.00%) (esc) mark /trunk/\xc3\xb9 came from \xc3\xa0:2 (esc) - \xc3\xa0/e\xcc\x81 (esc) getting files: \xc3\xa0/e\xcc\x81 1/4 (25.00%) (esc) + getting files: \xc3\xa9 2/4 (50.00%) (esc) \xc3\xa8 (esc) - getting files: \xc3\xa8 2/4 (50.00%) (esc) + getting files: \xc3\xa8 3/4 (75.00%) (esc) \xc3\xa8: copy \xc3\xa9:6b67ccefd5ce6de77e7ead4f5292843a0255329f (esc) - \xc3\xa9 (esc) - getting files: \xc3\xa9 3/4 (75.00%) (esc) \xc3\xb9/e\xcc\x81 (esc) getting files: \xc3\xb9/e\xcc\x81 4/4 (100.00%) (esc) \xc3\xb9/e\xcc\x81: copy \xc3\xa0/e\xcc\x81:a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc) @@ -99,9 +97,7 @@ Convert while testing all possible outpu gone from -1 reparent to file://*/svn-repo (glob) reparent to file://*/svn-repo/trunk (glob) - \xc3\xa8 (esc) getting files: \xc3\xa8 1/2 (50.00%) (esc) - \xc3\xb9/e\xcc\x81 (esc) getting files: \xc3\xb9/e\xcc\x81 2/2 (100.00%) (esc) 1 branch to branch? source: svn:afeb9c47-92ff-4c0c-9f72-e1f6eb8ac9af/branches/branch?@5 diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t --- a/tests/test-histedit-fold.t +++ b/tests/test-histedit-fold.t @@ -172,11 +172,16 @@ check saving last-message.txt > EOF $ rm -f .hg/last-message.txt - $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <&1 < pick 8e03a72b6f83 f > fold c4a9eb7989fc d > EOF 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + adding d allow non-folding commit 0 files updated, 0 files merged, 3 files removed, 0 files unresolved ==== before editing @@ -193,13 +198,14 @@ check saving last-message.txt HG: -- HG: user: test HG: branch 'default' - HG: changed c - HG: changed d - HG: changed f + HG: added c + HG: added d + HG: added f ==== transaction abort! rollback completed abort: pretxncommit.abortfolding hook failed + [255] $ cat .hg/last-message.txt f