##// 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 439 return self._changeset.date
440 440 def files(self):
441 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 465 def description(self):
443 466 return self._changeset.description
444 467 def branch(self):
@@ -1158,7 +1181,26 b' class committablectx(basectx):'
1158 1181 def files(self):
1159 1182 return sorted(self._status.modified + self._status.added +
1160 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 1204 def modified(self):
1163 1205 return self._status.modified
1164 1206 def added(self):
@@ -1810,6 +1852,30 b' class overlayworkingctx(committablectx):'
1810 1852 return [f for f in self._cache.keys() if
1811 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 1879 def isinmemory(self):
1814 1880 return True
1815 1881
@@ -1741,6 +1741,28 b' def debugobsolete(ui, repo, precursor=No'
1741 1741 cmdutil.showmarker(fm, m, index=ind)
1742 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 1766 @command('debugpathcomplete',
1745 1767 [('f', 'full', None, _('complete an entire path')),
1746 1768 ('n', 'normal', None, _('show only normal files')),
@@ -103,6 +103,8 b' Show debug commands if there are no othe'
103 103 debugmergestate
104 104 debugnamecomplete
105 105 debugobsolete
106 debugp1copies
107 debugp2copies
106 108 debugpathcomplete
107 109 debugpathcopies
108 110 debugpeer
@@ -280,6 +282,8 b' Show all commands + options'
280 282 debugmergestate:
281 283 debugnamecomplete:
282 284 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
285 debugp1copies: rev
286 debugp2copies: rev
283 287 debugpathcomplete: full, normal, added, removed
284 288 debugpathcopies: include, exclude
285 289 debugpeer:
@@ -17,12 +17,17 b' Simple rename case'
17 17 $ echo x > x
18 18 $ hg ci -Aqm 'add x'
19 19 $ hg mv x y
20 $ hg debugp1copies
21 x -> y
22 $ hg debugp2copies
20 23 $ hg ci -m 'rename x to y'
21 24 $ hg l
22 25 @ 1 rename x to y
23 26 | x y
24 27 o 0 add x
25 28 x
29 $ hg debugp1copies -r 1
30 x -> y
26 31 $ hg debugpathcopies 0 1
27 32 x -> y
28 33 $ hg debugpathcopies 1 0
@@ -41,12 +46,17 b' Copy a file onto another file'
41 46 $ echo y > y
42 47 $ hg ci -Aqm 'add x and y'
43 48 $ hg cp -f x y
49 $ hg debugp1copies
50 x -> y
51 $ hg debugp2copies
44 52 $ hg ci -m 'copy x onto y'
45 53 $ hg l
46 54 @ 1 copy x onto y
47 55 | y
48 56 o 0 add x and y
49 57 x y
58 $ hg debugp1copies -r 1
59 x -> y
50 60 Incorrectly doesn't show the rename
51 61 $ hg debugpathcopies 0 1
52 62
@@ -63,6 +73,8 b' produce a new filelog entry. The changes'
63 73 | x2
64 74 o 0 add x and x2 with same content
65 75 x x2
76 $ hg debugp1copies -r 1
77 x -> x2
66 78 Incorrectly doesn't show the rename
67 79 $ hg debugpathcopies 0 1
68 80
@@ -85,6 +97,8 b' Copy a file, then delete destination, th'
85 97 | y
86 98 o 0 add x
87 99 x
100 $ hg debugp1copies -r 3
101 x -> y
88 102 $ hg debugpathcopies 0 3
89 103 x -> y
90 104
@@ -93,6 +107,9 b' Rename file in a loop: x->y->z->x'
93 107 $ echo x > x
94 108 $ hg ci -Aqm 'add x'
95 109 $ hg mv x y
110 $ hg debugp1copies
111 x -> y
112 $ hg debugp2copies
96 113 $ hg ci -m 'rename x to y'
97 114 $ hg mv y z
98 115 $ hg ci -m 'rename y to z'
@@ -129,6 +146,7 b' end up reporting y as copied from x (if '
129 146 | x y
130 147 o 0 add x
131 148 x
149 $ hg debugp1copies -r 3
132 150 $ hg debugpathcopies 0 3
133 151
134 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 171 | z
154 172 o 0 add x and x2 with same content
155 173 x x2
174 $ hg debugp1copies -r 3
175 x2 -> z
156 176 $ hg debugpathcopies 0 3
157 177 x2 -> z
158 178
@@ -225,6 +245,8 b' Merge rename from other branch'
225 245 $ echo z > z
226 246 $ hg ci -Aqm 'add z'
227 247 $ hg merge -q 1
248 $ hg debugp1copies
249 $ hg debugp2copies
228 250 $ hg ci -m 'merge rename from p2'
229 251 $ hg l
230 252 @ 3 merge rename from p2
@@ -237,6 +259,8 b' Merge rename from other branch'
237 259 x
238 260 Perhaps we should indicate the rename here, but `hg status` is documented to be weird during
239 261 merges, so...
262 $ hg debugp1copies -r 3
263 $ hg debugp2copies -r 3
240 264 $ hg debugpathcopies 0 3
241 265 x -> y
242 266 $ hg debugpathcopies 1 2
@@ -254,10 +278,16 b' Copy file from either side in a merge'
254 278 $ hg ci -Aqm 'add y'
255 279 $ hg merge -q 0
256 280 $ hg cp y z
281 $ hg debugp1copies
282 y -> z
283 $ hg debugp2copies
257 284 $ hg ci -m 'copy file from p1 in merge'
258 285 $ hg co -q 1
259 286 $ hg merge -q 0
260 287 $ hg cp x z
288 $ hg debugp1copies
289 $ hg debugp2copies
290 x -> z
261 291 $ hg ci -qm 'copy file from p2 in merge'
262 292 $ hg l
263 293 @ 3 copy file from p2 in merge
@@ -268,9 +298,15 b' Copy file from either side in a merge'
268 298 | y
269 299 o 0 add x
270 300 x
301 $ hg debugp1copies -r 2
302 y -> z
303 $ hg debugp2copies -r 2
271 304 $ hg debugpathcopies 1 2
272 305 y -> z
273 306 $ hg debugpathcopies 0 2
307 $ hg debugp1copies -r 3
308 $ hg debugp2copies -r 3
309 x -> z
274 310 $ hg debugpathcopies 1 3
275 311 $ hg debugpathcopies 0 3
276 312 x -> z
@@ -284,6 +320,9 b' Copy file that exists on both sides of t'
284 320 $ hg ci -Aqm 'add x on branch 2'
285 321 $ hg merge -q 0
286 322 $ hg cp x z
323 $ hg debugp1copies
324 x -> z
325 $ hg debugp2copies
287 326 $ hg ci -qm 'merge'
288 327 $ hg l
289 328 @ 2 merge
@@ -292,6 +331,9 b' Copy file that exists on both sides of t'
292 331 | x
293 332 o 0 add x on branch 1
294 333 x
334 $ hg debugp1copies -r 2
335 x -> z
336 $ hg debugp2copies -r 2
295 337 It's a little weird that it shows up on both sides
296 338 $ hg debugpathcopies 1 2
297 339 x -> z
@@ -312,6 +354,9 b' Copy file that exists on both sides of t'
312 354 $ hg resolve -m x
313 355 (no more unresolved files)
314 356 $ hg cp x z
357 $ hg debugp1copies
358 x -> z
359 $ hg debugp2copies
315 360 $ hg ci -qm 'merge'
316 361 $ hg l
317 362 @ 2 merge
@@ -320,6 +365,9 b' Copy file that exists on both sides of t'
320 365 | x
321 366 o 0 add x on branch 1
322 367 x
368 $ hg debugp1copies -r 2
369 $ hg debugp2copies -r 2
370 x -> z
323 371 $ hg debugpathcopies 1 2
324 372 $ hg debugpathcopies 0 2
325 373 x -> z
@@ -345,6 +393,8 b' of the merge to the merge should include'
345 393 |/ y
346 394 o 0 add x
347 395 x
396 $ hg debugp1copies -r 3
397 $ hg debugp2copies -r 3
348 398 $ hg debugpathcopies 2 3
349 399 x -> y
350 400 $ hg debugpathcopies 1 3
@@ -375,6 +425,9 b' first side should not include the y->z r'
375 425 |/ y
376 426 o 0 add x
377 427 x
428 $ hg debugp1copies -r 3
429 y -> z
430 $ hg debugp2copies -r 3
378 431 $ hg debugpathcopies 2 3
379 432 y -> z
380 433 $ hg debugpathcopies 1 3
@@ -1011,6 +1011,10 b' Test list of internal help commands'
1011 1011 debugoptADV (no help text available)
1012 1012 debugoptDEP (no help text available)
1013 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 1018 debugpathcomplete
1015 1019 complete part or all of a tracked path
1016 1020 debugpathcopies
General Comments 0
You need to be logged in to leave comments. Login now