Show More
@@ -1,216 +1,222 | |||
|
1 | 1 | # repair.py - functions for repository repair for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Chris Mason <mason@suse.com> |
|
4 | 4 | # Copyright 2007 Matt Mackall |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | from mercurial import changegroup, exchange, util, bundle2 |
|
10 | 10 | from mercurial.node import short, hex |
|
11 | 11 | from mercurial.i18n import _ |
|
12 | 12 | import errno |
|
13 | 13 | |
|
14 | 14 | def _bundle(repo, bases, heads, node, suffix, compress=True): |
|
15 | 15 | """create a bundle with the specified revisions as a backup""" |
|
16 | 16 | usebundle2 = (repo.ui.config('experimental', 'bundle2-exp') and |
|
17 | 17 | repo.ui.config('experimental', 'strip-bundle2-version')) |
|
18 | 18 | if usebundle2: |
|
19 | 19 | cgversion = repo.ui.config('experimental', 'strip-bundle2-version') |
|
20 | if cgversion not in changegroup.packermap: | |
|
21 | repo.ui.warn(_('unknown strip-bundle2-version value %r; ' + | |
|
22 | 'should be one of %r\n') % | |
|
23 | (cgversion, sorted(changegroup.packermap.keys()),)) | |
|
24 | cgversion = '01' | |
|
25 | usebundle2 = False | |
|
20 | 26 | else: |
|
21 | 27 | cgversion = '01' |
|
22 | 28 | |
|
23 | 29 | cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', |
|
24 | 30 | version=cgversion) |
|
25 | 31 | backupdir = "strip-backup" |
|
26 | 32 | vfs = repo.vfs |
|
27 | 33 | if not vfs.isdir(backupdir): |
|
28 | 34 | vfs.mkdir(backupdir) |
|
29 | 35 | |
|
30 | 36 | # Include a hash of all the nodes in the filename for uniqueness |
|
31 | 37 | hexbases = (hex(n) for n in bases) |
|
32 | 38 | hexheads = (hex(n) for n in heads) |
|
33 | 39 | allcommits = repo.set('%ls::%ls', hexbases, hexheads) |
|
34 | 40 | allhashes = sorted(c.hex() for c in allcommits) |
|
35 | 41 | totalhash = util.sha1(''.join(allhashes)).hexdigest() |
|
36 | 42 | name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) |
|
37 | 43 | |
|
38 | 44 | if usebundle2: |
|
39 | 45 | bundletype = "HG2Y" |
|
40 | 46 | elif compress: |
|
41 | 47 | bundletype = "HG10BZ" |
|
42 | 48 | else: |
|
43 | 49 | bundletype = "HG10UN" |
|
44 | 50 | return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs) |
|
45 | 51 | |
|
46 | 52 | def _collectfiles(repo, striprev): |
|
47 | 53 | """find out the filelogs affected by the strip""" |
|
48 | 54 | files = set() |
|
49 | 55 | |
|
50 | 56 | for x in xrange(striprev, len(repo)): |
|
51 | 57 | files.update(repo[x].files()) |
|
52 | 58 | |
|
53 | 59 | return sorted(files) |
|
54 | 60 | |
|
55 | 61 | def _collectbrokencsets(repo, files, striprev): |
|
56 | 62 | """return the changesets which will be broken by the truncation""" |
|
57 | 63 | s = set() |
|
58 | 64 | def collectone(revlog): |
|
59 | 65 | _, brokenset = revlog.getstrippoint(striprev) |
|
60 | 66 | s.update([revlog.linkrev(r) for r in brokenset]) |
|
61 | 67 | |
|
62 | 68 | collectone(repo.manifest) |
|
63 | 69 | for fname in files: |
|
64 | 70 | collectone(repo.file(fname)) |
|
65 | 71 | |
|
66 | 72 | return s |
|
67 | 73 | |
|
68 | 74 | def strip(ui, repo, nodelist, backup=True, topic='backup'): |
|
69 | 75 | |
|
70 | 76 | # Simple way to maintain backwards compatibility for this |
|
71 | 77 | # argument. |
|
72 | 78 | if backup in ['none', 'strip']: |
|
73 | 79 | backup = False |
|
74 | 80 | |
|
75 | 81 | repo = repo.unfiltered() |
|
76 | 82 | repo.destroying() |
|
77 | 83 | |
|
78 | 84 | cl = repo.changelog |
|
79 | 85 | # TODO handle undo of merge sets |
|
80 | 86 | if isinstance(nodelist, str): |
|
81 | 87 | nodelist = [nodelist] |
|
82 | 88 | striplist = [cl.rev(node) for node in nodelist] |
|
83 | 89 | striprev = min(striplist) |
|
84 | 90 | |
|
85 | 91 | # Some revisions with rev > striprev may not be descendants of striprev. |
|
86 | 92 | # We have to find these revisions and put them in a bundle, so that |
|
87 | 93 | # we can restore them after the truncations. |
|
88 | 94 | # To create the bundle we use repo.changegroupsubset which requires |
|
89 | 95 | # the list of heads and bases of the set of interesting revisions. |
|
90 | 96 | # (head = revision in the set that has no descendant in the set; |
|
91 | 97 | # base = revision in the set that has no ancestor in the set) |
|
92 | 98 | tostrip = set(striplist) |
|
93 | 99 | for rev in striplist: |
|
94 | 100 | for desc in cl.descendants([rev]): |
|
95 | 101 | tostrip.add(desc) |
|
96 | 102 | |
|
97 | 103 | files = _collectfiles(repo, striprev) |
|
98 | 104 | saverevs = _collectbrokencsets(repo, files, striprev) |
|
99 | 105 | |
|
100 | 106 | # compute heads |
|
101 | 107 | saveheads = set(saverevs) |
|
102 | 108 | for r in xrange(striprev + 1, len(cl)): |
|
103 | 109 | if r not in tostrip: |
|
104 | 110 | saverevs.add(r) |
|
105 | 111 | saveheads.difference_update(cl.parentrevs(r)) |
|
106 | 112 | saveheads.add(r) |
|
107 | 113 | saveheads = [cl.node(r) for r in saveheads] |
|
108 | 114 | |
|
109 | 115 | # compute base nodes |
|
110 | 116 | if saverevs: |
|
111 | 117 | descendants = set(cl.descendants(saverevs)) |
|
112 | 118 | saverevs.difference_update(descendants) |
|
113 | 119 | savebases = [cl.node(r) for r in saverevs] |
|
114 | 120 | stripbases = [cl.node(r) for r in tostrip] |
|
115 | 121 | |
|
116 | 122 | # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but |
|
117 | 123 | # is much faster |
|
118 | 124 | newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) |
|
119 | 125 | if newbmtarget: |
|
120 | 126 | newbmtarget = repo[newbmtarget.first()].node() |
|
121 | 127 | else: |
|
122 | 128 | newbmtarget = '.' |
|
123 | 129 | |
|
124 | 130 | bm = repo._bookmarks |
|
125 | 131 | updatebm = [] |
|
126 | 132 | for m in bm: |
|
127 | 133 | rev = repo[bm[m]].rev() |
|
128 | 134 | if rev in tostrip: |
|
129 | 135 | updatebm.append(m) |
|
130 | 136 | |
|
131 | 137 | # create a changegroup for all the branches we need to keep |
|
132 | 138 | backupfile = None |
|
133 | 139 | vfs = repo.vfs |
|
134 | 140 | if backup: |
|
135 | 141 | backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) |
|
136 | 142 | repo.ui.status(_("saved backup bundle to %s\n") % |
|
137 | 143 | vfs.join(backupfile)) |
|
138 | 144 | repo.ui.log("backupbundle", "saved backup bundle to %s\n", |
|
139 | 145 | vfs.join(backupfile)) |
|
140 | 146 | if saveheads or savebases: |
|
141 | 147 | # do not compress partial bundle if we remove it from disk later |
|
142 | 148 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', |
|
143 | 149 | compress=False) |
|
144 | 150 | |
|
145 | 151 | mfst = repo.manifest |
|
146 | 152 | |
|
147 | 153 | tr = repo.transaction("strip") |
|
148 | 154 | offset = len(tr.entries) |
|
149 | 155 | |
|
150 | 156 | try: |
|
151 | 157 | tr.startgroup() |
|
152 | 158 | cl.strip(striprev, tr) |
|
153 | 159 | mfst.strip(striprev, tr) |
|
154 | 160 | for fn in files: |
|
155 | 161 | repo.file(fn).strip(striprev, tr) |
|
156 | 162 | tr.endgroup() |
|
157 | 163 | |
|
158 | 164 | try: |
|
159 | 165 | for i in xrange(offset, len(tr.entries)): |
|
160 | 166 | file, troffset, ignore = tr.entries[i] |
|
161 | 167 | repo.svfs(file, 'a').truncate(troffset) |
|
162 | 168 | if troffset == 0: |
|
163 | 169 | repo.store.markremoved(file) |
|
164 | 170 | tr.close() |
|
165 | 171 | except: # re-raises |
|
166 | 172 | tr.abort() |
|
167 | 173 | raise |
|
168 | 174 | |
|
169 | 175 | if saveheads or savebases: |
|
170 | 176 | ui.note(_("adding branch\n")) |
|
171 | 177 | f = vfs.open(chgrpfile, "rb") |
|
172 | 178 | gen = exchange.readbundle(ui, f, chgrpfile, vfs) |
|
173 | 179 | if not repo.ui.verbose: |
|
174 | 180 | # silence internal shuffling chatter |
|
175 | 181 | repo.ui.pushbuffer() |
|
176 | 182 | if isinstance(gen, bundle2.unbundle20): |
|
177 | 183 | tr = repo.transaction('strip') |
|
178 | 184 | try: |
|
179 | 185 | bundle2.processbundle(repo, gen, lambda: tr) |
|
180 | 186 | tr.close() |
|
181 | 187 | finally: |
|
182 | 188 | tr.release() |
|
183 | 189 | else: |
|
184 | 190 | changegroup.addchangegroup(repo, gen, 'strip', |
|
185 | 191 | 'bundle:' + vfs.join(chgrpfile), |
|
186 | 192 | True) |
|
187 | 193 | if not repo.ui.verbose: |
|
188 | 194 | repo.ui.popbuffer() |
|
189 | 195 | f.close() |
|
190 | 196 | |
|
191 | 197 | # remove undo files |
|
192 | 198 | for undovfs, undofile in repo.undofiles(): |
|
193 | 199 | try: |
|
194 | 200 | undovfs.unlink(undofile) |
|
195 | 201 | except OSError, e: |
|
196 | 202 | if e.errno != errno.ENOENT: |
|
197 | 203 | ui.warn(_('error removing %s: %s\n') % |
|
198 | 204 | (undovfs.join(undofile), str(e))) |
|
199 | 205 | |
|
200 | 206 | for m in updatebm: |
|
201 | 207 | bm[m] = repo[newbmtarget].node() |
|
202 | 208 | bm.write() |
|
203 | 209 | except: # re-raises |
|
204 | 210 | if backupfile: |
|
205 | 211 | ui.warn(_("strip failed, full bundle stored in '%s'\n") |
|
206 | 212 | % vfs.join(backupfile)) |
|
207 | 213 | elif saveheads: |
|
208 | 214 | ui.warn(_("strip failed, partial bundle stored in '%s'\n") |
|
209 | 215 | % vfs.join(chgrpfile)) |
|
210 | 216 | raise |
|
211 | 217 | else: |
|
212 | 218 | if saveheads or savebases: |
|
213 | 219 | # Remove partial backup only if there were no exceptions |
|
214 | 220 | vfs.unlink(chgrpfile) |
|
215 | 221 | |
|
216 | 222 | repo.destroyed() |
@@ -1,595 +1,605 | |||
|
1 | 1 | $ echo "[extensions]" >> $HGRCPATH |
|
2 | 2 | $ echo "strip=" >> $HGRCPATH |
|
3 | 3 | |
|
4 | 4 | $ restore() { |
|
5 | 5 | > hg unbundle -q .hg/strip-backup/* |
|
6 | 6 | > rm .hg/strip-backup/* |
|
7 | 7 | > } |
|
8 | 8 | $ teststrip() { |
|
9 | 9 | > hg up -C $1 |
|
10 | 10 | > echo % before update $1, strip $2 |
|
11 | 11 | > hg parents |
|
12 | 12 | > hg --traceback strip $2 |
|
13 | 13 | > echo % after update $1, strip $2 |
|
14 | 14 | > hg parents |
|
15 | 15 | > restore |
|
16 | 16 | > } |
|
17 | 17 | |
|
18 | 18 | $ hg init test |
|
19 | 19 | $ cd test |
|
20 | 20 | |
|
21 | 21 | $ echo foo > bar |
|
22 | 22 | $ hg ci -Ama |
|
23 | 23 | adding bar |
|
24 | 24 | |
|
25 | 25 | $ echo more >> bar |
|
26 | 26 | $ hg ci -Amb |
|
27 | 27 | |
|
28 | 28 | $ echo blah >> bar |
|
29 | 29 | $ hg ci -Amc |
|
30 | 30 | |
|
31 | 31 | $ hg up 1 |
|
32 | 32 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
33 | 33 | $ echo blah >> bar |
|
34 | 34 | $ hg ci -Amd |
|
35 | 35 | created new head |
|
36 | 36 | |
|
37 | 37 | $ echo final >> bar |
|
38 | 38 | $ hg ci -Ame |
|
39 | 39 | |
|
40 | 40 | $ hg log |
|
41 | 41 | changeset: 4:443431ffac4f |
|
42 | 42 | tag: tip |
|
43 | 43 | user: test |
|
44 | 44 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
45 | 45 | summary: e |
|
46 | 46 | |
|
47 | 47 | changeset: 3:65bd5f99a4a3 |
|
48 | 48 | parent: 1:ef3a871183d7 |
|
49 | 49 | user: test |
|
50 | 50 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
51 | 51 | summary: d |
|
52 | 52 | |
|
53 | 53 | changeset: 2:264128213d29 |
|
54 | 54 | user: test |
|
55 | 55 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
56 | 56 | summary: c |
|
57 | 57 | |
|
58 | 58 | changeset: 1:ef3a871183d7 |
|
59 | 59 | user: test |
|
60 | 60 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
61 | 61 | summary: b |
|
62 | 62 | |
|
63 | 63 | changeset: 0:9ab35a2d17cb |
|
64 | 64 | user: test |
|
65 | 65 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
66 | 66 | summary: a |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | $ teststrip 4 4 |
|
70 | 70 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
71 | 71 | % before update 4, strip 4 |
|
72 | 72 | changeset: 4:443431ffac4f |
|
73 | 73 | tag: tip |
|
74 | 74 | user: test |
|
75 | 75 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
76 | 76 | summary: e |
|
77 | 77 | |
|
78 | 78 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
79 | 79 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
80 | 80 | % after update 4, strip 4 |
|
81 | 81 | changeset: 3:65bd5f99a4a3 |
|
82 | 82 | tag: tip |
|
83 | 83 | parent: 1:ef3a871183d7 |
|
84 | 84 | user: test |
|
85 | 85 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
86 | 86 | summary: d |
|
87 | 87 | |
|
88 | 88 | $ teststrip 4 3 |
|
89 | 89 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 | 90 | % before update 4, strip 3 |
|
91 | 91 | changeset: 4:443431ffac4f |
|
92 | 92 | tag: tip |
|
93 | 93 | user: test |
|
94 | 94 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
95 | 95 | summary: e |
|
96 | 96 | |
|
97 | 97 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
98 | 98 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
99 | 99 | % after update 4, strip 3 |
|
100 | 100 | changeset: 1:ef3a871183d7 |
|
101 | 101 | user: test |
|
102 | 102 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
103 | 103 | summary: b |
|
104 | 104 | |
|
105 | 105 | $ teststrip 1 4 |
|
106 | 106 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
107 | 107 | % before update 1, strip 4 |
|
108 | 108 | changeset: 1:ef3a871183d7 |
|
109 | 109 | user: test |
|
110 | 110 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
111 | 111 | summary: b |
|
112 | 112 | |
|
113 | 113 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
114 | 114 | % after update 1, strip 4 |
|
115 | 115 | changeset: 1:ef3a871183d7 |
|
116 | 116 | user: test |
|
117 | 117 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
118 | 118 | summary: b |
|
119 | 119 | |
|
120 | 120 | $ teststrip 4 2 |
|
121 | 121 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
122 | 122 | % before update 4, strip 2 |
|
123 | 123 | changeset: 4:443431ffac4f |
|
124 | 124 | tag: tip |
|
125 | 125 | user: test |
|
126 | 126 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
127 | 127 | summary: e |
|
128 | 128 | |
|
129 | 129 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
130 | 130 | % after update 4, strip 2 |
|
131 | 131 | changeset: 3:443431ffac4f |
|
132 | 132 | tag: tip |
|
133 | 133 | user: test |
|
134 | 134 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
135 | 135 | summary: e |
|
136 | 136 | |
|
137 | 137 | $ teststrip 4 1 |
|
138 | 138 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
139 | 139 | % before update 4, strip 1 |
|
140 | 140 | changeset: 4:264128213d29 |
|
141 | 141 | tag: tip |
|
142 | 142 | parent: 1:ef3a871183d7 |
|
143 | 143 | user: test |
|
144 | 144 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
145 | 145 | summary: c |
|
146 | 146 | |
|
147 | 147 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
148 | 148 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
149 | 149 | % after update 4, strip 1 |
|
150 | 150 | changeset: 0:9ab35a2d17cb |
|
151 | 151 | tag: tip |
|
152 | 152 | user: test |
|
153 | 153 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
154 | 154 | summary: a |
|
155 | 155 | |
|
156 | 156 | $ teststrip null 4 |
|
157 | 157 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
158 | 158 | % before update null, strip 4 |
|
159 | 159 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
160 | 160 | % after update null, strip 4 |
|
161 | 161 | |
|
162 | 162 | $ hg log |
|
163 | 163 | changeset: 4:264128213d29 |
|
164 | 164 | tag: tip |
|
165 | 165 | parent: 1:ef3a871183d7 |
|
166 | 166 | user: test |
|
167 | 167 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
168 | 168 | summary: c |
|
169 | 169 | |
|
170 | 170 | changeset: 3:443431ffac4f |
|
171 | 171 | user: test |
|
172 | 172 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
173 | 173 | summary: e |
|
174 | 174 | |
|
175 | 175 | changeset: 2:65bd5f99a4a3 |
|
176 | 176 | user: test |
|
177 | 177 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
178 | 178 | summary: d |
|
179 | 179 | |
|
180 | 180 | changeset: 1:ef3a871183d7 |
|
181 | 181 | user: test |
|
182 | 182 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
183 | 183 | summary: b |
|
184 | 184 | |
|
185 | 185 | changeset: 0:9ab35a2d17cb |
|
186 | 186 | user: test |
|
187 | 187 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
188 | 188 | summary: a |
|
189 | 189 | |
|
190 | 190 | $ hg up -C 4 |
|
191 | 191 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
192 | 192 | $ hg parents |
|
193 | 193 | changeset: 4:264128213d29 |
|
194 | 194 | tag: tip |
|
195 | 195 | parent: 1:ef3a871183d7 |
|
196 | 196 | user: test |
|
197 | 197 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
198 | 198 | summary: c |
|
199 | 199 | |
|
200 | $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=INVALID strip 4 | |
|
201 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
202 | unknown strip-bundle2-version value 'INVALID'; should be one of ['01', '02'] | |
|
203 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) | |
|
204 | $ hg debugbundle .hg/strip-backup/* | |
|
205 | 264128213d290d868c54642d13aeaa3675551a78 | |
|
206 | $ restore | |
|
207 | ||
|
208 | $ hg up -C 4 | |
|
209 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
200 | 210 |
$ |
|
201 | 211 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
202 | 212 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) |
|
203 | 213 | $ hg parents |
|
204 | 214 | changeset: 1:ef3a871183d7 |
|
205 | 215 | user: test |
|
206 | 216 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
207 | 217 | summary: b |
|
208 | 218 | |
|
209 | 219 | $ hg debugbundle .hg/strip-backup/* |
|
210 | 220 | Stream params: {} |
|
211 | 221 | b2x:changegroup -- "{'version': '02'}" |
|
212 | 222 | 264128213d290d868c54642d13aeaa3675551a78 |
|
213 | 223 | $ restore |
|
214 | 224 | |
|
215 | 225 | $ hg up -C 2 |
|
216 | 226 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
217 | 227 | $ hg merge 4 |
|
218 | 228 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
219 | 229 | (branch merge, don't forget to commit) |
|
220 | 230 | |
|
221 | 231 | before strip of merge parent |
|
222 | 232 | |
|
223 | 233 | $ hg parents |
|
224 | 234 | changeset: 2:65bd5f99a4a3 |
|
225 | 235 | user: test |
|
226 | 236 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
227 | 237 | summary: d |
|
228 | 238 | |
|
229 | 239 | changeset: 4:264128213d29 |
|
230 | 240 | tag: tip |
|
231 | 241 | parent: 1:ef3a871183d7 |
|
232 | 242 | user: test |
|
233 | 243 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
234 | 244 | summary: c |
|
235 | 245 | |
|
236 | 246 | $ hg strip 4 |
|
237 | 247 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
238 | 248 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
239 | 249 | |
|
240 | 250 | after strip of merge parent |
|
241 | 251 | |
|
242 | 252 | $ hg parents |
|
243 | 253 | changeset: 1:ef3a871183d7 |
|
244 | 254 | user: test |
|
245 | 255 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
246 | 256 | summary: b |
|
247 | 257 | |
|
248 | 258 | $ restore |
|
249 | 259 | |
|
250 | 260 | $ hg up |
|
251 | 261 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
252 | 262 | $ hg log -G |
|
253 | 263 | @ changeset: 4:264128213d29 |
|
254 | 264 | | tag: tip |
|
255 | 265 | | parent: 1:ef3a871183d7 |
|
256 | 266 | | user: test |
|
257 | 267 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
258 | 268 | | summary: c |
|
259 | 269 | | |
|
260 | 270 | | o changeset: 3:443431ffac4f |
|
261 | 271 | | | user: test |
|
262 | 272 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
263 | 273 | | | summary: e |
|
264 | 274 | | | |
|
265 | 275 | | o changeset: 2:65bd5f99a4a3 |
|
266 | 276 | |/ user: test |
|
267 | 277 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
268 | 278 | | summary: d |
|
269 | 279 | | |
|
270 | 280 | o changeset: 1:ef3a871183d7 |
|
271 | 281 | | user: test |
|
272 | 282 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
273 | 283 | | summary: b |
|
274 | 284 | | |
|
275 | 285 | o changeset: 0:9ab35a2d17cb |
|
276 | 286 | user: test |
|
277 | 287 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
278 | 288 | summary: a |
|
279 | 289 | |
|
280 | 290 | |
|
281 | 291 | 2 is parent of 3, only one strip should happen |
|
282 | 292 | |
|
283 | 293 | $ hg strip "roots(2)" 3 |
|
284 | 294 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
285 | 295 | $ hg log -G |
|
286 | 296 | @ changeset: 2:264128213d29 |
|
287 | 297 | | tag: tip |
|
288 | 298 | | user: test |
|
289 | 299 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
290 | 300 | | summary: c |
|
291 | 301 | | |
|
292 | 302 | o changeset: 1:ef3a871183d7 |
|
293 | 303 | | user: test |
|
294 | 304 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
295 | 305 | | summary: b |
|
296 | 306 | | |
|
297 | 307 | o changeset: 0:9ab35a2d17cb |
|
298 | 308 | user: test |
|
299 | 309 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
300 | 310 | summary: a |
|
301 | 311 | |
|
302 | 312 | $ restore |
|
303 | 313 | $ hg log -G |
|
304 | 314 | o changeset: 4:443431ffac4f |
|
305 | 315 | | tag: tip |
|
306 | 316 | | user: test |
|
307 | 317 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
308 | 318 | | summary: e |
|
309 | 319 | | |
|
310 | 320 | o changeset: 3:65bd5f99a4a3 |
|
311 | 321 | | parent: 1:ef3a871183d7 |
|
312 | 322 | | user: test |
|
313 | 323 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
314 | 324 | | summary: d |
|
315 | 325 | | |
|
316 | 326 | | @ changeset: 2:264128213d29 |
|
317 | 327 | |/ user: test |
|
318 | 328 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
319 | 329 | | summary: c |
|
320 | 330 | | |
|
321 | 331 | o changeset: 1:ef3a871183d7 |
|
322 | 332 | | user: test |
|
323 | 333 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
324 | 334 | | summary: b |
|
325 | 335 | | |
|
326 | 336 | o changeset: 0:9ab35a2d17cb |
|
327 | 337 | user: test |
|
328 | 338 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
329 | 339 | summary: a |
|
330 | 340 | |
|
331 | 341 | |
|
332 | 342 | 2 different branches: 2 strips |
|
333 | 343 | |
|
334 | 344 | $ hg strip 2 4 |
|
335 | 345 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
336 | 346 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
337 | 347 | $ hg log -G |
|
338 | 348 | o changeset: 2:65bd5f99a4a3 |
|
339 | 349 | | tag: tip |
|
340 | 350 | | user: test |
|
341 | 351 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
342 | 352 | | summary: d |
|
343 | 353 | | |
|
344 | 354 | @ changeset: 1:ef3a871183d7 |
|
345 | 355 | | user: test |
|
346 | 356 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
347 | 357 | | summary: b |
|
348 | 358 | | |
|
349 | 359 | o changeset: 0:9ab35a2d17cb |
|
350 | 360 | user: test |
|
351 | 361 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
352 | 362 | summary: a |
|
353 | 363 | |
|
354 | 364 | $ restore |
|
355 | 365 | |
|
356 | 366 | 2 different branches and a common ancestor: 1 strip |
|
357 | 367 | |
|
358 | 368 | $ hg strip 1 "2|4" |
|
359 | 369 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
360 | 370 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
361 | 371 | $ restore |
|
362 | 372 | |
|
363 | 373 | verify fncache is kept up-to-date |
|
364 | 374 | |
|
365 | 375 | $ touch a |
|
366 | 376 | $ hg ci -qAm a |
|
367 | 377 | $ cat .hg/store/fncache | sort |
|
368 | 378 | data/a.i |
|
369 | 379 | data/bar.i |
|
370 | 380 | $ hg strip tip |
|
371 | 381 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
372 | 382 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
373 | 383 | $ cat .hg/store/fncache |
|
374 | 384 | data/bar.i |
|
375 | 385 | |
|
376 | 386 | stripping an empty revset |
|
377 | 387 | |
|
378 | 388 | $ hg strip "1 and not 1" |
|
379 | 389 | abort: empty revision set |
|
380 | 390 | [255] |
|
381 | 391 | |
|
382 | 392 | remove branchy history for qimport tests |
|
383 | 393 | |
|
384 | 394 | $ hg strip 3 |
|
385 | 395 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
386 | 396 | |
|
387 | 397 | |
|
388 | 398 | strip of applied mq should cleanup status file |
|
389 | 399 | |
|
390 | 400 | $ echo "mq=" >> $HGRCPATH |
|
391 | 401 | $ hg up -C 3 |
|
392 | 402 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
393 | 403 | $ echo fooagain >> bar |
|
394 | 404 | $ hg ci -mf |
|
395 | 405 | $ hg qimport -r tip:2 |
|
396 | 406 | |
|
397 | 407 | applied patches before strip |
|
398 | 408 | |
|
399 | 409 | $ hg qapplied |
|
400 | 410 | 2.diff |
|
401 | 411 | 3.diff |
|
402 | 412 | 4.diff |
|
403 | 413 | |
|
404 | 414 | stripping revision in queue |
|
405 | 415 | |
|
406 | 416 | $ hg strip 3 |
|
407 | 417 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
408 | 418 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
409 | 419 | |
|
410 | 420 | applied patches after stripping rev in queue |
|
411 | 421 | |
|
412 | 422 | $ hg qapplied |
|
413 | 423 | 2.diff |
|
414 | 424 | |
|
415 | 425 | stripping ancestor of queue |
|
416 | 426 | |
|
417 | 427 | $ hg strip 1 |
|
418 | 428 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
419 | 429 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
420 | 430 | |
|
421 | 431 | applied patches after stripping ancestor of queue |
|
422 | 432 | |
|
423 | 433 | $ hg qapplied |
|
424 | 434 | |
|
425 | 435 | Verify strip protects against stripping wc parent when there are uncommitted mods |
|
426 | 436 | |
|
427 | 437 | $ echo b > b |
|
428 | 438 | $ hg add b |
|
429 | 439 | $ hg ci -m 'b' |
|
430 | 440 | $ hg log --graph |
|
431 | 441 | @ changeset: 1:7519abd79d14 |
|
432 | 442 | | tag: tip |
|
433 | 443 | | user: test |
|
434 | 444 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
435 | 445 | | summary: b |
|
436 | 446 | | |
|
437 | 447 | o changeset: 0:9ab35a2d17cb |
|
438 | 448 | user: test |
|
439 | 449 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
440 | 450 | summary: a |
|
441 | 451 | |
|
442 | 452 | |
|
443 | 453 | $ echo c > b |
|
444 | 454 | $ echo c > bar |
|
445 | 455 | $ hg strip tip |
|
446 | 456 | abort: local changes found |
|
447 | 457 | [255] |
|
448 | 458 | $ hg strip tip --keep |
|
449 | 459 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
450 | 460 | $ hg log --graph |
|
451 | 461 | @ changeset: 0:9ab35a2d17cb |
|
452 | 462 | tag: tip |
|
453 | 463 | user: test |
|
454 | 464 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
455 | 465 | summary: a |
|
456 | 466 | |
|
457 | 467 | $ hg status |
|
458 | 468 | M bar |
|
459 | 469 | ? b |
|
460 | 470 | |
|
461 | 471 | Strip adds, removes, modifies with --keep |
|
462 | 472 | |
|
463 | 473 | $ touch b |
|
464 | 474 | $ hg add b |
|
465 | 475 | $ hg commit -mb |
|
466 | 476 | $ touch c |
|
467 | 477 | |
|
468 | 478 | ... with a clean working dir |
|
469 | 479 | |
|
470 | 480 | $ hg add c |
|
471 | 481 | $ hg rm bar |
|
472 | 482 | $ hg commit -mc |
|
473 | 483 | $ hg status |
|
474 | 484 | $ hg strip --keep tip |
|
475 | 485 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
476 | 486 | $ hg status |
|
477 | 487 | ! bar |
|
478 | 488 | ? c |
|
479 | 489 | |
|
480 | 490 | ... with a dirty working dir |
|
481 | 491 | |
|
482 | 492 | $ hg add c |
|
483 | 493 | $ hg rm bar |
|
484 | 494 | $ hg commit -mc |
|
485 | 495 | $ hg status |
|
486 | 496 | $ echo b > b |
|
487 | 497 | $ echo d > d |
|
488 | 498 | $ hg strip --keep tip |
|
489 | 499 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/57e364c8a475-4cfed93c-backup.hg (glob) |
|
490 | 500 | $ hg status |
|
491 | 501 | M b |
|
492 | 502 | ! bar |
|
493 | 503 | ? c |
|
494 | 504 | ? d |
|
495 | 505 | $ cd .. |
|
496 | 506 | |
|
497 | 507 | stripping many nodes on a complex graph (issue3299) |
|
498 | 508 | |
|
499 | 509 | $ hg init issue3299 |
|
500 | 510 | $ cd issue3299 |
|
501 | 511 | $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a' |
|
502 | 512 | $ hg strip 'not ancestors(x)' |
|
503 | 513 | saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob) |
|
504 | 514 | |
|
505 | 515 | test hg strip -B bookmark |
|
506 | 516 | |
|
507 | 517 | $ cd .. |
|
508 | 518 | $ hg init bookmarks |
|
509 | 519 | $ cd bookmarks |
|
510 | 520 | $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b' |
|
511 | 521 | $ hg bookmark -r 'a' 'todelete' |
|
512 | 522 | $ hg bookmark -r 'b' 'B' |
|
513 | 523 | $ hg bookmark -r 'b' 'nostrip' |
|
514 | 524 | $ hg bookmark -r 'c' 'delete' |
|
515 | 525 | $ hg up -C todelete |
|
516 | 526 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
517 | 527 | (activating bookmark todelete) |
|
518 | 528 | $ hg strip -B nostrip |
|
519 | 529 | bookmark 'nostrip' deleted |
|
520 | 530 | abort: empty revision set |
|
521 | 531 | [255] |
|
522 | 532 | $ hg strip -B todelete |
|
523 | 533 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
524 | 534 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
525 | 535 | bookmark 'todelete' deleted |
|
526 | 536 | $ hg id -ir dcbb326fdec2 |
|
527 | 537 | abort: unknown revision 'dcbb326fdec2'! |
|
528 | 538 | [255] |
|
529 | 539 | $ hg id -ir d62d843c9a01 |
|
530 | 540 | d62d843c9a01 |
|
531 | 541 | $ hg bookmarks |
|
532 | 542 | B 9:ff43616e5d0f |
|
533 | 543 | delete 6:2702dd0c91e7 |
|
534 | 544 | $ hg strip -B delete |
|
535 | 545 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
536 | 546 | bookmark 'delete' deleted |
|
537 | 547 | $ hg id -ir 6:2702dd0c91e7 |
|
538 | 548 | abort: unknown revision '2702dd0c91e7'! |
|
539 | 549 | [255] |
|
540 | 550 | $ hg update B |
|
541 | 551 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
542 | 552 | (activating bookmark B) |
|
543 | 553 | $ echo a > a |
|
544 | 554 | $ hg add a |
|
545 | 555 | $ hg strip -B B |
|
546 | 556 | abort: local changes found |
|
547 | 557 | [255] |
|
548 | 558 | $ hg bookmarks |
|
549 | 559 | * B 6:ff43616e5d0f |
|
550 | 560 | |
|
551 | 561 | Make sure no one adds back a -b option: |
|
552 | 562 | |
|
553 | 563 | $ hg strip -b tip |
|
554 | 564 | hg strip: option -b not recognized |
|
555 | 565 | hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV... |
|
556 | 566 | |
|
557 | 567 | strip changesets and all their descendants from the repository |
|
558 | 568 | |
|
559 | 569 | (use "hg help -e strip" to show help for the strip extension) |
|
560 | 570 | |
|
561 | 571 | options ([+] can be repeated): |
|
562 | 572 | |
|
563 | 573 | -r --rev REV [+] strip specified revision (optional, can specify revisions |
|
564 | 574 | without this option) |
|
565 | 575 | -f --force force removal of changesets, discard uncommitted changes |
|
566 | 576 | (no backup) |
|
567 | 577 | --no-backup no backups |
|
568 | 578 | -k --keep do not modify working copy during strip |
|
569 | 579 | -B --bookmark VALUE remove revs only reachable from given bookmark |
|
570 | 580 | --mq operate on patch repository |
|
571 | 581 | |
|
572 | 582 | (use "hg strip -h" to show more help) |
|
573 | 583 | [255] |
|
574 | 584 | |
|
575 | 585 | $ cd .. |
|
576 | 586 | |
|
577 | 587 | Verify bundles don't get overwritten: |
|
578 | 588 | |
|
579 | 589 | $ hg init doublebundle |
|
580 | 590 | $ cd doublebundle |
|
581 | 591 | $ touch a |
|
582 | 592 | $ hg commit -Aqm a |
|
583 | 593 | $ touch b |
|
584 | 594 | $ hg commit -Aqm b |
|
585 | 595 | $ hg strip -r 0 |
|
586 | 596 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
587 | 597 | saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg (glob) |
|
588 | 598 | $ ls .hg/strip-backup |
|
589 | 599 | 3903775176ed-e68910bd-backup.hg |
|
590 | 600 | $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg |
|
591 | 601 | $ hg strip -r 0 |
|
592 | 602 | saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg (glob) |
|
593 | 603 | $ ls .hg/strip-backup |
|
594 | 604 | 3903775176ed-54390173-backup.hg |
|
595 | 605 | 3903775176ed-e68910bd-backup.hg |
General Comments 0
You need to be logged in to leave comments.
Login now