Show More
@@ -99,6 +99,14 b' def decodecopies(data):' | |||
|
99 | 99 | # used different syntax for the value. |
|
100 | 100 | return None |
|
101 | 101 | |
|
102 | def encodefileindices(files, subset): | |
|
103 | subset = set(subset) | |
|
104 | indices = [] | |
|
105 | for i, f in enumerate(files): | |
|
106 | if f in subset: | |
|
107 | indices.append('%d' % i) | |
|
108 | return '\0'.join(indices) | |
|
109 | ||
|
102 | 110 | def stripdesc(desc): |
|
103 | 111 | """strip trailing whitespace and leading and trailing empty lines""" |
|
104 | 112 | return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') |
@@ -564,7 +572,8 b' class changelog(revlog.revlog):' | |||
|
564 | 572 | return l[3:] |
|
565 | 573 | |
|
566 | 574 | def add(self, manifest, files, desc, transaction, p1, p2, |
|
567 |
user, date=None, extra=None, p1copies=None, p2copies=None |
|
|
575 | user, date=None, extra=None, p1copies=None, p2copies=None, | |
|
576 | filesadded=None, filesremoved=None): | |
|
568 | 577 | # Convert to UTF-8 encoded bytestrings as the very first |
|
569 | 578 | # thing: calling any method on a localstr object will turn it |
|
570 | 579 | # into a str object and the cached UTF-8 string is thus lost. |
@@ -593,17 +602,23 b' class changelog(revlog.revlog):' | |||
|
593 | 602 | elif branch in (".", "null", "tip"): |
|
594 | 603 | raise error.StorageError(_('the name \'%s\' is reserved') |
|
595 | 604 | % branch) |
|
596 | if (p1copies is not None or p2copies is not None) and extra is None: | |
|
605 | extrasentries = p1copies, p2copies, filesadded, filesremoved | |
|
606 | if extra is None and any(x is not None for x in extrasentries): | |
|
597 | 607 | extra = {} |
|
598 | 608 | if p1copies is not None: |
|
599 | 609 | extra['p1copies'] = encodecopies(p1copies) |
|
600 | 610 | if p2copies is not None: |
|
601 | 611 | extra['p2copies'] = encodecopies(p2copies) |
|
612 | sortedfiles = sorted(files) | |
|
613 | if filesadded is not None: | |
|
614 | extra['filesadded'] = encodefileindices(sortedfiles, filesadded) | |
|
615 | if filesremoved is not None: | |
|
616 | extra['filesremoved'] = encodefileindices(sortedfiles, filesremoved) | |
|
602 | 617 | |
|
603 | 618 | if extra: |
|
604 | 619 | extra = encodeextra(extra) |
|
605 | 620 | parseddate = "%s %s" % (parseddate, extra) |
|
606 |
l = [hex(manifest), user, parseddate] + sorted |
|
|
621 | l = [hex(manifest), user, parseddate] + sortedfiles + ["", desc] | |
|
607 | 622 | text = "\n".join(l) |
|
608 | 623 | return self.addrevision(text, transaction, len(self), p1, p2) |
|
609 | 624 |
@@ -2589,10 +2589,13 b' class localrepository(object):' | |||
|
2589 | 2589 | |
|
2590 | 2590 | writecopiesto = self.ui.config('experimental', 'copies.write-to') |
|
2591 | 2591 | writefilecopymeta = writecopiesto != 'changeset-only' |
|
2592 | writechangesetcopy = (writecopiesto in | |
|
2593 | ('changeset-only', 'compatibility')) | |
|
2592 | 2594 | p1copies, p2copies = None, None |
|
2593 |
if writec |
|
|
2595 | if writechangesetcopy: | |
|
2594 | 2596 | p1copies = ctx.p1copies() |
|
2595 | 2597 | p2copies = ctx.p2copies() |
|
2598 | filesadded, filesremoved = None, None | |
|
2596 | 2599 | with self.lock(), self.transaction("commit") as tr: |
|
2597 | 2600 | trp = weakref.proxy(tr) |
|
2598 | 2601 | |
@@ -2601,6 +2604,9 b' class localrepository(object):' | |||
|
2601 | 2604 | self.ui.debug('reusing known manifest\n') |
|
2602 | 2605 | mn = ctx.manifestnode() |
|
2603 | 2606 | files = ctx.files() |
|
2607 | if writechangesetcopy: | |
|
2608 | filesadded = ctx.filesadded() | |
|
2609 | filesremoved = ctx.filesremoved() | |
|
2604 | 2610 | elif ctx.files(): |
|
2605 | 2611 | m1ctx = p1.manifestctx() |
|
2606 | 2612 | m2ctx = p2.manifestctx() |
@@ -2667,6 +2673,11 b' class localrepository(object):' | |||
|
2667 | 2673 | mn = mctx.write(trp, linkrev, |
|
2668 | 2674 | p1.manifestnode(), p2.manifestnode(), |
|
2669 | 2675 | added, drop, match=self.narrowmatch()) |
|
2676 | ||
|
2677 | if writechangesetcopy: | |
|
2678 | filesadded = [f for f in changed | |
|
2679 | if not (f in m1 or f in m2)] | |
|
2680 | filesremoved = removed | |
|
2670 | 2681 | else: |
|
2671 | 2682 | self.ui.debug('reusing manifest from p1 (listed files ' |
|
2672 | 2683 | 'actually unchanged)\n') |
@@ -2683,6 +2694,8 b' class localrepository(object):' | |||
|
2683 | 2694 | # filelogs. |
|
2684 | 2695 | p1copies = p1copies or None |
|
2685 | 2696 | p2copies = p2copies or None |
|
2697 | filesadded = filesadded or None | |
|
2698 | filesremoved = filesremoved or None | |
|
2686 | 2699 | |
|
2687 | 2700 | # update changelog |
|
2688 | 2701 | self.ui.note(_("committing changelog\n")) |
@@ -2690,7 +2703,7 b' class localrepository(object):' | |||
|
2690 | 2703 | n = self.changelog.add(mn, files, ctx.description(), |
|
2691 | 2704 | trp, p1.node(), p2.node(), |
|
2692 | 2705 | user, ctx.date(), ctx.extra().copy(), |
|
2693 | p1copies, p2copies) | |
|
2706 | p1copies, p2copies, filesadded, filesremoved) | |
|
2694 | 2707 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
2695 | 2708 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
2696 | 2709 | parent2=xp2) |
@@ -5,6 +5,7 b'' | |||
|
5 | 5 | > copies.read-from=changeset-only |
|
6 | 6 | > [alias] |
|
7 | 7 | > changesetcopies = log -r . -T 'files: {files} |
|
8 | > {extras % "{ifcontains("files", key, "{key}: {value}\n")}"} | |
|
8 | 9 | > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' |
|
9 | 10 | > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}' |
|
10 | 11 | > [extensions] |
@@ -24,6 +25,8 b' Check that copies are recorded correctly' | |||
|
24 | 25 | $ hg ci -m 'copy a to b, c, and d' |
|
25 | 26 | $ hg changesetcopies |
|
26 | 27 | files: b c d |
|
28 | filesadded: 0\x001\x002 (esc) | |
|
29 | ||
|
27 | 30 | p1copies: b\x00a (esc) |
|
28 | 31 | c\x00a (esc) |
|
29 | 32 | d\x00a (esc) |
@@ -43,6 +46,9 b' Check that renames are recorded correctl' | |||
|
43 | 46 | $ hg ci -m 'rename b to b2' |
|
44 | 47 | $ hg changesetcopies |
|
45 | 48 | files: b b2 |
|
49 | filesadded: 1 | |
|
50 | filesremoved: 0 | |
|
51 | ||
|
46 | 52 | p1copies: b2\x00b (esc) |
|
47 | 53 | $ hg showcopies |
|
48 | 54 | b -> b2 |
@@ -60,6 +66,7 b' even though there is no filelog entry.' | |||
|
60 | 66 | $ hg ci -m 'move b onto d' |
|
61 | 67 | $ hg changesetcopies |
|
62 | 68 | files: c |
|
69 | ||
|
63 | 70 | p1copies: c\x00b2 (esc) |
|
64 | 71 | $ hg showcopies |
|
65 | 72 | b2 -> c |
@@ -88,6 +95,8 b" File 'f' exists only in p1, so 'i' shoul" | |||
|
88 | 95 | $ hg ci -m 'merge' |
|
89 | 96 | $ hg changesetcopies |
|
90 | 97 | files: g h i |
|
98 | filesadded: 0\x001\x002 (esc) | |
|
99 | ||
|
91 | 100 | p1copies: g\x00a (esc) |
|
92 | 101 | i\x00f (esc) |
|
93 | 102 | p2copies: h\x00d (esc) |
@@ -102,6 +111,9 b' Test writing to both changeset and filel' | |||
|
102 | 111 | $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility |
|
103 | 112 | $ hg changesetcopies |
|
104 | 113 | files: j |
|
114 | filesadded: 0 | |
|
115 | filesremoved: | |
|
116 | ||
|
105 | 117 | p1copies: j\x00a (esc) |
|
106 | 118 | p2copies: |
|
107 | 119 | $ hg debugdata j 0 |
@@ -122,6 +134,9 b" won't have to fall back to reading from " | |||
|
122 | 134 | $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility |
|
123 | 135 | $ hg changesetcopies |
|
124 | 136 | files: j |
|
137 | filesadded: | |
|
138 | filesremoved: | |
|
139 | ||
|
125 | 140 | p1copies: |
|
126 | 141 | p2copies: |
|
127 | 142 | |
@@ -131,6 +146,7 b' Test writing only to filelog' | |||
|
131 | 146 | $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only |
|
132 | 147 | $ hg changesetcopies |
|
133 | 148 | files: k |
|
149 | ||
|
134 | 150 | $ hg debugdata k 0 |
|
135 | 151 | \x01 (esc) |
|
136 | 152 | copy: a |
@@ -157,9 +173,9 b' Test rebasing a commit with copy informa' | |||
|
157 | 173 | $ hg mv a b |
|
158 | 174 | $ hg ci -qm 'rename a to b' |
|
159 | 175 | $ hg rebase -d 1 --config rebase.experimental.inmemory=yes |
|
160 |
rebasing 2: |
|
|
176 | rebasing 2:acfc33f3aa6d "rename a to b" (tip) | |
|
161 | 177 | merging a and b to b |
|
162 |
saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/ |
|
|
178 | saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/acfc33f3aa6d-81d0180d-rebase.hg | |
|
163 | 179 | $ hg st --change . --copies |
|
164 | 180 | A b |
|
165 | 181 | a |
@@ -551,14 +551,15 b' Grafting revision 4 on top of revision 2' | |||
|
551 | 551 | |
|
552 | 552 | $ hg up 2 -q |
|
553 | 553 | $ hg graft -r 4 --base 3 --hidden |
|
554 | grafting 4:af28412ec03c "added d, modified b" (tip) | |
|
554 | grafting 4:af28412ec03c "added d, modified b" (tip) (no-changeset !) | |
|
555 | grafting 4:6325ca0b7a1c "added d, modified b" (tip) (changeset !) | |
|
555 | 556 | merging b1 and b to b1 |
|
556 | 557 | |
|
557 | 558 | $ hg l -l1 -p |
|
558 | 559 | @ 5 added d, modified b |
|
559 | 560 | | b1 |
|
560 | 561 | ~ diff -r 5a4825cc2926 -r 94a2f1a0e8e2 b1 (no-changeset !) |
|
561 |
~ diff -r |
|
|
562 | ~ diff -r df722b7fe2d5 -r ba3ddbbdfd96 b1 (changeset !) | |
|
562 | 563 | --- a/b1 Thu Jan 01 00:00:00 1970 +0000 |
|
563 | 564 | +++ b/b1 Thu Jan 01 00:00:00 1970 +0000 |
|
564 | 565 | @@ -1,1 +1,2 @@ |
@@ -618,7 +619,8 b' merging csets is a descendant of the bas' | |||
|
618 | 619 | a |
|
619 | 620 | |
|
620 | 621 | $ hg rebase -r . -d 2 -t :other |
|
621 | rebasing 5:5018b1509e94 "added willconflict and d" (tip) | |
|
622 | rebasing 5:5018b1509e94 "added willconflict and d" (tip) (no-changeset !) | |
|
623 | rebasing 5:619047c26bf8 "added willconflict and d" (tip) (changeset !) | |
|
622 | 624 | |
|
623 | 625 | $ hg up 3 -q |
|
624 | 626 | $ hg l --hidden |
@@ -641,4 +643,5 b' Now if we trigger a merge between revisi' | |||
|
641 | 643 | neither of the merging csets will be a descendant of the base revision: |
|
642 | 644 | |
|
643 | 645 | $ hg graft -r 6 --base 4 --hidden -t :other |
|
644 | grafting 6:99802e4f1e46 "added willconflict and d" (tip) | |
|
646 | grafting 6:99802e4f1e46 "added willconflict and d" (tip) (no-changeset !) | |
|
647 | grafting 6:9ddc6fb3b691 "added willconflict and d" (tip) (changeset !) |
General Comments 0
You need to be logged in to leave comments.
Login now