Show More
@@ -87,6 +87,18 b' def encodecopies(copies):' | |||
|
87 | 87 | ] |
|
88 | 88 | return "\n".join(items) |
|
89 | 89 | |
|
90 | def decodecopies(data): | |
|
91 | try: | |
|
92 | copies = {} | |
|
93 | for l in data.split('\n'): | |
|
94 | k, v = l.split('\0') | |
|
95 | copies[k] = v | |
|
96 | return copies | |
|
97 | except ValueError: | |
|
98 | # Perhaps someone had chosen the same key name (e.g. "p1copies") and | |
|
99 | # used different syntax for the value. | |
|
100 | return None | |
|
101 | ||
|
90 | 102 | def stripdesc(desc): |
|
91 | 103 | """strip trailing whitespace and leading and trailing empty lines""" |
|
92 | 104 | return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') |
@@ -286,6 +298,16 b' class changelogrevision(object):' | |||
|
286 | 298 | return self._text[off[2] + 1:off[3]].split('\n') |
|
287 | 299 | |
|
288 | 300 | @property |
|
301 | def p1copies(self): | |
|
302 | rawcopies = self.extra.get('p1copies') | |
|
303 | return rawcopies and decodecopies(rawcopies) | |
|
304 | ||
|
305 | @property | |
|
306 | def p2copies(self): | |
|
307 | rawcopies = self.extra.get('p2copies') | |
|
308 | return rawcopies and decodecopies(rawcopies) | |
|
309 | ||
|
310 | @property | |
|
289 | 311 | def description(self): |
|
290 | 312 | return encoding.tolocal(self._text[self._offsets[3] + 2:]) |
|
291 | 313 |
@@ -441,6 +441,21 b' class changectx(basectx):' | |||
|
441 | 441 | return self._changeset.files |
|
442 | 442 | @propertycache |
|
443 | 443 | def _copies(self): |
|
444 | source = self._repo.ui.config('experimental', 'copies.read-from') | |
|
445 | p1copies = self._changeset.p1copies | |
|
446 | p2copies = self._changeset.p2copies | |
|
447 | # If config says to get copy metadata only from changeset, then return | |
|
448 | # that, defaulting to {} if there was no copy metadata. | |
|
449 | # In compatibility mode, we return copy data from the changeset if | |
|
450 | # it was recorded there, and otherwise we fall back to getting it from | |
|
451 | # the filelogs (below). | |
|
452 | if (source == 'changeset-only' or | |
|
453 | (source == 'compatibility' and p1copies is not None)): | |
|
454 | return p1copies or {}, p2copies or {} | |
|
455 | ||
|
456 | # Otherwise (config said to read only from filelog, or we are in | |
|
457 | # compatiblity mode and there is not data in the changeset), we get | |
|
458 | # the copy metadata from the filelogs. | |
|
444 | 459 | p1copies = {} |
|
445 | 460 | p2copies = {} |
|
446 | 461 | p1 = self.p1() |
@@ -162,8 +162,8 b' def _computeforwardmissing(a, b, match=N' | |||
|
162 | 162 | |
|
163 | 163 | def usechangesetcentricalgo(repo): |
|
164 | 164 | """Checks if we should use changeset-centric copy algorithms""" |
|
165 |
return (repo.ui.config('experimental', 'copies.read-from') |
|
|
166 | 'compatibility') | |
|
165 | return (repo.ui.config('experimental', 'copies.read-from') in | |
|
166 | ('changeset-only', 'compatibility')) | |
|
167 | 167 | |
|
168 | 168 | def _committedforwardcopies(a, b, match): |
|
169 | 169 | """Like _forwardcopies(), but b.rev() cannot be None (working copy)""" |
@@ -2,9 +2,11 b'' | |||
|
2 | 2 | $ cat >> $HGRCPATH << EOF |
|
3 | 3 | > [experimental] |
|
4 | 4 | > copies.write-to=changeset-only |
|
5 | > copies.read-from=changeset-only | |
|
5 | 6 | > [alias] |
|
6 | 7 | > changesetcopies = log -r . -T 'files: {files} |
|
7 | 8 | > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' |
|
9 | > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}' | |
|
8 | 10 | > EOF |
|
9 | 11 | |
|
10 | 12 | Check that copies are recorded correctly |
@@ -23,6 +25,15 b' Check that copies are recorded correctly' | |||
|
23 | 25 | p1copies: b\x00a (esc) |
|
24 | 26 | c\x00a (esc) |
|
25 | 27 | d\x00a (esc) |
|
28 | $ hg showcopies | |
|
29 | a -> b | |
|
30 | a -> c | |
|
31 | a -> d | |
|
32 | $ hg showcopies --config experimental.copies.read-from=compatibility | |
|
33 | a -> b | |
|
34 | a -> c | |
|
35 | a -> d | |
|
36 | $ hg showcopies --config experimental.copies.read-from=filelog-only | |
|
26 | 37 | |
|
27 | 38 | Check that renames are recorded correctly |
|
28 | 39 | |
@@ -31,6 +42,8 b' Check that renames are recorded correctl' | |||
|
31 | 42 | $ hg changesetcopies |
|
32 | 43 | files: b b2 |
|
33 | 44 | p1copies: b2\x00b (esc) |
|
45 | $ hg showcopies | |
|
46 | b -> b2 | |
|
34 | 47 | |
|
35 | 48 | Rename onto existing file. This should get recorded in the changeset files list and in the extras, |
|
36 | 49 | even though there is no filelog entry. |
@@ -46,6 +59,8 b' even though there is no filelog entry.' | |||
|
46 | 59 | $ hg changesetcopies |
|
47 | 60 | files: c |
|
48 | 61 | p1copies: c\x00b2 (esc) |
|
62 | $ hg showcopies | |
|
63 | b2 -> c | |
|
49 | 64 | $ hg debugindex c |
|
50 | 65 | rev linkrev nodeid p1 p2 |
|
51 | 66 | 0 1 b789fdd96dc2 000000000000 000000000000 |
@@ -74,6 +89,10 b" File 'f' exists only in p1, so 'i' shoul" | |||
|
74 | 89 | p1copies: g\x00a (esc) |
|
75 | 90 | i\x00f (esc) |
|
76 | 91 | p2copies: h\x00d (esc) |
|
92 | $ hg showcopies | |
|
93 | a -> g | |
|
94 | d -> h | |
|
95 | f -> i | |
|
77 | 96 | |
|
78 | 97 | Test writing to both changeset and filelog |
|
79 | 98 | |
@@ -88,6 +107,12 b' Test writing to both changeset and filel' | |||
|
88 | 107 | copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 |
|
89 | 108 | \x01 (esc) |
|
90 | 109 | a |
|
110 | $ hg showcopies | |
|
111 | a -> j | |
|
112 | $ hg showcopies --config experimental.copies.read-from=compatibility | |
|
113 | a -> j | |
|
114 | $ hg showcopies --config experimental.copies.read-from=filelog-only | |
|
115 | a -> j | |
|
91 | 116 | |
|
92 | 117 | Test writing only to filelog |
|
93 | 118 | |
@@ -101,5 +126,10 b' Test writing only to filelog' | |||
|
101 | 126 | copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 |
|
102 | 127 | \x01 (esc) |
|
103 | 128 | a |
|
129 | $ hg showcopies | |
|
130 | $ hg showcopies --config experimental.copies.read-from=compatibility | |
|
131 | a -> k | |
|
132 | $ hg showcopies --config experimental.copies.read-from=filelog-only | |
|
133 | a -> k | |
|
104 | 134 | |
|
105 | 135 | $ cd .. |
@@ -1,4 +1,4 b'' | |||
|
1 | #testcases filelog compatibility | |
|
1 | #testcases filelog compatibility changeset | |
|
2 | 2 | |
|
3 | 3 | $ cat >> $HGRCPATH << EOF |
|
4 | 4 | > [extensions] |
@@ -14,6 +14,14 b'' | |||
|
14 | 14 | > EOF |
|
15 | 15 | #endif |
|
16 | 16 | |
|
17 | #if changeset | |
|
18 | $ cat >> $HGRCPATH << EOF | |
|
19 | > [experimental] | |
|
20 | > copies.read-from = changeset-only | |
|
21 | > copies.write-to = changeset-only | |
|
22 | > EOF | |
|
23 | #endif | |
|
24 | ||
|
17 | 25 | $ REPONUM=0 |
|
18 | 26 | $ newrepo() { |
|
19 | 27 | > cd $TESTTMP |
@@ -376,11 +384,13 b' Copy file that exists on both sides of t' | |||
|
376 | 384 | o 0 add x on branch 1 |
|
377 | 385 | x |
|
378 | 386 | $ hg debugp1copies -r 2 |
|
387 | x -> z (changeset !) | |
|
379 | 388 | $ hg debugp2copies -r 2 |
|
380 | x -> z | |
|
389 | x -> z (no-changeset !) | |
|
381 | 390 | $ hg debugpathcopies 1 2 |
|
391 | x -> z (changeset !) | |
|
382 | 392 | $ hg debugpathcopies 0 2 |
|
383 | x -> z | |
|
393 | x -> z (no-changeset !) | |
|
384 | 394 | |
|
385 | 395 | Copy x->y on one side of merge and copy x->z on the other side. Pathcopies from one parent |
|
386 | 396 | of the merge to the merge should include the copy from the other side. |
@@ -539,6 +549,9 b' test reflect that for this particular ca' | |||
|
539 | 549 | |
|
540 | 550 | Grafting revision 4 on top of revision 2, showing that it respect the rename: |
|
541 | 551 | |
|
552 | TODO: Make this work with copy info in changesets (probably by writing a | |
|
553 | changeset-centric version of copies.mergecopies()) | |
|
554 | #if no-changeset | |
|
542 | 555 | $ hg up 2 -q |
|
543 | 556 | $ hg graft -r 4 --base 3 --hidden |
|
544 | 557 | grafting 4:af28412ec03c "added d, modified b" (tip) |
@@ -554,6 +567,8 b' Grafting revision 4 on top of revision 2' | |||
|
554 | 567 | b |
|
555 | 568 | +baba |
|
556 | 569 | |
|
570 | #endif | |
|
571 | ||
|
557 | 572 | Test to make sure that fullcopytracing algorithm don't fail when both the merging csets are dirty |
|
558 | 573 | (a dirty cset is one who is not the descendant of merge base) |
|
559 | 574 | ------------------------------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now