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