##// END OF EJS Templates
memctx: calculate exact status being committed from specified files...
FUJIWARA Katsunori -
r23587:8063901e default
parent child Browse files
Show More
@@ -1583,8 +1583,7 b' class memctx(committablectx):'
1583 p1, p2 = parents
1583 p1, p2 = parents
1584 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
1584 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
1585 files = sorted(set(files))
1585 files = sorted(set(files))
1586 self._status = scmutil.status(files, [], [], [], [], [], [])
1586 self._files = files
1587 self._filectxfn = filectxfn
1588 self.substate = {}
1587 self.substate = {}
1589
1588
1590 # if store is not callable, wrap it in a function
1589 # if store is not callable, wrap it in a function
@@ -1600,6 +1599,10 b' class memctx(committablectx):'
1600 islink=fctx.islink(), isexec=fctx.isexec(),
1599 islink=fctx.islink(), isexec=fctx.isexec(),
1601 copied=copied, memctx=memctx)
1600 copied=copied, memctx=memctx)
1602 self._filectxfn = getfilectx
1601 self._filectxfn = getfilectx
1602 else:
1603 # "util.cachefunc" reduces invocation of possibly expensive
1604 # "filectxfn" for performance (e.g. converting from another VCS)
1605 self._filectxfn = util.cachefunc(filectxfn)
1603
1606
1604 self._extra = extra and extra.copy() or {}
1607 self._extra = extra and extra.copy() or {}
1605 if self._extra.get('branch', '') == '':
1608 if self._extra.get('branch', '') == '':
@@ -1645,6 +1648,31 b' class memctx(committablectx):'
1645
1648
1646 return man
1649 return man
1647
1650
1651 @propertycache
1652 def _status(self):
1653 """Calculate exact status from ``files`` specified at construction
1654 """
1655 man1 = self.p1().manifest()
1656 p2 = self._parents[1]
1657 # "1 < len(self._parents)" can't be used for checking
1658 # existence of the 2nd parent, because "memctx._parents" is
1659 # explicitly initialized by the list, of which length is 2.
1660 if p2.node() != nullid:
1661 man2 = p2.manifest()
1662 managing = lambda f: f in man1 or f in man2
1663 else:
1664 managing = lambda f: f in man1
1665
1666 modified, added, removed = [], [], []
1667 for f in self._files:
1668 if not managing(f):
1669 added.append(f)
1670 elif self[f]:
1671 modified.append(f)
1672 else:
1673 removed.append(f)
1674
1675 return scmutil.status(modified, added, removed, [], [], [], [])
1648
1676
1649 class memfilectx(committablefilectx):
1677 class memfilectx(committablefilectx):
1650 """memfilectx represents an in-memory file to commit.
1678 """memfilectx represents an in-memory file to commit.
@@ -842,6 +842,8 b' Test that amend with --edit invokes edit'
842 $ hg parents --template "{desc}\n"
842 $ hg parents --template "{desc}\n"
843 editor should be suppressed
843 editor should be suppressed
844
844
845 $ hg status --rev '.^1::.'
846 A foo
845 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
847 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
846 editor should be invoked
848 editor should be invoked
847
849
@@ -851,7 +853,7 b' Test that amend with --edit invokes edit'
851 HG: --
853 HG: --
852 HG: user: test
854 HG: user: test
853 HG: branch 'silliness'
855 HG: branch 'silliness'
854 HG: changed foo
856 HG: added foo
855 $ hg parents --template "{desc}\n"
857 $ hg parents --template "{desc}\n"
856 editor should be invoked
858 editor should be invoked
857
859
@@ -78,13 +78,11 b' Convert while testing all possible outpu'
78 reparent to file://*/svn-repo/trunk (glob)
78 reparent to file://*/svn-repo/trunk (glob)
79 scanning paths: /trunk/\xc3\xb9 3/4 (75.00%) (esc)
79 scanning paths: /trunk/\xc3\xb9 3/4 (75.00%) (esc)
80 mark /trunk/\xc3\xb9 came from \xc3\xa0:2 (esc)
80 mark /trunk/\xc3\xb9 came from \xc3\xa0:2 (esc)
81 \xc3\xa0/e\xcc\x81 (esc)
82 getting files: \xc3\xa0/e\xcc\x81 1/4 (25.00%) (esc)
81 getting files: \xc3\xa0/e\xcc\x81 1/4 (25.00%) (esc)
82 getting files: \xc3\xa9 2/4 (50.00%) (esc)
83 \xc3\xa8 (esc)
83 \xc3\xa8 (esc)
84 getting files: \xc3\xa8 2/4 (50.00%) (esc)
84 getting files: \xc3\xa8 3/4 (75.00%) (esc)
85 \xc3\xa8: copy \xc3\xa9:6b67ccefd5ce6de77e7ead4f5292843a0255329f (esc)
85 \xc3\xa8: copy \xc3\xa9:6b67ccefd5ce6de77e7ead4f5292843a0255329f (esc)
86 \xc3\xa9 (esc)
87 getting files: \xc3\xa9 3/4 (75.00%) (esc)
88 \xc3\xb9/e\xcc\x81 (esc)
86 \xc3\xb9/e\xcc\x81 (esc)
89 getting files: \xc3\xb9/e\xcc\x81 4/4 (100.00%) (esc)
87 getting files: \xc3\xb9/e\xcc\x81 4/4 (100.00%) (esc)
90 \xc3\xb9/e\xcc\x81: copy \xc3\xa0/e\xcc\x81:a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc)
88 \xc3\xb9/e\xcc\x81: copy \xc3\xa0/e\xcc\x81:a9092a3d84a37b9993b5c73576f6de29b7ea50f6 (esc)
@@ -99,9 +97,7 b' Convert while testing all possible outpu'
99 gone from -1
97 gone from -1
100 reparent to file://*/svn-repo (glob)
98 reparent to file://*/svn-repo (glob)
101 reparent to file://*/svn-repo/trunk (glob)
99 reparent to file://*/svn-repo/trunk (glob)
102 \xc3\xa8 (esc)
103 getting files: \xc3\xa8 1/2 (50.00%) (esc)
100 getting files: \xc3\xa8 1/2 (50.00%) (esc)
104 \xc3\xb9/e\xcc\x81 (esc)
105 getting files: \xc3\xb9/e\xcc\x81 2/2 (100.00%) (esc)
101 getting files: \xc3\xb9/e\xcc\x81 2/2 (100.00%) (esc)
106 1 branch to branch?
102 1 branch to branch?
107 source: svn:afeb9c47-92ff-4c0c-9f72-e1f6eb8ac9af/branches/branch?@5
103 source: svn:afeb9c47-92ff-4c0c-9f72-e1f6eb8ac9af/branches/branch?@5
@@ -172,11 +172,16 b' check saving last-message.txt'
172 > EOF
172 > EOF
173
173
174 $ rm -f .hg/last-message.txt
174 $ rm -f .hg/last-message.txt
175 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF | fixbundle
175 $ hg status --rev '8e03a72b6f83^1::c4a9eb7989fc'
176 A c
177 A d
178 A f
179 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF
176 > pick 8e03a72b6f83 f
180 > pick 8e03a72b6f83 f
177 > fold c4a9eb7989fc d
181 > fold c4a9eb7989fc d
178 > EOF
182 > EOF
179 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
183 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
184 adding d
180 allow non-folding commit
185 allow non-folding commit
181 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
186 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
182 ==== before editing
187 ==== before editing
@@ -193,13 +198,14 b' check saving last-message.txt'
193 HG: --
198 HG: --
194 HG: user: test
199 HG: user: test
195 HG: branch 'default'
200 HG: branch 'default'
196 HG: changed c
201 HG: added c
197 HG: changed d
202 HG: added d
198 HG: changed f
203 HG: added f
199 ====
204 ====
200 transaction abort!
205 transaction abort!
201 rollback completed
206 rollback completed
202 abort: pretxncommit.abortfolding hook failed
207 abort: pretxncommit.abortfolding hook failed
208 [255]
203
209
204 $ cat .hg/last-message.txt
210 $ cat .hg/last-message.txt
205 f
211 f
General Comments 0
You need to be logged in to leave comments. Login now