##// END OF EJS Templates
context: introduce p[12]copies() methods and debugp[12]copies commands...
Martin von Zweigbergk -
r41905:456ad0fd default draft
parent child Browse files
Show More
@@ -439,6 +439,29 b' class changectx(basectx):'
439 return self._changeset.date
439 return self._changeset.date
440 def files(self):
440 def files(self):
441 return self._changeset.files
441 return self._changeset.files
442 @propertycache
443 def _copies(self):
444 p1copies = {}
445 p2copies = {}
446 p1 = self.p1()
447 p2 = self.p2()
448 narrowmatch = self._repo.narrowmatch()
449 for dst in self.files():
450 if not narrowmatch(dst) or dst not in self:
451 continue
452 copied = self[dst].renamed()
453 if not copied:
454 continue
455 src, srcnode = copied
456 if src in p1 and p1[src].filenode() == srcnode:
457 p1copies[dst] = src
458 elif src in p2 and p2[src].filenode() == srcnode:
459 p2copies[dst] = src
460 return p1copies, p2copies
461 def p1copies(self):
462 return self._copies[0]
463 def p2copies(self):
464 return self._copies[1]
442 def description(self):
465 def description(self):
443 return self._changeset.description
466 return self._changeset.description
444 def branch(self):
467 def branch(self):
@@ -1158,7 +1181,26 b' class committablectx(basectx):'
1158 def files(self):
1181 def files(self):
1159 return sorted(self._status.modified + self._status.added +
1182 return sorted(self._status.modified + self._status.added +
1160 self._status.removed)
1183 self._status.removed)
1161
1184 @propertycache
1185 def _copies(self):
1186 p1copies = {}
1187 p2copies = {}
1188 parents = self._repo.dirstate.parents()
1189 p1manifest = self._repo[parents[0]].manifest()
1190 p2manifest = self._repo[parents[1]].manifest()
1191 narrowmatch = self._repo.narrowmatch()
1192 for dst, src in self._repo.dirstate.copies().items():
1193 if not narrowmatch(dst):
1194 continue
1195 if src in p1manifest:
1196 p1copies[dst] = src
1197 elif src in p2manifest:
1198 p2copies[dst] = src
1199 return p1copies, p2copies
1200 def p1copies(self):
1201 return self._copies[0]
1202 def p2copies(self):
1203 return self._copies[1]
1162 def modified(self):
1204 def modified(self):
1163 return self._status.modified
1205 return self._status.modified
1164 def added(self):
1206 def added(self):
@@ -1810,6 +1852,30 b' class overlayworkingctx(committablectx):'
1810 return [f for f in self._cache.keys() if
1852 return [f for f in self._cache.keys() if
1811 not self._cache[f]['exists'] and self._existsinparent(f)]
1853 not self._cache[f]['exists'] and self._existsinparent(f)]
1812
1854
1855 def p1copies(self):
1856 copies = self._repo._wrappedctx.p1copies().copy()
1857 narrowmatch = self._repo.narrowmatch()
1858 for f in self._cache.keys():
1859 if not narrowmatch(f):
1860 continue
1861 copies.pop(f, None) # delete if it exists
1862 source = self._cache[f]['copied']
1863 if source:
1864 copies[f] = source
1865 return copies
1866
1867 def p2copies(self):
1868 copies = self._repo._wrappedctx.p2copies().copy()
1869 narrowmatch = self._repo.narrowmatch()
1870 for f in self._cache.keys():
1871 if not narrowmatch(f):
1872 continue
1873 copies.pop(f, None) # delete if it exists
1874 source = self._cache[f]['copied']
1875 if source:
1876 copies[f] = source
1877 return copies
1878
1813 def isinmemory(self):
1879 def isinmemory(self):
1814 return True
1880 return True
1815
1881
@@ -1741,6 +1741,28 b' def debugobsolete(ui, repo, precursor=No'
1741 cmdutil.showmarker(fm, m, index=ind)
1741 cmdutil.showmarker(fm, m, index=ind)
1742 fm.end()
1742 fm.end()
1743
1743
1744 @command('debugp1copies',
1745 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1746 _('[-r REV]'))
1747 def debugp1copies(ui, repo, **opts):
1748 """dump copy information compared to p1"""
1749
1750 opts = pycompat.byteskwargs(opts)
1751 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1752 for dst, src in ctx.p1copies().items():
1753 ui.write('%s -> %s\n' % (src, dst))
1754
1755 @command('debugp2copies',
1756 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1757 _('[-r REV]'))
1758 def debugp1copies(ui, repo, **opts):
1759 """dump copy information compared to p2"""
1760
1761 opts = pycompat.byteskwargs(opts)
1762 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1763 for dst, src in ctx.p2copies().items():
1764 ui.write('%s -> %s\n' % (src, dst))
1765
1744 @command('debugpathcomplete',
1766 @command('debugpathcomplete',
1745 [('f', 'full', None, _('complete an entire path')),
1767 [('f', 'full', None, _('complete an entire path')),
1746 ('n', 'normal', None, _('show only normal files')),
1768 ('n', 'normal', None, _('show only normal files')),
@@ -103,6 +103,8 b' Show debug commands if there are no othe'
103 debugmergestate
103 debugmergestate
104 debugnamecomplete
104 debugnamecomplete
105 debugobsolete
105 debugobsolete
106 debugp1copies
107 debugp2copies
106 debugpathcomplete
108 debugpathcomplete
107 debugpathcopies
109 debugpathcopies
108 debugpeer
110 debugpeer
@@ -280,6 +282,8 b' Show all commands + options'
280 debugmergestate:
282 debugmergestate:
281 debugnamecomplete:
283 debugnamecomplete:
282 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
284 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
285 debugp1copies: rev
286 debugp2copies: rev
283 debugpathcomplete: full, normal, added, removed
287 debugpathcomplete: full, normal, added, removed
284 debugpathcopies: include, exclude
288 debugpathcopies: include, exclude
285 debugpeer:
289 debugpeer:
@@ -17,12 +17,17 b' Simple rename case'
17 $ echo x > x
17 $ echo x > x
18 $ hg ci -Aqm 'add x'
18 $ hg ci -Aqm 'add x'
19 $ hg mv x y
19 $ hg mv x y
20 $ hg debugp1copies
21 x -> y
22 $ hg debugp2copies
20 $ hg ci -m 'rename x to y'
23 $ hg ci -m 'rename x to y'
21 $ hg l
24 $ hg l
22 @ 1 rename x to y
25 @ 1 rename x to y
23 | x y
26 | x y
24 o 0 add x
27 o 0 add x
25 x
28 x
29 $ hg debugp1copies -r 1
30 x -> y
26 $ hg debugpathcopies 0 1
31 $ hg debugpathcopies 0 1
27 x -> y
32 x -> y
28 $ hg debugpathcopies 1 0
33 $ hg debugpathcopies 1 0
@@ -41,12 +46,17 b' Copy a file onto another file'
41 $ echo y > y
46 $ echo y > y
42 $ hg ci -Aqm 'add x and y'
47 $ hg ci -Aqm 'add x and y'
43 $ hg cp -f x y
48 $ hg cp -f x y
49 $ hg debugp1copies
50 x -> y
51 $ hg debugp2copies
44 $ hg ci -m 'copy x onto y'
52 $ hg ci -m 'copy x onto y'
45 $ hg l
53 $ hg l
46 @ 1 copy x onto y
54 @ 1 copy x onto y
47 | y
55 | y
48 o 0 add x and y
56 o 0 add x and y
49 x y
57 x y
58 $ hg debugp1copies -r 1
59 x -> y
50 Incorrectly doesn't show the rename
60 Incorrectly doesn't show the rename
51 $ hg debugpathcopies 0 1
61 $ hg debugpathcopies 0 1
52
62
@@ -63,6 +73,8 b' produce a new filelog entry. The changes'
63 | x2
73 | x2
64 o 0 add x and x2 with same content
74 o 0 add x and x2 with same content
65 x x2
75 x x2
76 $ hg debugp1copies -r 1
77 x -> x2
66 Incorrectly doesn't show the rename
78 Incorrectly doesn't show the rename
67 $ hg debugpathcopies 0 1
79 $ hg debugpathcopies 0 1
68
80
@@ -85,6 +97,8 b' Copy a file, then delete destination, th'
85 | y
97 | y
86 o 0 add x
98 o 0 add x
87 x
99 x
100 $ hg debugp1copies -r 3
101 x -> y
88 $ hg debugpathcopies 0 3
102 $ hg debugpathcopies 0 3
89 x -> y
103 x -> y
90
104
@@ -93,6 +107,9 b' Rename file in a loop: x->y->z->x'
93 $ echo x > x
107 $ echo x > x
94 $ hg ci -Aqm 'add x'
108 $ hg ci -Aqm 'add x'
95 $ hg mv x y
109 $ hg mv x y
110 $ hg debugp1copies
111 x -> y
112 $ hg debugp2copies
96 $ hg ci -m 'rename x to y'
113 $ hg ci -m 'rename x to y'
97 $ hg mv y z
114 $ hg mv y z
98 $ hg ci -m 'rename y to z'
115 $ hg ci -m 'rename y to z'
@@ -129,6 +146,7 b' end up reporting y as copied from x (if '
129 | x y
146 | x y
130 o 0 add x
147 o 0 add x
131 x
148 x
149 $ hg debugp1copies -r 3
132 $ hg debugpathcopies 0 3
150 $ hg debugpathcopies 0 3
133
151
134 Copy x to z, then remove z, then copy x2 (same content as x) to z. With copy metadata in the
152 Copy x to z, then remove z, then copy x2 (same content as x) to z. With copy metadata in the
@@ -153,6 +171,8 b' to the first commit that added the file.'
153 | z
171 | z
154 o 0 add x and x2 with same content
172 o 0 add x and x2 with same content
155 x x2
173 x x2
174 $ hg debugp1copies -r 3
175 x2 -> z
156 $ hg debugpathcopies 0 3
176 $ hg debugpathcopies 0 3
157 x2 -> z
177 x2 -> z
158
178
@@ -225,6 +245,8 b' Merge rename from other branch'
225 $ echo z > z
245 $ echo z > z
226 $ hg ci -Aqm 'add z'
246 $ hg ci -Aqm 'add z'
227 $ hg merge -q 1
247 $ hg merge -q 1
248 $ hg debugp1copies
249 $ hg debugp2copies
228 $ hg ci -m 'merge rename from p2'
250 $ hg ci -m 'merge rename from p2'
229 $ hg l
251 $ hg l
230 @ 3 merge rename from p2
252 @ 3 merge rename from p2
@@ -237,6 +259,8 b' Merge rename from other branch'
237 x
259 x
238 Perhaps we should indicate the rename here, but `hg status` is documented to be weird during
260 Perhaps we should indicate the rename here, but `hg status` is documented to be weird during
239 merges, so...
261 merges, so...
262 $ hg debugp1copies -r 3
263 $ hg debugp2copies -r 3
240 $ hg debugpathcopies 0 3
264 $ hg debugpathcopies 0 3
241 x -> y
265 x -> y
242 $ hg debugpathcopies 1 2
266 $ hg debugpathcopies 1 2
@@ -254,10 +278,16 b' Copy file from either side in a merge'
254 $ hg ci -Aqm 'add y'
278 $ hg ci -Aqm 'add y'
255 $ hg merge -q 0
279 $ hg merge -q 0
256 $ hg cp y z
280 $ hg cp y z
281 $ hg debugp1copies
282 y -> z
283 $ hg debugp2copies
257 $ hg ci -m 'copy file from p1 in merge'
284 $ hg ci -m 'copy file from p1 in merge'
258 $ hg co -q 1
285 $ hg co -q 1
259 $ hg merge -q 0
286 $ hg merge -q 0
260 $ hg cp x z
287 $ hg cp x z
288 $ hg debugp1copies
289 $ hg debugp2copies
290 x -> z
261 $ hg ci -qm 'copy file from p2 in merge'
291 $ hg ci -qm 'copy file from p2 in merge'
262 $ hg l
292 $ hg l
263 @ 3 copy file from p2 in merge
293 @ 3 copy file from p2 in merge
@@ -268,9 +298,15 b' Copy file from either side in a merge'
268 | y
298 | y
269 o 0 add x
299 o 0 add x
270 x
300 x
301 $ hg debugp1copies -r 2
302 y -> z
303 $ hg debugp2copies -r 2
271 $ hg debugpathcopies 1 2
304 $ hg debugpathcopies 1 2
272 y -> z
305 y -> z
273 $ hg debugpathcopies 0 2
306 $ hg debugpathcopies 0 2
307 $ hg debugp1copies -r 3
308 $ hg debugp2copies -r 3
309 x -> z
274 $ hg debugpathcopies 1 3
310 $ hg debugpathcopies 1 3
275 $ hg debugpathcopies 0 3
311 $ hg debugpathcopies 0 3
276 x -> z
312 x -> z
@@ -284,6 +320,9 b' Copy file that exists on both sides of t'
284 $ hg ci -Aqm 'add x on branch 2'
320 $ hg ci -Aqm 'add x on branch 2'
285 $ hg merge -q 0
321 $ hg merge -q 0
286 $ hg cp x z
322 $ hg cp x z
323 $ hg debugp1copies
324 x -> z
325 $ hg debugp2copies
287 $ hg ci -qm 'merge'
326 $ hg ci -qm 'merge'
288 $ hg l
327 $ hg l
289 @ 2 merge
328 @ 2 merge
@@ -292,6 +331,9 b' Copy file that exists on both sides of t'
292 | x
331 | x
293 o 0 add x on branch 1
332 o 0 add x on branch 1
294 x
333 x
334 $ hg debugp1copies -r 2
335 x -> z
336 $ hg debugp2copies -r 2
295 It's a little weird that it shows up on both sides
337 It's a little weird that it shows up on both sides
296 $ hg debugpathcopies 1 2
338 $ hg debugpathcopies 1 2
297 x -> z
339 x -> z
@@ -312,6 +354,9 b' Copy file that exists on both sides of t'
312 $ hg resolve -m x
354 $ hg resolve -m x
313 (no more unresolved files)
355 (no more unresolved files)
314 $ hg cp x z
356 $ hg cp x z
357 $ hg debugp1copies
358 x -> z
359 $ hg debugp2copies
315 $ hg ci -qm 'merge'
360 $ hg ci -qm 'merge'
316 $ hg l
361 $ hg l
317 @ 2 merge
362 @ 2 merge
@@ -320,6 +365,9 b' Copy file that exists on both sides of t'
320 | x
365 | x
321 o 0 add x on branch 1
366 o 0 add x on branch 1
322 x
367 x
368 $ hg debugp1copies -r 2
369 $ hg debugp2copies -r 2
370 x -> z
323 $ hg debugpathcopies 1 2
371 $ hg debugpathcopies 1 2
324 $ hg debugpathcopies 0 2
372 $ hg debugpathcopies 0 2
325 x -> z
373 x -> z
@@ -345,6 +393,8 b' of the merge to the merge should include'
345 |/ y
393 |/ y
346 o 0 add x
394 o 0 add x
347 x
395 x
396 $ hg debugp1copies -r 3
397 $ hg debugp2copies -r 3
348 $ hg debugpathcopies 2 3
398 $ hg debugpathcopies 2 3
349 x -> y
399 x -> y
350 $ hg debugpathcopies 1 3
400 $ hg debugpathcopies 1 3
@@ -375,6 +425,9 b' first side should not include the y->z r'
375 |/ y
425 |/ y
376 o 0 add x
426 o 0 add x
377 x
427 x
428 $ hg debugp1copies -r 3
429 y -> z
430 $ hg debugp2copies -r 3
378 $ hg debugpathcopies 2 3
431 $ hg debugpathcopies 2 3
379 y -> z
432 y -> z
380 $ hg debugpathcopies 1 3
433 $ hg debugpathcopies 1 3
@@ -1011,6 +1011,10 b' Test list of internal help commands'
1011 debugoptADV (no help text available)
1011 debugoptADV (no help text available)
1012 debugoptDEP (no help text available)
1012 debugoptDEP (no help text available)
1013 debugoptEXP (no help text available)
1013 debugoptEXP (no help text available)
1014 debugp1copies
1015 dump copy information compared to p1
1016 debugp2copies
1017 dump copy information compared to p2
1014 debugpathcomplete
1018 debugpathcomplete
1015 complete part or all of a tracked path
1019 complete part or all of a tracked path
1016 debugpathcopies
1020 debugpathcopies
General Comments 0
You need to be logged in to leave comments. Login now