Show More
@@ -1,2274 +1,2273 | |||||
1 | # localrepo.py - read/write repository class for mercurial |
|
1 | # localrepo.py - read/write repository class for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import errno |
|
10 | import errno | |
11 | import hashlib |
|
11 | import hashlib | |
12 | import inspect |
|
12 | import inspect | |
13 | import os |
|
13 | import os | |
14 | import random |
|
14 | import random | |
15 | import time |
|
15 | import time | |
16 | import weakref |
|
16 | import weakref | |
17 |
|
17 | |||
18 | from .i18n import _ |
|
18 | from .i18n import _ | |
19 | from .node import ( |
|
19 | from .node import ( | |
20 | hex, |
|
20 | hex, | |
21 | nullid, |
|
21 | nullid, | |
22 | short, |
|
22 | short, | |
23 | ) |
|
23 | ) | |
24 | from . import ( |
|
24 | from . import ( | |
25 | bookmarks, |
|
25 | bookmarks, | |
26 | branchmap, |
|
26 | branchmap, | |
27 | bundle2, |
|
27 | bundle2, | |
28 | changegroup, |
|
28 | changegroup, | |
29 | changelog, |
|
29 | changelog, | |
30 | color, |
|
30 | color, | |
31 | context, |
|
31 | context, | |
32 | dirstate, |
|
32 | dirstate, | |
33 | dirstateguard, |
|
33 | dirstateguard, | |
34 | discovery, |
|
34 | discovery, | |
35 | encoding, |
|
35 | encoding, | |
36 | error, |
|
36 | error, | |
37 | exchange, |
|
37 | exchange, | |
38 | extensions, |
|
38 | extensions, | |
39 | filelog, |
|
39 | filelog, | |
40 | hook, |
|
40 | hook, | |
41 | lock as lockmod, |
|
41 | lock as lockmod, | |
42 | manifest, |
|
42 | manifest, | |
43 | match as matchmod, |
|
43 | match as matchmod, | |
44 | merge as mergemod, |
|
44 | merge as mergemod, | |
45 | mergeutil, |
|
45 | mergeutil, | |
46 | namespaces, |
|
46 | namespaces, | |
47 | obsolete, |
|
47 | obsolete, | |
48 | pathutil, |
|
48 | pathutil, | |
49 | peer, |
|
49 | peer, | |
50 | phases, |
|
50 | phases, | |
51 | pushkey, |
|
51 | pushkey, | |
52 | pycompat, |
|
52 | pycompat, | |
53 | repository, |
|
53 | repository, | |
54 | repoview, |
|
54 | repoview, | |
55 | revset, |
|
55 | revset, | |
56 | revsetlang, |
|
56 | revsetlang, | |
57 | scmutil, |
|
57 | scmutil, | |
58 | sparse, |
|
58 | sparse, | |
59 | store, |
|
59 | store, | |
60 | subrepo, |
|
60 | subrepo, | |
61 | tags as tagsmod, |
|
61 | tags as tagsmod, | |
62 | transaction, |
|
62 | transaction, | |
63 | txnutil, |
|
63 | txnutil, | |
64 | util, |
|
64 | util, | |
65 | vfs as vfsmod, |
|
65 | vfs as vfsmod, | |
66 | ) |
|
66 | ) | |
67 |
|
67 | |||
68 | release = lockmod.release |
|
68 | release = lockmod.release | |
69 | urlerr = util.urlerr |
|
69 | urlerr = util.urlerr | |
70 | urlreq = util.urlreq |
|
70 | urlreq = util.urlreq | |
71 |
|
71 | |||
72 | # set of (path, vfs-location) tuples. vfs-location is: |
|
72 | # set of (path, vfs-location) tuples. vfs-location is: | |
73 | # - 'plain for vfs relative paths |
|
73 | # - 'plain for vfs relative paths | |
74 | # - '' for svfs relative paths |
|
74 | # - '' for svfs relative paths | |
75 | _cachedfiles = set() |
|
75 | _cachedfiles = set() | |
76 |
|
76 | |||
77 | class _basefilecache(scmutil.filecache): |
|
77 | class _basefilecache(scmutil.filecache): | |
78 | """All filecache usage on repo are done for logic that should be unfiltered |
|
78 | """All filecache usage on repo are done for logic that should be unfiltered | |
79 | """ |
|
79 | """ | |
80 | def __get__(self, repo, type=None): |
|
80 | def __get__(self, repo, type=None): | |
81 | if repo is None: |
|
81 | if repo is None: | |
82 | return self |
|
82 | return self | |
83 | return super(_basefilecache, self).__get__(repo.unfiltered(), type) |
|
83 | return super(_basefilecache, self).__get__(repo.unfiltered(), type) | |
84 | def __set__(self, repo, value): |
|
84 | def __set__(self, repo, value): | |
85 | return super(_basefilecache, self).__set__(repo.unfiltered(), value) |
|
85 | return super(_basefilecache, self).__set__(repo.unfiltered(), value) | |
86 | def __delete__(self, repo): |
|
86 | def __delete__(self, repo): | |
87 | return super(_basefilecache, self).__delete__(repo.unfiltered()) |
|
87 | return super(_basefilecache, self).__delete__(repo.unfiltered()) | |
88 |
|
88 | |||
89 | class repofilecache(_basefilecache): |
|
89 | class repofilecache(_basefilecache): | |
90 | """filecache for files in .hg but outside of .hg/store""" |
|
90 | """filecache for files in .hg but outside of .hg/store""" | |
91 | def __init__(self, *paths): |
|
91 | def __init__(self, *paths): | |
92 | super(repofilecache, self).__init__(*paths) |
|
92 | super(repofilecache, self).__init__(*paths) | |
93 | for path in paths: |
|
93 | for path in paths: | |
94 | _cachedfiles.add((path, 'plain')) |
|
94 | _cachedfiles.add((path, 'plain')) | |
95 |
|
95 | |||
96 | def join(self, obj, fname): |
|
96 | def join(self, obj, fname): | |
97 | return obj.vfs.join(fname) |
|
97 | return obj.vfs.join(fname) | |
98 |
|
98 | |||
99 | class storecache(_basefilecache): |
|
99 | class storecache(_basefilecache): | |
100 | """filecache for files in the store""" |
|
100 | """filecache for files in the store""" | |
101 | def __init__(self, *paths): |
|
101 | def __init__(self, *paths): | |
102 | super(storecache, self).__init__(*paths) |
|
102 | super(storecache, self).__init__(*paths) | |
103 | for path in paths: |
|
103 | for path in paths: | |
104 | _cachedfiles.add((path, '')) |
|
104 | _cachedfiles.add((path, '')) | |
105 |
|
105 | |||
106 | def join(self, obj, fname): |
|
106 | def join(self, obj, fname): | |
107 | return obj.sjoin(fname) |
|
107 | return obj.sjoin(fname) | |
108 |
|
108 | |||
109 | def isfilecached(repo, name): |
|
109 | def isfilecached(repo, name): | |
110 | """check if a repo has already cached "name" filecache-ed property |
|
110 | """check if a repo has already cached "name" filecache-ed property | |
111 |
|
111 | |||
112 | This returns (cachedobj-or-None, iscached) tuple. |
|
112 | This returns (cachedobj-or-None, iscached) tuple. | |
113 | """ |
|
113 | """ | |
114 | cacheentry = repo.unfiltered()._filecache.get(name, None) |
|
114 | cacheentry = repo.unfiltered()._filecache.get(name, None) | |
115 | if not cacheentry: |
|
115 | if not cacheentry: | |
116 | return None, False |
|
116 | return None, False | |
117 | return cacheentry.obj, True |
|
117 | return cacheentry.obj, True | |
118 |
|
118 | |||
119 | class unfilteredpropertycache(util.propertycache): |
|
119 | class unfilteredpropertycache(util.propertycache): | |
120 | """propertycache that apply to unfiltered repo only""" |
|
120 | """propertycache that apply to unfiltered repo only""" | |
121 |
|
121 | |||
122 | def __get__(self, repo, type=None): |
|
122 | def __get__(self, repo, type=None): | |
123 | unfi = repo.unfiltered() |
|
123 | unfi = repo.unfiltered() | |
124 | if unfi is repo: |
|
124 | if unfi is repo: | |
125 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
125 | return super(unfilteredpropertycache, self).__get__(unfi) | |
126 | return getattr(unfi, self.name) |
|
126 | return getattr(unfi, self.name) | |
127 |
|
127 | |||
128 | class filteredpropertycache(util.propertycache): |
|
128 | class filteredpropertycache(util.propertycache): | |
129 | """propertycache that must take filtering in account""" |
|
129 | """propertycache that must take filtering in account""" | |
130 |
|
130 | |||
131 | def cachevalue(self, obj, value): |
|
131 | def cachevalue(self, obj, value): | |
132 | object.__setattr__(obj, self.name, value) |
|
132 | object.__setattr__(obj, self.name, value) | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | def hasunfilteredcache(repo, name): |
|
135 | def hasunfilteredcache(repo, name): | |
136 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
136 | """check if a repo has an unfilteredpropertycache value for <name>""" | |
137 | return name in vars(repo.unfiltered()) |
|
137 | return name in vars(repo.unfiltered()) | |
138 |
|
138 | |||
139 | def unfilteredmethod(orig): |
|
139 | def unfilteredmethod(orig): | |
140 | """decorate method that always need to be run on unfiltered version""" |
|
140 | """decorate method that always need to be run on unfiltered version""" | |
141 | def wrapper(repo, *args, **kwargs): |
|
141 | def wrapper(repo, *args, **kwargs): | |
142 | return orig(repo.unfiltered(), *args, **kwargs) |
|
142 | return orig(repo.unfiltered(), *args, **kwargs) | |
143 | return wrapper |
|
143 | return wrapper | |
144 |
|
144 | |||
145 | moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', |
|
145 | moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', | |
146 | 'unbundle'} |
|
146 | 'unbundle'} | |
147 | legacycaps = moderncaps.union({'changegroupsubset'}) |
|
147 | legacycaps = moderncaps.union({'changegroupsubset'}) | |
148 |
|
148 | |||
149 | class localpeer(repository.peer): |
|
149 | class localpeer(repository.peer): | |
150 | '''peer for a local repo; reflects only the most recent API''' |
|
150 | '''peer for a local repo; reflects only the most recent API''' | |
151 |
|
151 | |||
152 | def __init__(self, repo, caps=None): |
|
152 | def __init__(self, repo, caps=None): | |
153 | super(localpeer, self).__init__() |
|
153 | super(localpeer, self).__init__() | |
154 |
|
154 | |||
155 | if caps is None: |
|
155 | if caps is None: | |
156 | caps = moderncaps.copy() |
|
156 | caps = moderncaps.copy() | |
157 | self._repo = repo.filtered('served') |
|
157 | self._repo = repo.filtered('served') | |
158 | self._ui = repo.ui |
|
158 | self._ui = repo.ui | |
159 | self._caps = repo._restrictcapabilities(caps) |
|
159 | self._caps = repo._restrictcapabilities(caps) | |
160 |
|
160 | |||
161 | # Begin of _basepeer interface. |
|
161 | # Begin of _basepeer interface. | |
162 |
|
162 | |||
163 | @util.propertycache |
|
163 | @util.propertycache | |
164 | def ui(self): |
|
164 | def ui(self): | |
165 | return self._ui |
|
165 | return self._ui | |
166 |
|
166 | |||
167 | def url(self): |
|
167 | def url(self): | |
168 | return self._repo.url() |
|
168 | return self._repo.url() | |
169 |
|
169 | |||
170 | def local(self): |
|
170 | def local(self): | |
171 | return self._repo |
|
171 | return self._repo | |
172 |
|
172 | |||
173 | def peer(self): |
|
173 | def peer(self): | |
174 | return self |
|
174 | return self | |
175 |
|
175 | |||
176 | def canpush(self): |
|
176 | def canpush(self): | |
177 | return True |
|
177 | return True | |
178 |
|
178 | |||
179 | def close(self): |
|
179 | def close(self): | |
180 | self._repo.close() |
|
180 | self._repo.close() | |
181 |
|
181 | |||
182 | # End of _basepeer interface. |
|
182 | # End of _basepeer interface. | |
183 |
|
183 | |||
184 | # Begin of _basewirecommands interface. |
|
184 | # Begin of _basewirecommands interface. | |
185 |
|
185 | |||
186 | def branchmap(self): |
|
186 | def branchmap(self): | |
187 | return self._repo.branchmap() |
|
187 | return self._repo.branchmap() | |
188 |
|
188 | |||
189 | def capabilities(self): |
|
189 | def capabilities(self): | |
190 | return self._caps |
|
190 | return self._caps | |
191 |
|
191 | |||
192 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
192 | def debugwireargs(self, one, two, three=None, four=None, five=None): | |
193 | """Used to test argument passing over the wire""" |
|
193 | """Used to test argument passing over the wire""" | |
194 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
194 | return "%s %s %s %s %s" % (one, two, three, four, five) | |
195 |
|
195 | |||
196 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, |
|
196 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, | |
197 | **kwargs): |
|
197 | **kwargs): | |
198 | chunks = exchange.getbundlechunks(self._repo, source, heads=heads, |
|
198 | chunks = exchange.getbundlechunks(self._repo, source, heads=heads, | |
199 | common=common, bundlecaps=bundlecaps, |
|
199 | common=common, bundlecaps=bundlecaps, | |
200 | **kwargs) |
|
200 | **kwargs) | |
201 | cb = util.chunkbuffer(chunks) |
|
201 | cb = util.chunkbuffer(chunks) | |
202 |
|
202 | |||
203 | if exchange.bundle2requested(bundlecaps): |
|
203 | if exchange.bundle2requested(bundlecaps): | |
204 | # When requesting a bundle2, getbundle returns a stream to make the |
|
204 | # When requesting a bundle2, getbundle returns a stream to make the | |
205 | # wire level function happier. We need to build a proper object |
|
205 | # wire level function happier. We need to build a proper object | |
206 | # from it in local peer. |
|
206 | # from it in local peer. | |
207 | return bundle2.getunbundler(self.ui, cb) |
|
207 | return bundle2.getunbundler(self.ui, cb) | |
208 | else: |
|
208 | else: | |
209 | return changegroup.getunbundler('01', cb, None) |
|
209 | return changegroup.getunbundler('01', cb, None) | |
210 |
|
210 | |||
211 | def heads(self): |
|
211 | def heads(self): | |
212 | return self._repo.heads() |
|
212 | return self._repo.heads() | |
213 |
|
213 | |||
214 | def known(self, nodes): |
|
214 | def known(self, nodes): | |
215 | return self._repo.known(nodes) |
|
215 | return self._repo.known(nodes) | |
216 |
|
216 | |||
217 | def listkeys(self, namespace): |
|
217 | def listkeys(self, namespace): | |
218 | return self._repo.listkeys(namespace) |
|
218 | return self._repo.listkeys(namespace) | |
219 |
|
219 | |||
220 | def lookup(self, key): |
|
220 | def lookup(self, key): | |
221 | return self._repo.lookup(key) |
|
221 | return self._repo.lookup(key) | |
222 |
|
222 | |||
223 | def pushkey(self, namespace, key, old, new): |
|
223 | def pushkey(self, namespace, key, old, new): | |
224 | return self._repo.pushkey(namespace, key, old, new) |
|
224 | return self._repo.pushkey(namespace, key, old, new) | |
225 |
|
225 | |||
226 | def stream_out(self): |
|
226 | def stream_out(self): | |
227 | raise error.Abort(_('cannot perform stream clone against local ' |
|
227 | raise error.Abort(_('cannot perform stream clone against local ' | |
228 | 'peer')) |
|
228 | 'peer')) | |
229 |
|
229 | |||
230 | def unbundle(self, cg, heads, url): |
|
230 | def unbundle(self, cg, heads, url): | |
231 | """apply a bundle on a repo |
|
231 | """apply a bundle on a repo | |
232 |
|
232 | |||
233 | This function handles the repo locking itself.""" |
|
233 | This function handles the repo locking itself.""" | |
234 | try: |
|
234 | try: | |
235 | try: |
|
235 | try: | |
236 | cg = exchange.readbundle(self.ui, cg, None) |
|
236 | cg = exchange.readbundle(self.ui, cg, None) | |
237 | ret = exchange.unbundle(self._repo, cg, heads, 'push', url) |
|
237 | ret = exchange.unbundle(self._repo, cg, heads, 'push', url) | |
238 | if util.safehasattr(ret, 'getchunks'): |
|
238 | if util.safehasattr(ret, 'getchunks'): | |
239 | # This is a bundle20 object, turn it into an unbundler. |
|
239 | # This is a bundle20 object, turn it into an unbundler. | |
240 | # This little dance should be dropped eventually when the |
|
240 | # This little dance should be dropped eventually when the | |
241 | # API is finally improved. |
|
241 | # API is finally improved. | |
242 | stream = util.chunkbuffer(ret.getchunks()) |
|
242 | stream = util.chunkbuffer(ret.getchunks()) | |
243 | ret = bundle2.getunbundler(self.ui, stream) |
|
243 | ret = bundle2.getunbundler(self.ui, stream) | |
244 | return ret |
|
244 | return ret | |
245 | except Exception as exc: |
|
245 | except Exception as exc: | |
246 | # If the exception contains output salvaged from a bundle2 |
|
246 | # If the exception contains output salvaged from a bundle2 | |
247 | # reply, we need to make sure it is printed before continuing |
|
247 | # reply, we need to make sure it is printed before continuing | |
248 | # to fail. So we build a bundle2 with such output and consume |
|
248 | # to fail. So we build a bundle2 with such output and consume | |
249 | # it directly. |
|
249 | # it directly. | |
250 | # |
|
250 | # | |
251 | # This is not very elegant but allows a "simple" solution for |
|
251 | # This is not very elegant but allows a "simple" solution for | |
252 | # issue4594 |
|
252 | # issue4594 | |
253 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
253 | output = getattr(exc, '_bundle2salvagedoutput', ()) | |
254 | if output: |
|
254 | if output: | |
255 | bundler = bundle2.bundle20(self._repo.ui) |
|
255 | bundler = bundle2.bundle20(self._repo.ui) | |
256 | for out in output: |
|
256 | for out in output: | |
257 | bundler.addpart(out) |
|
257 | bundler.addpart(out) | |
258 | stream = util.chunkbuffer(bundler.getchunks()) |
|
258 | stream = util.chunkbuffer(bundler.getchunks()) | |
259 | b = bundle2.getunbundler(self.ui, stream) |
|
259 | b = bundle2.getunbundler(self.ui, stream) | |
260 | bundle2.processbundle(self._repo, b) |
|
260 | bundle2.processbundle(self._repo, b) | |
261 | raise |
|
261 | raise | |
262 | except error.PushRaced as exc: |
|
262 | except error.PushRaced as exc: | |
263 | raise error.ResponseError(_('push failed:'), str(exc)) |
|
263 | raise error.ResponseError(_('push failed:'), str(exc)) | |
264 |
|
264 | |||
265 | # End of _basewirecommands interface. |
|
265 | # End of _basewirecommands interface. | |
266 |
|
266 | |||
267 | # Begin of peer interface. |
|
267 | # Begin of peer interface. | |
268 |
|
268 | |||
269 | def iterbatch(self): |
|
269 | def iterbatch(self): | |
270 | return peer.localiterbatcher(self) |
|
270 | return peer.localiterbatcher(self) | |
271 |
|
271 | |||
272 | # End of peer interface. |
|
272 | # End of peer interface. | |
273 |
|
273 | |||
274 | class locallegacypeer(repository.legacypeer, localpeer): |
|
274 | class locallegacypeer(repository.legacypeer, localpeer): | |
275 | '''peer extension which implements legacy methods too; used for tests with |
|
275 | '''peer extension which implements legacy methods too; used for tests with | |
276 | restricted capabilities''' |
|
276 | restricted capabilities''' | |
277 |
|
277 | |||
278 | def __init__(self, repo): |
|
278 | def __init__(self, repo): | |
279 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) |
|
279 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) | |
280 |
|
280 | |||
281 | # Begin of baselegacywirecommands interface. |
|
281 | # Begin of baselegacywirecommands interface. | |
282 |
|
282 | |||
283 | def between(self, pairs): |
|
283 | def between(self, pairs): | |
284 | return self._repo.between(pairs) |
|
284 | return self._repo.between(pairs) | |
285 |
|
285 | |||
286 | def branches(self, nodes): |
|
286 | def branches(self, nodes): | |
287 | return self._repo.branches(nodes) |
|
287 | return self._repo.branches(nodes) | |
288 |
|
288 | |||
289 | def changegroup(self, basenodes, source): |
|
289 | def changegroup(self, basenodes, source): | |
290 | outgoing = discovery.outgoing(self._repo, missingroots=basenodes, |
|
290 | outgoing = discovery.outgoing(self._repo, missingroots=basenodes, | |
291 | missingheads=self._repo.heads()) |
|
291 | missingheads=self._repo.heads()) | |
292 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
292 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) | |
293 |
|
293 | |||
294 | def changegroupsubset(self, bases, heads, source): |
|
294 | def changegroupsubset(self, bases, heads, source): | |
295 | outgoing = discovery.outgoing(self._repo, missingroots=bases, |
|
295 | outgoing = discovery.outgoing(self._repo, missingroots=bases, | |
296 | missingheads=heads) |
|
296 | missingheads=heads) | |
297 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
297 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) | |
298 |
|
298 | |||
299 | # End of baselegacywirecommands interface. |
|
299 | # End of baselegacywirecommands interface. | |
300 |
|
300 | |||
301 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
301 | # Increment the sub-version when the revlog v2 format changes to lock out old | |
302 | # clients. |
|
302 | # clients. | |
303 | REVLOGV2_REQUIREMENT = 'exp-revlogv2.0' |
|
303 | REVLOGV2_REQUIREMENT = 'exp-revlogv2.0' | |
304 |
|
304 | |||
305 | class localrepository(object): |
|
305 | class localrepository(object): | |
306 |
|
306 | |||
307 | supportedformats = { |
|
307 | supportedformats = { | |
308 | 'revlogv1', |
|
308 | 'revlogv1', | |
309 | 'generaldelta', |
|
309 | 'generaldelta', | |
310 | 'treemanifest', |
|
310 | 'treemanifest', | |
311 | 'manifestv2', |
|
311 | 'manifestv2', | |
312 | REVLOGV2_REQUIREMENT, |
|
312 | REVLOGV2_REQUIREMENT, | |
313 | } |
|
313 | } | |
314 | _basesupported = supportedformats | { |
|
314 | _basesupported = supportedformats | { | |
315 | 'store', |
|
315 | 'store', | |
316 | 'fncache', |
|
316 | 'fncache', | |
317 | 'shared', |
|
317 | 'shared', | |
318 | 'relshared', |
|
318 | 'relshared', | |
319 | 'dotencode', |
|
319 | 'dotencode', | |
320 | 'exp-sparse', |
|
320 | 'exp-sparse', | |
321 | } |
|
321 | } | |
322 | openerreqs = { |
|
322 | openerreqs = { | |
323 | 'revlogv1', |
|
323 | 'revlogv1', | |
324 | 'generaldelta', |
|
324 | 'generaldelta', | |
325 | 'treemanifest', |
|
325 | 'treemanifest', | |
326 | 'manifestv2', |
|
326 | 'manifestv2', | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | # a list of (ui, featureset) functions. |
|
329 | # a list of (ui, featureset) functions. | |
330 | # only functions defined in module of enabled extensions are invoked |
|
330 | # only functions defined in module of enabled extensions are invoked | |
331 | featuresetupfuncs = set() |
|
331 | featuresetupfuncs = set() | |
332 |
|
332 | |||
333 | # list of prefix for file which can be written without 'wlock' |
|
333 | # list of prefix for file which can be written without 'wlock' | |
334 | # Extensions should extend this list when needed |
|
334 | # Extensions should extend this list when needed | |
335 | _wlockfreeprefix = { |
|
335 | _wlockfreeprefix = { | |
336 | # We migh consider requiring 'wlock' for the next |
|
336 | # We migh consider requiring 'wlock' for the next | |
337 | # two, but pretty much all the existing code assume |
|
337 | # two, but pretty much all the existing code assume | |
338 | # wlock is not needed so we keep them excluded for |
|
338 | # wlock is not needed so we keep them excluded for | |
339 | # now. |
|
339 | # now. | |
340 | 'hgrc', |
|
340 | 'hgrc', | |
341 | 'requires', |
|
341 | 'requires', | |
342 | # XXX cache is a complicatged business someone |
|
342 | # XXX cache is a complicatged business someone | |
343 | # should investigate this in depth at some point |
|
343 | # should investigate this in depth at some point | |
344 | 'cache/', |
|
344 | 'cache/', | |
345 | # XXX shouldn't be dirstate covered by the wlock? |
|
345 | # XXX shouldn't be dirstate covered by the wlock? | |
346 | 'dirstate', |
|
346 | 'dirstate', | |
347 | # XXX bisect was still a bit too messy at the time |
|
347 | # XXX bisect was still a bit too messy at the time | |
348 | # this changeset was introduced. Someone should fix |
|
348 | # this changeset was introduced. Someone should fix | |
349 | # the remainig bit and drop this line |
|
349 | # the remainig bit and drop this line | |
350 | 'bisect.state', |
|
350 | 'bisect.state', | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | def __init__(self, baseui, path, create=False): |
|
353 | def __init__(self, baseui, path, create=False): | |
354 | self.requirements = set() |
|
354 | self.requirements = set() | |
355 | self.filtername = None |
|
355 | self.filtername = None | |
356 | # wvfs: rooted at the repository root, used to access the working copy |
|
356 | # wvfs: rooted at the repository root, used to access the working copy | |
357 | self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
357 | self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True) | |
358 | # vfs: rooted at .hg, used to access repo files outside of .hg/store |
|
358 | # vfs: rooted at .hg, used to access repo files outside of .hg/store | |
359 | self.vfs = None |
|
359 | self.vfs = None | |
360 | # svfs: usually rooted at .hg/store, used to access repository history |
|
360 | # svfs: usually rooted at .hg/store, used to access repository history | |
361 | # If this is a shared repository, this vfs may point to another |
|
361 | # If this is a shared repository, this vfs may point to another | |
362 | # repository's .hg/store directory. |
|
362 | # repository's .hg/store directory. | |
363 | self.svfs = None |
|
363 | self.svfs = None | |
364 | self.root = self.wvfs.base |
|
364 | self.root = self.wvfs.base | |
365 | self.path = self.wvfs.join(".hg") |
|
365 | self.path = self.wvfs.join(".hg") | |
366 | self.origroot = path |
|
366 | self.origroot = path | |
367 | # This is only used by context.workingctx.match in order to |
|
367 | # This is only used by context.workingctx.match in order to | |
368 | # detect files in subrepos. |
|
368 | # detect files in subrepos. | |
369 | self.auditor = pathutil.pathauditor( |
|
369 | self.auditor = pathutil.pathauditor( | |
370 | self.root, callback=self._checknested) |
|
370 | self.root, callback=self._checknested) | |
371 | # This is only used by context.basectx.match in order to detect |
|
371 | # This is only used by context.basectx.match in order to detect | |
372 | # files in subrepos. |
|
372 | # files in subrepos. | |
373 | self.nofsauditor = pathutil.pathauditor( |
|
373 | self.nofsauditor = pathutil.pathauditor( | |
374 | self.root, callback=self._checknested, realfs=False, cached=True) |
|
374 | self.root, callback=self._checknested, realfs=False, cached=True) | |
375 | self.baseui = baseui |
|
375 | self.baseui = baseui | |
376 | self.ui = baseui.copy() |
|
376 | self.ui = baseui.copy() | |
377 | self.ui.copy = baseui.copy # prevent copying repo configuration |
|
377 | self.ui.copy = baseui.copy # prevent copying repo configuration | |
378 | self.vfs = vfsmod.vfs(self.path, cacheaudited=True) |
|
378 | self.vfs = vfsmod.vfs(self.path, cacheaudited=True) | |
379 | if (self.ui.configbool('devel', 'all-warnings') or |
|
379 | if (self.ui.configbool('devel', 'all-warnings') or | |
380 | self.ui.configbool('devel', 'check-locks')): |
|
380 | self.ui.configbool('devel', 'check-locks')): | |
381 | self.vfs.audit = self._getvfsward(self.vfs.audit) |
|
381 | self.vfs.audit = self._getvfsward(self.vfs.audit) | |
382 | # A list of callback to shape the phase if no data were found. |
|
382 | # A list of callback to shape the phase if no data were found. | |
383 | # Callback are in the form: func(repo, roots) --> processed root. |
|
383 | # Callback are in the form: func(repo, roots) --> processed root. | |
384 | # This list it to be filled by extension during repo setup |
|
384 | # This list it to be filled by extension during repo setup | |
385 | self._phasedefaults = [] |
|
385 | self._phasedefaults = [] | |
386 | try: |
|
386 | try: | |
387 | self.ui.readconfig(self.vfs.join("hgrc"), self.root) |
|
387 | self.ui.readconfig(self.vfs.join("hgrc"), self.root) | |
388 | self._loadextensions() |
|
388 | self._loadextensions() | |
389 | except IOError: |
|
389 | except IOError: | |
390 | pass |
|
390 | pass | |
391 |
|
391 | |||
392 | if self.featuresetupfuncs: |
|
392 | if self.featuresetupfuncs: | |
393 | self.supported = set(self._basesupported) # use private copy |
|
393 | self.supported = set(self._basesupported) # use private copy | |
394 | extmods = set(m.__name__ for n, m |
|
394 | extmods = set(m.__name__ for n, m | |
395 | in extensions.extensions(self.ui)) |
|
395 | in extensions.extensions(self.ui)) | |
396 | for setupfunc in self.featuresetupfuncs: |
|
396 | for setupfunc in self.featuresetupfuncs: | |
397 | if setupfunc.__module__ in extmods: |
|
397 | if setupfunc.__module__ in extmods: | |
398 | setupfunc(self.ui, self.supported) |
|
398 | setupfunc(self.ui, self.supported) | |
399 | else: |
|
399 | else: | |
400 | self.supported = self._basesupported |
|
400 | self.supported = self._basesupported | |
401 | color.setup(self.ui) |
|
401 | color.setup(self.ui) | |
402 |
|
402 | |||
403 | # Add compression engines. |
|
403 | # Add compression engines. | |
404 | for name in util.compengines: |
|
404 | for name in util.compengines: | |
405 | engine = util.compengines[name] |
|
405 | engine = util.compengines[name] | |
406 | if engine.revlogheader(): |
|
406 | if engine.revlogheader(): | |
407 | self.supported.add('exp-compression-%s' % name) |
|
407 | self.supported.add('exp-compression-%s' % name) | |
408 |
|
408 | |||
409 | if not self.vfs.isdir(): |
|
409 | if not self.vfs.isdir(): | |
410 | if create: |
|
410 | if create: | |
411 | self.requirements = newreporequirements(self) |
|
411 | self.requirements = newreporequirements(self) | |
412 |
|
412 | |||
413 | if not self.wvfs.exists(): |
|
413 | if not self.wvfs.exists(): | |
414 | self.wvfs.makedirs() |
|
414 | self.wvfs.makedirs() | |
415 | self.vfs.makedir(notindexed=True) |
|
415 | self.vfs.makedir(notindexed=True) | |
416 |
|
416 | |||
417 | if 'store' in self.requirements: |
|
417 | if 'store' in self.requirements: | |
418 | self.vfs.mkdir("store") |
|
418 | self.vfs.mkdir("store") | |
419 |
|
419 | |||
420 | # create an invalid changelog |
|
420 | # create an invalid changelog | |
421 | self.vfs.append( |
|
421 | self.vfs.append( | |
422 | "00changelog.i", |
|
422 | "00changelog.i", | |
423 | '\0\0\0\2' # represents revlogv2 |
|
423 | '\0\0\0\2' # represents revlogv2 | |
424 | ' dummy changelog to prevent using the old repo layout' |
|
424 | ' dummy changelog to prevent using the old repo layout' | |
425 | ) |
|
425 | ) | |
426 | else: |
|
426 | else: | |
427 | raise error.RepoError(_("repository %s not found") % path) |
|
427 | raise error.RepoError(_("repository %s not found") % path) | |
428 | elif create: |
|
428 | elif create: | |
429 | raise error.RepoError(_("repository %s already exists") % path) |
|
429 | raise error.RepoError(_("repository %s already exists") % path) | |
430 | else: |
|
430 | else: | |
431 | try: |
|
431 | try: | |
432 | self.requirements = scmutil.readrequires( |
|
432 | self.requirements = scmutil.readrequires( | |
433 | self.vfs, self.supported) |
|
433 | self.vfs, self.supported) | |
434 | except IOError as inst: |
|
434 | except IOError as inst: | |
435 | if inst.errno != errno.ENOENT: |
|
435 | if inst.errno != errno.ENOENT: | |
436 | raise |
|
436 | raise | |
437 |
|
437 | |||
438 | cachepath = self.vfs.join('cache') |
|
438 | cachepath = self.vfs.join('cache') | |
439 | self.sharedpath = self.path |
|
439 | self.sharedpath = self.path | |
440 | try: |
|
440 | try: | |
441 | sharedpath = self.vfs.read("sharedpath").rstrip('\n') |
|
441 | sharedpath = self.vfs.read("sharedpath").rstrip('\n') | |
442 | if 'relshared' in self.requirements: |
|
442 | if 'relshared' in self.requirements: | |
443 | sharedpath = self.vfs.join(sharedpath) |
|
443 | sharedpath = self.vfs.join(sharedpath) | |
444 | vfs = vfsmod.vfs(sharedpath, realpath=True) |
|
444 | vfs = vfsmod.vfs(sharedpath, realpath=True) | |
445 | cachepath = vfs.join('cache') |
|
445 | cachepath = vfs.join('cache') | |
446 | s = vfs.base |
|
446 | s = vfs.base | |
447 | if not vfs.exists(): |
|
447 | if not vfs.exists(): | |
448 | raise error.RepoError( |
|
448 | raise error.RepoError( | |
449 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
449 | _('.hg/sharedpath points to nonexistent directory %s') % s) | |
450 | self.sharedpath = s |
|
450 | self.sharedpath = s | |
451 | except IOError as inst: |
|
451 | except IOError as inst: | |
452 | if inst.errno != errno.ENOENT: |
|
452 | if inst.errno != errno.ENOENT: | |
453 | raise |
|
453 | raise | |
454 |
|
454 | |||
455 | if 'exp-sparse' in self.requirements and not sparse.enabled: |
|
455 | if 'exp-sparse' in self.requirements and not sparse.enabled: | |
456 | raise error.RepoError(_('repository is using sparse feature but ' |
|
456 | raise error.RepoError(_('repository is using sparse feature but ' | |
457 | 'sparse is not enabled; enable the ' |
|
457 | 'sparse is not enabled; enable the ' | |
458 | '"sparse" extensions to access')) |
|
458 | '"sparse" extensions to access')) | |
459 |
|
459 | |||
460 | self.store = store.store( |
|
460 | self.store = store.store( | |
461 | self.requirements, self.sharedpath, |
|
461 | self.requirements, self.sharedpath, | |
462 | lambda base: vfsmod.vfs(base, cacheaudited=True)) |
|
462 | lambda base: vfsmod.vfs(base, cacheaudited=True)) | |
463 | self.spath = self.store.path |
|
463 | self.spath = self.store.path | |
464 | self.svfs = self.store.vfs |
|
464 | self.svfs = self.store.vfs | |
465 | self.sjoin = self.store.join |
|
465 | self.sjoin = self.store.join | |
466 | self.vfs.createmode = self.store.createmode |
|
466 | self.vfs.createmode = self.store.createmode | |
467 | self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) |
|
467 | self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) | |
468 | self.cachevfs.createmode = self.store.createmode |
|
468 | self.cachevfs.createmode = self.store.createmode | |
469 | if (self.ui.configbool('devel', 'all-warnings') or |
|
469 | if (self.ui.configbool('devel', 'all-warnings') or | |
470 | self.ui.configbool('devel', 'check-locks')): |
|
470 | self.ui.configbool('devel', 'check-locks')): | |
471 | if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs |
|
471 | if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs | |
472 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) |
|
472 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) | |
473 | else: # standard vfs |
|
473 | else: # standard vfs | |
474 | self.svfs.audit = self._getsvfsward(self.svfs.audit) |
|
474 | self.svfs.audit = self._getsvfsward(self.svfs.audit) | |
475 | self._applyopenerreqs() |
|
475 | self._applyopenerreqs() | |
476 | if create: |
|
476 | if create: | |
477 | self._writerequirements() |
|
477 | self._writerequirements() | |
478 |
|
478 | |||
479 | self._dirstatevalidatewarned = False |
|
479 | self._dirstatevalidatewarned = False | |
480 |
|
480 | |||
481 | self._branchcaches = {} |
|
481 | self._branchcaches = {} | |
482 | self._revbranchcache = None |
|
482 | self._revbranchcache = None | |
483 | self.filterpats = {} |
|
483 | self.filterpats = {} | |
484 | self._datafilters = {} |
|
484 | self._datafilters = {} | |
485 | self._transref = self._lockref = self._wlockref = None |
|
485 | self._transref = self._lockref = self._wlockref = None | |
486 |
|
486 | |||
487 | # A cache for various files under .hg/ that tracks file changes, |
|
487 | # A cache for various files under .hg/ that tracks file changes, | |
488 | # (used by the filecache decorator) |
|
488 | # (used by the filecache decorator) | |
489 | # |
|
489 | # | |
490 | # Maps a property name to its util.filecacheentry |
|
490 | # Maps a property name to its util.filecacheentry | |
491 | self._filecache = {} |
|
491 | self._filecache = {} | |
492 |
|
492 | |||
493 | # hold sets of revision to be filtered |
|
493 | # hold sets of revision to be filtered | |
494 | # should be cleared when something might have changed the filter value: |
|
494 | # should be cleared when something might have changed the filter value: | |
495 | # - new changesets, |
|
495 | # - new changesets, | |
496 | # - phase change, |
|
496 | # - phase change, | |
497 | # - new obsolescence marker, |
|
497 | # - new obsolescence marker, | |
498 | # - working directory parent change, |
|
498 | # - working directory parent change, | |
499 | # - bookmark changes |
|
499 | # - bookmark changes | |
500 | self.filteredrevcache = {} |
|
500 | self.filteredrevcache = {} | |
501 |
|
501 | |||
502 | # post-dirstate-status hooks |
|
502 | # post-dirstate-status hooks | |
503 | self._postdsstatus = [] |
|
503 | self._postdsstatus = [] | |
504 |
|
504 | |||
505 | # generic mapping between names and nodes |
|
505 | # generic mapping between names and nodes | |
506 | self.names = namespaces.namespaces() |
|
506 | self.names = namespaces.namespaces() | |
507 |
|
507 | |||
508 | # Key to signature value. |
|
508 | # Key to signature value. | |
509 | self._sparsesignaturecache = {} |
|
509 | self._sparsesignaturecache = {} | |
510 | # Signature to cached matcher instance. |
|
510 | # Signature to cached matcher instance. | |
511 | self._sparsematchercache = {} |
|
511 | self._sparsematchercache = {} | |
512 |
|
512 | |||
513 | def _getvfsward(self, origfunc): |
|
513 | def _getvfsward(self, origfunc): | |
514 | """build a ward for self.vfs""" |
|
514 | """build a ward for self.vfs""" | |
515 | rref = weakref.ref(self) |
|
515 | rref = weakref.ref(self) | |
516 | def checkvfs(path, mode=None): |
|
516 | def checkvfs(path, mode=None): | |
517 | ret = origfunc(path, mode=mode) |
|
517 | ret = origfunc(path, mode=mode) | |
518 | repo = rref() |
|
518 | repo = rref() | |
519 | if (repo is None |
|
519 | if (repo is None | |
520 | or not util.safehasattr(repo, '_wlockref') |
|
520 | or not util.safehasattr(repo, '_wlockref') | |
521 | or not util.safehasattr(repo, '_lockref')): |
|
521 | or not util.safehasattr(repo, '_lockref')): | |
522 | return |
|
522 | return | |
523 | if mode in (None, 'r', 'rb'): |
|
523 | if mode in (None, 'r', 'rb'): | |
524 | return |
|
524 | return | |
525 | if path.startswith(repo.path): |
|
525 | if path.startswith(repo.path): | |
526 | # truncate name relative to the repository (.hg) |
|
526 | # truncate name relative to the repository (.hg) | |
527 | path = path[len(repo.path) + 1:] |
|
527 | path = path[len(repo.path) + 1:] | |
528 | if path.startswith('cache/'): |
|
528 | if path.startswith('cache/'): | |
529 | msg = 'accessing cache with vfs instead of cachevfs: "%s"' |
|
529 | msg = 'accessing cache with vfs instead of cachevfs: "%s"' | |
530 | repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs") |
|
530 | repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs") | |
531 | if path.startswith('journal.'): |
|
531 | if path.startswith('journal.'): | |
532 | # journal is covered by 'lock' |
|
532 | # journal is covered by 'lock' | |
533 | if repo._currentlock(repo._lockref) is None: |
|
533 | if repo._currentlock(repo._lockref) is None: | |
534 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
534 | repo.ui.develwarn('write with no lock: "%s"' % path, | |
535 | stacklevel=2, config='check-locks') |
|
535 | stacklevel=2, config='check-locks') | |
536 | elif repo._currentlock(repo._wlockref) is None: |
|
536 | elif repo._currentlock(repo._wlockref) is None: | |
537 | # rest of vfs files are covered by 'wlock' |
|
537 | # rest of vfs files are covered by 'wlock' | |
538 | # |
|
538 | # | |
539 | # exclude special files |
|
539 | # exclude special files | |
540 | for prefix in self._wlockfreeprefix: |
|
540 | for prefix in self._wlockfreeprefix: | |
541 | if path.startswith(prefix): |
|
541 | if path.startswith(prefix): | |
542 | return |
|
542 | return | |
543 | repo.ui.develwarn('write with no wlock: "%s"' % path, |
|
543 | repo.ui.develwarn('write with no wlock: "%s"' % path, | |
544 | stacklevel=2, config='check-locks') |
|
544 | stacklevel=2, config='check-locks') | |
545 | return ret |
|
545 | return ret | |
546 | return checkvfs |
|
546 | return checkvfs | |
547 |
|
547 | |||
548 | def _getsvfsward(self, origfunc): |
|
548 | def _getsvfsward(self, origfunc): | |
549 | """build a ward for self.svfs""" |
|
549 | """build a ward for self.svfs""" | |
550 | rref = weakref.ref(self) |
|
550 | rref = weakref.ref(self) | |
551 | def checksvfs(path, mode=None): |
|
551 | def checksvfs(path, mode=None): | |
552 | ret = origfunc(path, mode=mode) |
|
552 | ret = origfunc(path, mode=mode) | |
553 | repo = rref() |
|
553 | repo = rref() | |
554 | if repo is None or not util.safehasattr(repo, '_lockref'): |
|
554 | if repo is None or not util.safehasattr(repo, '_lockref'): | |
555 | return |
|
555 | return | |
556 | if mode in (None, 'r', 'rb'): |
|
556 | if mode in (None, 'r', 'rb'): | |
557 | return |
|
557 | return | |
558 | if path.startswith(repo.sharedpath): |
|
558 | if path.startswith(repo.sharedpath): | |
559 | # truncate name relative to the repository (.hg) |
|
559 | # truncate name relative to the repository (.hg) | |
560 | path = path[len(repo.sharedpath) + 1:] |
|
560 | path = path[len(repo.sharedpath) + 1:] | |
561 | if repo._currentlock(repo._lockref) is None: |
|
561 | if repo._currentlock(repo._lockref) is None: | |
562 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
562 | repo.ui.develwarn('write with no lock: "%s"' % path, | |
563 | stacklevel=3) |
|
563 | stacklevel=3) | |
564 | return ret |
|
564 | return ret | |
565 | return checksvfs |
|
565 | return checksvfs | |
566 |
|
566 | |||
567 | def close(self): |
|
567 | def close(self): | |
568 | self._writecaches() |
|
568 | self._writecaches() | |
569 |
|
569 | |||
570 | def _loadextensions(self): |
|
570 | def _loadextensions(self): | |
571 | extensions.loadall(self.ui) |
|
571 | extensions.loadall(self.ui) | |
572 |
|
572 | |||
573 | def _writecaches(self): |
|
573 | def _writecaches(self): | |
574 | if self._revbranchcache: |
|
574 | if self._revbranchcache: | |
575 | self._revbranchcache.write() |
|
575 | self._revbranchcache.write() | |
576 |
|
576 | |||
577 | def _restrictcapabilities(self, caps): |
|
577 | def _restrictcapabilities(self, caps): | |
578 | if self.ui.configbool('experimental', 'bundle2-advertise'): |
|
578 | if self.ui.configbool('experimental', 'bundle2-advertise'): | |
579 | caps = set(caps) |
|
579 | caps = set(caps) | |
580 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self)) |
|
580 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self)) | |
581 | caps.add('bundle2=' + urlreq.quote(capsblob)) |
|
581 | caps.add('bundle2=' + urlreq.quote(capsblob)) | |
582 | return caps |
|
582 | return caps | |
583 |
|
583 | |||
584 | def _applyopenerreqs(self): |
|
584 | def _applyopenerreqs(self): | |
585 | self.svfs.options = dict((r, 1) for r in self.requirements |
|
585 | self.svfs.options = dict((r, 1) for r in self.requirements | |
586 | if r in self.openerreqs) |
|
586 | if r in self.openerreqs) | |
587 | # experimental config: format.chunkcachesize |
|
587 | # experimental config: format.chunkcachesize | |
588 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') |
|
588 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') | |
589 | if chunkcachesize is not None: |
|
589 | if chunkcachesize is not None: | |
590 | self.svfs.options['chunkcachesize'] = chunkcachesize |
|
590 | self.svfs.options['chunkcachesize'] = chunkcachesize | |
591 | # experimental config: format.maxchainlen |
|
591 | # experimental config: format.maxchainlen | |
592 | maxchainlen = self.ui.configint('format', 'maxchainlen') |
|
592 | maxchainlen = self.ui.configint('format', 'maxchainlen') | |
593 | if maxchainlen is not None: |
|
593 | if maxchainlen is not None: | |
594 | self.svfs.options['maxchainlen'] = maxchainlen |
|
594 | self.svfs.options['maxchainlen'] = maxchainlen | |
595 | # experimental config: format.manifestcachesize |
|
595 | # experimental config: format.manifestcachesize | |
596 | manifestcachesize = self.ui.configint('format', 'manifestcachesize') |
|
596 | manifestcachesize = self.ui.configint('format', 'manifestcachesize') | |
597 | if manifestcachesize is not None: |
|
597 | if manifestcachesize is not None: | |
598 | self.svfs.options['manifestcachesize'] = manifestcachesize |
|
598 | self.svfs.options['manifestcachesize'] = manifestcachesize | |
599 | # experimental config: format.aggressivemergedeltas |
|
599 | # experimental config: format.aggressivemergedeltas | |
600 | aggressivemergedeltas = self.ui.configbool('format', |
|
600 | aggressivemergedeltas = self.ui.configbool('format', | |
601 | 'aggressivemergedeltas') |
|
601 | 'aggressivemergedeltas') | |
602 | self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas |
|
602 | self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas | |
603 | self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) |
|
603 | self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) | |
604 | chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan') |
|
604 | chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan') | |
605 | if 0 <= chainspan: |
|
605 | if 0 <= chainspan: | |
606 | self.svfs.options['maxdeltachainspan'] = chainspan |
|
606 | self.svfs.options['maxdeltachainspan'] = chainspan | |
607 | mmapindexthreshold = self.ui.configbytes('experimental', |
|
607 | mmapindexthreshold = self.ui.configbytes('experimental', | |
608 | 'mmapindexthreshold') |
|
608 | 'mmapindexthreshold') | |
609 | if mmapindexthreshold is not None: |
|
609 | if mmapindexthreshold is not None: | |
610 | self.svfs.options['mmapindexthreshold'] = mmapindexthreshold |
|
610 | self.svfs.options['mmapindexthreshold'] = mmapindexthreshold | |
611 | withsparseread = self.ui.configbool('experimental', 'sparse-read') |
|
611 | withsparseread = self.ui.configbool('experimental', 'sparse-read') | |
612 | srdensitythres = float(self.ui.config('experimental', |
|
612 | srdensitythres = float(self.ui.config('experimental', | |
613 | 'sparse-read.density-threshold')) |
|
613 | 'sparse-read.density-threshold')) | |
614 | srmingapsize = self.ui.configbytes('experimental', |
|
614 | srmingapsize = self.ui.configbytes('experimental', | |
615 | 'sparse-read.min-gap-size') |
|
615 | 'sparse-read.min-gap-size') | |
616 | self.svfs.options['with-sparse-read'] = withsparseread |
|
616 | self.svfs.options['with-sparse-read'] = withsparseread | |
617 | self.svfs.options['sparse-read-density-threshold'] = srdensitythres |
|
617 | self.svfs.options['sparse-read-density-threshold'] = srdensitythres | |
618 | self.svfs.options['sparse-read-min-gap-size'] = srmingapsize |
|
618 | self.svfs.options['sparse-read-min-gap-size'] = srmingapsize | |
619 |
|
619 | |||
620 | for r in self.requirements: |
|
620 | for r in self.requirements: | |
621 | if r.startswith('exp-compression-'): |
|
621 | if r.startswith('exp-compression-'): | |
622 | self.svfs.options['compengine'] = r[len('exp-compression-'):] |
|
622 | self.svfs.options['compengine'] = r[len('exp-compression-'):] | |
623 |
|
623 | |||
624 | # TODO move "revlogv2" to openerreqs once finalized. |
|
624 | # TODO move "revlogv2" to openerreqs once finalized. | |
625 | if REVLOGV2_REQUIREMENT in self.requirements: |
|
625 | if REVLOGV2_REQUIREMENT in self.requirements: | |
626 | self.svfs.options['revlogv2'] = True |
|
626 | self.svfs.options['revlogv2'] = True | |
627 |
|
627 | |||
628 | def _writerequirements(self): |
|
628 | def _writerequirements(self): | |
629 | scmutil.writerequires(self.vfs, self.requirements) |
|
629 | scmutil.writerequires(self.vfs, self.requirements) | |
630 |
|
630 | |||
631 | def _checknested(self, path): |
|
631 | def _checknested(self, path): | |
632 | """Determine if path is a legal nested repository.""" |
|
632 | """Determine if path is a legal nested repository.""" | |
633 | if not path.startswith(self.root): |
|
633 | if not path.startswith(self.root): | |
634 | return False |
|
634 | return False | |
635 | subpath = path[len(self.root) + 1:] |
|
635 | subpath = path[len(self.root) + 1:] | |
636 | normsubpath = util.pconvert(subpath) |
|
636 | normsubpath = util.pconvert(subpath) | |
637 |
|
637 | |||
638 | # XXX: Checking against the current working copy is wrong in |
|
638 | # XXX: Checking against the current working copy is wrong in | |
639 | # the sense that it can reject things like |
|
639 | # the sense that it can reject things like | |
640 | # |
|
640 | # | |
641 | # $ hg cat -r 10 sub/x.txt |
|
641 | # $ hg cat -r 10 sub/x.txt | |
642 | # |
|
642 | # | |
643 | # if sub/ is no longer a subrepository in the working copy |
|
643 | # if sub/ is no longer a subrepository in the working copy | |
644 | # parent revision. |
|
644 | # parent revision. | |
645 | # |
|
645 | # | |
646 | # However, it can of course also allow things that would have |
|
646 | # However, it can of course also allow things that would have | |
647 | # been rejected before, such as the above cat command if sub/ |
|
647 | # been rejected before, such as the above cat command if sub/ | |
648 | # is a subrepository now, but was a normal directory before. |
|
648 | # is a subrepository now, but was a normal directory before. | |
649 | # The old path auditor would have rejected by mistake since it |
|
649 | # The old path auditor would have rejected by mistake since it | |
650 | # panics when it sees sub/.hg/. |
|
650 | # panics when it sees sub/.hg/. | |
651 | # |
|
651 | # | |
652 | # All in all, checking against the working copy seems sensible |
|
652 | # All in all, checking against the working copy seems sensible | |
653 | # since we want to prevent access to nested repositories on |
|
653 | # since we want to prevent access to nested repositories on | |
654 | # the filesystem *now*. |
|
654 | # the filesystem *now*. | |
655 | ctx = self[None] |
|
655 | ctx = self[None] | |
656 | parts = util.splitpath(subpath) |
|
656 | parts = util.splitpath(subpath) | |
657 | while parts: |
|
657 | while parts: | |
658 | prefix = '/'.join(parts) |
|
658 | prefix = '/'.join(parts) | |
659 | if prefix in ctx.substate: |
|
659 | if prefix in ctx.substate: | |
660 | if prefix == normsubpath: |
|
660 | if prefix == normsubpath: | |
661 | return True |
|
661 | return True | |
662 | else: |
|
662 | else: | |
663 | sub = ctx.sub(prefix) |
|
663 | sub = ctx.sub(prefix) | |
664 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
664 | return sub.checknested(subpath[len(prefix) + 1:]) | |
665 | else: |
|
665 | else: | |
666 | parts.pop() |
|
666 | parts.pop() | |
667 | return False |
|
667 | return False | |
668 |
|
668 | |||
669 | def peer(self): |
|
669 | def peer(self): | |
670 | return localpeer(self) # not cached to avoid reference cycle |
|
670 | return localpeer(self) # not cached to avoid reference cycle | |
671 |
|
671 | |||
672 | def unfiltered(self): |
|
672 | def unfiltered(self): | |
673 | """Return unfiltered version of the repository |
|
673 | """Return unfiltered version of the repository | |
674 |
|
674 | |||
675 | Intended to be overwritten by filtered repo.""" |
|
675 | Intended to be overwritten by filtered repo.""" | |
676 | return self |
|
676 | return self | |
677 |
|
677 | |||
678 | def filtered(self, name, visibilityexceptions=None): |
|
678 | def filtered(self, name, visibilityexceptions=None): | |
679 | """Return a filtered version of a repository""" |
|
679 | """Return a filtered version of a repository""" | |
680 | cls = repoview.newtype(self.unfiltered().__class__) |
|
680 | cls = repoview.newtype(self.unfiltered().__class__) | |
681 | return cls(self, name, visibilityexceptions) |
|
681 | return cls(self, name, visibilityexceptions) | |
682 |
|
682 | |||
683 | @repofilecache('bookmarks', 'bookmarks.current') |
|
683 | @repofilecache('bookmarks', 'bookmarks.current') | |
684 | def _bookmarks(self): |
|
684 | def _bookmarks(self): | |
685 | return bookmarks.bmstore(self) |
|
685 | return bookmarks.bmstore(self) | |
686 |
|
686 | |||
687 | @property |
|
687 | @property | |
688 | def _activebookmark(self): |
|
688 | def _activebookmark(self): | |
689 | return self._bookmarks.active |
|
689 | return self._bookmarks.active | |
690 |
|
690 | |||
691 | # _phasesets depend on changelog. what we need is to call |
|
691 | # _phasesets depend on changelog. what we need is to call | |
692 | # _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
692 | # _phasecache.invalidate() if '00changelog.i' was changed, but it | |
693 | # can't be easily expressed in filecache mechanism. |
|
693 | # can't be easily expressed in filecache mechanism. | |
694 | @storecache('phaseroots', '00changelog.i') |
|
694 | @storecache('phaseroots', '00changelog.i') | |
695 | def _phasecache(self): |
|
695 | def _phasecache(self): | |
696 | return phases.phasecache(self, self._phasedefaults) |
|
696 | return phases.phasecache(self, self._phasedefaults) | |
697 |
|
697 | |||
698 | @storecache('obsstore') |
|
698 | @storecache('obsstore') | |
699 | def obsstore(self): |
|
699 | def obsstore(self): | |
700 | return obsolete.makestore(self.ui, self) |
|
700 | return obsolete.makestore(self.ui, self) | |
701 |
|
701 | |||
702 | @storecache('00changelog.i') |
|
702 | @storecache('00changelog.i') | |
703 | def changelog(self): |
|
703 | def changelog(self): | |
704 | return changelog.changelog(self.svfs, |
|
704 | return changelog.changelog(self.svfs, | |
705 | trypending=txnutil.mayhavepending(self.root)) |
|
705 | trypending=txnutil.mayhavepending(self.root)) | |
706 |
|
706 | |||
707 | def _constructmanifest(self): |
|
707 | def _constructmanifest(self): | |
708 | # This is a temporary function while we migrate from manifest to |
|
708 | # This is a temporary function while we migrate from manifest to | |
709 | # manifestlog. It allows bundlerepo and unionrepo to intercept the |
|
709 | # manifestlog. It allows bundlerepo and unionrepo to intercept the | |
710 | # manifest creation. |
|
710 | # manifest creation. | |
711 | return manifest.manifestrevlog(self.svfs) |
|
711 | return manifest.manifestrevlog(self.svfs) | |
712 |
|
712 | |||
713 | @storecache('00manifest.i') |
|
713 | @storecache('00manifest.i') | |
714 | def manifestlog(self): |
|
714 | def manifestlog(self): | |
715 | return manifest.manifestlog(self.svfs, self) |
|
715 | return manifest.manifestlog(self.svfs, self) | |
716 |
|
716 | |||
717 | @repofilecache('dirstate') |
|
717 | @repofilecache('dirstate') | |
718 | def dirstate(self): |
|
718 | def dirstate(self): | |
719 | sparsematchfn = lambda: sparse.matcher(self) |
|
719 | sparsematchfn = lambda: sparse.matcher(self) | |
720 |
|
720 | |||
721 | return dirstate.dirstate(self.vfs, self.ui, self.root, |
|
721 | return dirstate.dirstate(self.vfs, self.ui, self.root, | |
722 | self._dirstatevalidate, sparsematchfn) |
|
722 | self._dirstatevalidate, sparsematchfn) | |
723 |
|
723 | |||
724 | def _dirstatevalidate(self, node): |
|
724 | def _dirstatevalidate(self, node): | |
725 | try: |
|
725 | try: | |
726 | self.changelog.rev(node) |
|
726 | self.changelog.rev(node) | |
727 | return node |
|
727 | return node | |
728 | except error.LookupError: |
|
728 | except error.LookupError: | |
729 | if not self._dirstatevalidatewarned: |
|
729 | if not self._dirstatevalidatewarned: | |
730 | self._dirstatevalidatewarned = True |
|
730 | self._dirstatevalidatewarned = True | |
731 | self.ui.warn(_("warning: ignoring unknown" |
|
731 | self.ui.warn(_("warning: ignoring unknown" | |
732 | " working parent %s!\n") % short(node)) |
|
732 | " working parent %s!\n") % short(node)) | |
733 | return nullid |
|
733 | return nullid | |
734 |
|
734 | |||
735 | def __getitem__(self, changeid): |
|
735 | def __getitem__(self, changeid): | |
736 | if changeid is None: |
|
736 | if changeid is None: | |
737 | return context.workingctx(self) |
|
737 | return context.workingctx(self) | |
738 | if isinstance(changeid, slice): |
|
738 | if isinstance(changeid, slice): | |
739 | # wdirrev isn't contiguous so the slice shouldn't include it |
|
739 | # wdirrev isn't contiguous so the slice shouldn't include it | |
740 | return [context.changectx(self, i) |
|
740 | return [context.changectx(self, i) | |
741 | for i in xrange(*changeid.indices(len(self))) |
|
741 | for i in xrange(*changeid.indices(len(self))) | |
742 | if i not in self.changelog.filteredrevs] |
|
742 | if i not in self.changelog.filteredrevs] | |
743 | try: |
|
743 | try: | |
744 | return context.changectx(self, changeid) |
|
744 | return context.changectx(self, changeid) | |
745 | except error.WdirUnsupported: |
|
745 | except error.WdirUnsupported: | |
746 | return context.workingctx(self) |
|
746 | return context.workingctx(self) | |
747 |
|
747 | |||
748 | def __contains__(self, changeid): |
|
748 | def __contains__(self, changeid): | |
749 | """True if the given changeid exists |
|
749 | """True if the given changeid exists | |
750 |
|
750 | |||
751 | error.LookupError is raised if an ambiguous node specified. |
|
751 | error.LookupError is raised if an ambiguous node specified. | |
752 | """ |
|
752 | """ | |
753 | try: |
|
753 | try: | |
754 | self[changeid] |
|
754 | self[changeid] | |
755 | return True |
|
755 | return True | |
756 | except error.RepoLookupError: |
|
756 | except error.RepoLookupError: | |
757 | return False |
|
757 | return False | |
758 |
|
758 | |||
759 | def __nonzero__(self): |
|
759 | def __nonzero__(self): | |
760 | return True |
|
760 | return True | |
761 |
|
761 | |||
762 | __bool__ = __nonzero__ |
|
762 | __bool__ = __nonzero__ | |
763 |
|
763 | |||
764 | def __len__(self): |
|
764 | def __len__(self): | |
765 | return len(self.changelog) |
|
765 | return len(self.changelog) | |
766 |
|
766 | |||
767 | def __iter__(self): |
|
767 | def __iter__(self): | |
768 | return iter(self.changelog) |
|
768 | return iter(self.changelog) | |
769 |
|
769 | |||
770 | def revs(self, expr, *args): |
|
770 | def revs(self, expr, *args): | |
771 | '''Find revisions matching a revset. |
|
771 | '''Find revisions matching a revset. | |
772 |
|
772 | |||
773 | The revset is specified as a string ``expr`` that may contain |
|
773 | The revset is specified as a string ``expr`` that may contain | |
774 | %-formatting to escape certain types. See ``revsetlang.formatspec``. |
|
774 | %-formatting to escape certain types. See ``revsetlang.formatspec``. | |
775 |
|
775 | |||
776 | Revset aliases from the configuration are not expanded. To expand |
|
776 | Revset aliases from the configuration are not expanded. To expand | |
777 | user aliases, consider calling ``scmutil.revrange()`` or |
|
777 | user aliases, consider calling ``scmutil.revrange()`` or | |
778 | ``repo.anyrevs([expr], user=True)``. |
|
778 | ``repo.anyrevs([expr], user=True)``. | |
779 |
|
779 | |||
780 | Returns a revset.abstractsmartset, which is a list-like interface |
|
780 | Returns a revset.abstractsmartset, which is a list-like interface | |
781 | that contains integer revisions. |
|
781 | that contains integer revisions. | |
782 | ''' |
|
782 | ''' | |
783 | expr = revsetlang.formatspec(expr, *args) |
|
783 | expr = revsetlang.formatspec(expr, *args) | |
784 | m = revset.match(None, expr) |
|
784 | m = revset.match(None, expr) | |
785 | return m(self) |
|
785 | return m(self) | |
786 |
|
786 | |||
787 | def set(self, expr, *args): |
|
787 | def set(self, expr, *args): | |
788 | '''Find revisions matching a revset and emit changectx instances. |
|
788 | '''Find revisions matching a revset and emit changectx instances. | |
789 |
|
789 | |||
790 | This is a convenience wrapper around ``revs()`` that iterates the |
|
790 | This is a convenience wrapper around ``revs()`` that iterates the | |
791 | result and is a generator of changectx instances. |
|
791 | result and is a generator of changectx instances. | |
792 |
|
792 | |||
793 | Revset aliases from the configuration are not expanded. To expand |
|
793 | Revset aliases from the configuration are not expanded. To expand | |
794 | user aliases, consider calling ``scmutil.revrange()``. |
|
794 | user aliases, consider calling ``scmutil.revrange()``. | |
795 | ''' |
|
795 | ''' | |
796 | for r in self.revs(expr, *args): |
|
796 | for r in self.revs(expr, *args): | |
797 | yield self[r] |
|
797 | yield self[r] | |
798 |
|
798 | |||
799 | def anyrevs(self, specs, user=False, localalias=None): |
|
799 | def anyrevs(self, specs, user=False, localalias=None): | |
800 | '''Find revisions matching one of the given revsets. |
|
800 | '''Find revisions matching one of the given revsets. | |
801 |
|
801 | |||
802 | Revset aliases from the configuration are not expanded by default. To |
|
802 | Revset aliases from the configuration are not expanded by default. To | |
803 | expand user aliases, specify ``user=True``. To provide some local |
|
803 | expand user aliases, specify ``user=True``. To provide some local | |
804 | definitions overriding user aliases, set ``localalias`` to |
|
804 | definitions overriding user aliases, set ``localalias`` to | |
805 | ``{name: definitionstring}``. |
|
805 | ``{name: definitionstring}``. | |
806 | ''' |
|
806 | ''' | |
807 | if user: |
|
807 | if user: | |
808 | m = revset.matchany(self.ui, specs, repo=self, |
|
808 | m = revset.matchany(self.ui, specs, repo=self, | |
809 | localalias=localalias) |
|
809 | localalias=localalias) | |
810 | else: |
|
810 | else: | |
811 | m = revset.matchany(None, specs, localalias=localalias) |
|
811 | m = revset.matchany(None, specs, localalias=localalias) | |
812 | return m(self) |
|
812 | return m(self) | |
813 |
|
813 | |||
814 | def url(self): |
|
814 | def url(self): | |
815 | return 'file:' + self.root |
|
815 | return 'file:' + self.root | |
816 |
|
816 | |||
817 | def hook(self, name, throw=False, **args): |
|
817 | def hook(self, name, throw=False, **args): | |
818 | """Call a hook, passing this repo instance. |
|
818 | """Call a hook, passing this repo instance. | |
819 |
|
819 | |||
820 | This a convenience method to aid invoking hooks. Extensions likely |
|
820 | This a convenience method to aid invoking hooks. Extensions likely | |
821 | won't call this unless they have registered a custom hook or are |
|
821 | won't call this unless they have registered a custom hook or are | |
822 | replacing code that is expected to call a hook. |
|
822 | replacing code that is expected to call a hook. | |
823 | """ |
|
823 | """ | |
824 | return hook.hook(self.ui, self, name, throw, **args) |
|
824 | return hook.hook(self.ui, self, name, throw, **args) | |
825 |
|
825 | |||
826 | @filteredpropertycache |
|
826 | @filteredpropertycache | |
827 | def _tagscache(self): |
|
827 | def _tagscache(self): | |
828 | '''Returns a tagscache object that contains various tags related |
|
828 | '''Returns a tagscache object that contains various tags related | |
829 | caches.''' |
|
829 | caches.''' | |
830 |
|
830 | |||
831 | # This simplifies its cache management by having one decorated |
|
831 | # This simplifies its cache management by having one decorated | |
832 | # function (this one) and the rest simply fetch things from it. |
|
832 | # function (this one) and the rest simply fetch things from it. | |
833 | class tagscache(object): |
|
833 | class tagscache(object): | |
834 | def __init__(self): |
|
834 | def __init__(self): | |
835 | # These two define the set of tags for this repository. tags |
|
835 | # These two define the set of tags for this repository. tags | |
836 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
836 | # maps tag name to node; tagtypes maps tag name to 'global' or | |
837 | # 'local'. (Global tags are defined by .hgtags across all |
|
837 | # 'local'. (Global tags are defined by .hgtags across all | |
838 | # heads, and local tags are defined in .hg/localtags.) |
|
838 | # heads, and local tags are defined in .hg/localtags.) | |
839 | # They constitute the in-memory cache of tags. |
|
839 | # They constitute the in-memory cache of tags. | |
840 | self.tags = self.tagtypes = None |
|
840 | self.tags = self.tagtypes = None | |
841 |
|
841 | |||
842 | self.nodetagscache = self.tagslist = None |
|
842 | self.nodetagscache = self.tagslist = None | |
843 |
|
843 | |||
844 | cache = tagscache() |
|
844 | cache = tagscache() | |
845 | cache.tags, cache.tagtypes = self._findtags() |
|
845 | cache.tags, cache.tagtypes = self._findtags() | |
846 |
|
846 | |||
847 | return cache |
|
847 | return cache | |
848 |
|
848 | |||
849 | def tags(self): |
|
849 | def tags(self): | |
850 | '''return a mapping of tag to node''' |
|
850 | '''return a mapping of tag to node''' | |
851 | t = {} |
|
851 | t = {} | |
852 | if self.changelog.filteredrevs: |
|
852 | if self.changelog.filteredrevs: | |
853 | tags, tt = self._findtags() |
|
853 | tags, tt = self._findtags() | |
854 | else: |
|
854 | else: | |
855 | tags = self._tagscache.tags |
|
855 | tags = self._tagscache.tags | |
856 | for k, v in tags.iteritems(): |
|
856 | for k, v in tags.iteritems(): | |
857 | try: |
|
857 | try: | |
858 | # ignore tags to unknown nodes |
|
858 | # ignore tags to unknown nodes | |
859 | self.changelog.rev(v) |
|
859 | self.changelog.rev(v) | |
860 | t[k] = v |
|
860 | t[k] = v | |
861 | except (error.LookupError, ValueError): |
|
861 | except (error.LookupError, ValueError): | |
862 | pass |
|
862 | pass | |
863 | return t |
|
863 | return t | |
864 |
|
864 | |||
865 | def _findtags(self): |
|
865 | def _findtags(self): | |
866 | '''Do the hard work of finding tags. Return a pair of dicts |
|
866 | '''Do the hard work of finding tags. Return a pair of dicts | |
867 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
867 | (tags, tagtypes) where tags maps tag name to node, and tagtypes | |
868 | maps tag name to a string like \'global\' or \'local\'. |
|
868 | maps tag name to a string like \'global\' or \'local\'. | |
869 | Subclasses or extensions are free to add their own tags, but |
|
869 | Subclasses or extensions are free to add their own tags, but | |
870 | should be aware that the returned dicts will be retained for the |
|
870 | should be aware that the returned dicts will be retained for the | |
871 | duration of the localrepo object.''' |
|
871 | duration of the localrepo object.''' | |
872 |
|
872 | |||
873 | # XXX what tagtype should subclasses/extensions use? Currently |
|
873 | # XXX what tagtype should subclasses/extensions use? Currently | |
874 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
874 | # mq and bookmarks add tags, but do not set the tagtype at all. | |
875 | # Should each extension invent its own tag type? Should there |
|
875 | # Should each extension invent its own tag type? Should there | |
876 | # be one tagtype for all such "virtual" tags? Or is the status |
|
876 | # be one tagtype for all such "virtual" tags? Or is the status | |
877 | # quo fine? |
|
877 | # quo fine? | |
878 |
|
878 | |||
879 |
|
879 | |||
880 | # map tag name to (node, hist) |
|
880 | # map tag name to (node, hist) | |
881 | alltags = tagsmod.findglobaltags(self.ui, self) |
|
881 | alltags = tagsmod.findglobaltags(self.ui, self) | |
882 | # map tag name to tag type |
|
882 | # map tag name to tag type | |
883 | tagtypes = dict((tag, 'global') for tag in alltags) |
|
883 | tagtypes = dict((tag, 'global') for tag in alltags) | |
884 |
|
884 | |||
885 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
885 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) | |
886 |
|
886 | |||
887 | # Build the return dicts. Have to re-encode tag names because |
|
887 | # Build the return dicts. Have to re-encode tag names because | |
888 | # the tags module always uses UTF-8 (in order not to lose info |
|
888 | # the tags module always uses UTF-8 (in order not to lose info | |
889 | # writing to the cache), but the rest of Mercurial wants them in |
|
889 | # writing to the cache), but the rest of Mercurial wants them in | |
890 | # local encoding. |
|
890 | # local encoding. | |
891 | tags = {} |
|
891 | tags = {} | |
892 | for (name, (node, hist)) in alltags.iteritems(): |
|
892 | for (name, (node, hist)) in alltags.iteritems(): | |
893 | if node != nullid: |
|
893 | if node != nullid: | |
894 | tags[encoding.tolocal(name)] = node |
|
894 | tags[encoding.tolocal(name)] = node | |
895 | tags['tip'] = self.changelog.tip() |
|
895 | tags['tip'] = self.changelog.tip() | |
896 | tagtypes = dict([(encoding.tolocal(name), value) |
|
896 | tagtypes = dict([(encoding.tolocal(name), value) | |
897 | for (name, value) in tagtypes.iteritems()]) |
|
897 | for (name, value) in tagtypes.iteritems()]) | |
898 | return (tags, tagtypes) |
|
898 | return (tags, tagtypes) | |
899 |
|
899 | |||
900 | def tagtype(self, tagname): |
|
900 | def tagtype(self, tagname): | |
901 | ''' |
|
901 | ''' | |
902 | return the type of the given tag. result can be: |
|
902 | return the type of the given tag. result can be: | |
903 |
|
903 | |||
904 | 'local' : a local tag |
|
904 | 'local' : a local tag | |
905 | 'global' : a global tag |
|
905 | 'global' : a global tag | |
906 | None : tag does not exist |
|
906 | None : tag does not exist | |
907 | ''' |
|
907 | ''' | |
908 |
|
908 | |||
909 | return self._tagscache.tagtypes.get(tagname) |
|
909 | return self._tagscache.tagtypes.get(tagname) | |
910 |
|
910 | |||
911 | def tagslist(self): |
|
911 | def tagslist(self): | |
912 | '''return a list of tags ordered by revision''' |
|
912 | '''return a list of tags ordered by revision''' | |
913 | if not self._tagscache.tagslist: |
|
913 | if not self._tagscache.tagslist: | |
914 | l = [] |
|
914 | l = [] | |
915 | for t, n in self.tags().iteritems(): |
|
915 | for t, n in self.tags().iteritems(): | |
916 | l.append((self.changelog.rev(n), t, n)) |
|
916 | l.append((self.changelog.rev(n), t, n)) | |
917 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
917 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] | |
918 |
|
918 | |||
919 | return self._tagscache.tagslist |
|
919 | return self._tagscache.tagslist | |
920 |
|
920 | |||
921 | def nodetags(self, node): |
|
921 | def nodetags(self, node): | |
922 | '''return the tags associated with a node''' |
|
922 | '''return the tags associated with a node''' | |
923 | if not self._tagscache.nodetagscache: |
|
923 | if not self._tagscache.nodetagscache: | |
924 | nodetagscache = {} |
|
924 | nodetagscache = {} | |
925 | for t, n in self._tagscache.tags.iteritems(): |
|
925 | for t, n in self._tagscache.tags.iteritems(): | |
926 | nodetagscache.setdefault(n, []).append(t) |
|
926 | nodetagscache.setdefault(n, []).append(t) | |
927 | for tags in nodetagscache.itervalues(): |
|
927 | for tags in nodetagscache.itervalues(): | |
928 | tags.sort() |
|
928 | tags.sort() | |
929 | self._tagscache.nodetagscache = nodetagscache |
|
929 | self._tagscache.nodetagscache = nodetagscache | |
930 | return self._tagscache.nodetagscache.get(node, []) |
|
930 | return self._tagscache.nodetagscache.get(node, []) | |
931 |
|
931 | |||
932 | def nodebookmarks(self, node): |
|
932 | def nodebookmarks(self, node): | |
933 | """return the list of bookmarks pointing to the specified node""" |
|
933 | """return the list of bookmarks pointing to the specified node""" | |
934 | marks = [] |
|
934 | marks = [] | |
935 | for bookmark, n in self._bookmarks.iteritems(): |
|
935 | for bookmark, n in self._bookmarks.iteritems(): | |
936 | if n == node: |
|
936 | if n == node: | |
937 | marks.append(bookmark) |
|
937 | marks.append(bookmark) | |
938 | return sorted(marks) |
|
938 | return sorted(marks) | |
939 |
|
939 | |||
940 | def branchmap(self): |
|
940 | def branchmap(self): | |
941 | '''returns a dictionary {branch: [branchheads]} with branchheads |
|
941 | '''returns a dictionary {branch: [branchheads]} with branchheads | |
942 | ordered by increasing revision number''' |
|
942 | ordered by increasing revision number''' | |
943 | branchmap.updatecache(self) |
|
943 | branchmap.updatecache(self) | |
944 | return self._branchcaches[self.filtername] |
|
944 | return self._branchcaches[self.filtername] | |
945 |
|
945 | |||
946 | @unfilteredmethod |
|
946 | @unfilteredmethod | |
947 | def revbranchcache(self): |
|
947 | def revbranchcache(self): | |
948 | if not self._revbranchcache: |
|
948 | if not self._revbranchcache: | |
949 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
949 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) | |
950 | return self._revbranchcache |
|
950 | return self._revbranchcache | |
951 |
|
951 | |||
952 | def branchtip(self, branch, ignoremissing=False): |
|
952 | def branchtip(self, branch, ignoremissing=False): | |
953 | '''return the tip node for a given branch |
|
953 | '''return the tip node for a given branch | |
954 |
|
954 | |||
955 | If ignoremissing is True, then this method will not raise an error. |
|
955 | If ignoremissing is True, then this method will not raise an error. | |
956 | This is helpful for callers that only expect None for a missing branch |
|
956 | This is helpful for callers that only expect None for a missing branch | |
957 | (e.g. namespace). |
|
957 | (e.g. namespace). | |
958 |
|
958 | |||
959 | ''' |
|
959 | ''' | |
960 | try: |
|
960 | try: | |
961 | return self.branchmap().branchtip(branch) |
|
961 | return self.branchmap().branchtip(branch) | |
962 | except KeyError: |
|
962 | except KeyError: | |
963 | if not ignoremissing: |
|
963 | if not ignoremissing: | |
964 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
964 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) | |
965 | else: |
|
965 | else: | |
966 | pass |
|
966 | pass | |
967 |
|
967 | |||
968 | def lookup(self, key): |
|
968 | def lookup(self, key): | |
969 | return self[key].node() |
|
969 | return self[key].node() | |
970 |
|
970 | |||
971 | def lookupbranch(self, key, remote=None): |
|
971 | def lookupbranch(self, key, remote=None): | |
972 | repo = remote or self |
|
972 | repo = remote or self | |
973 | if key in repo.branchmap(): |
|
973 | if key in repo.branchmap(): | |
974 | return key |
|
974 | return key | |
975 |
|
975 | |||
976 | repo = (remote and remote.local()) and remote or self |
|
976 | repo = (remote and remote.local()) and remote or self | |
977 | return repo[key].branch() |
|
977 | return repo[key].branch() | |
978 |
|
978 | |||
979 | def known(self, nodes): |
|
979 | def known(self, nodes): | |
980 | cl = self.changelog |
|
980 | cl = self.changelog | |
981 | nm = cl.nodemap |
|
981 | nm = cl.nodemap | |
982 | filtered = cl.filteredrevs |
|
982 | filtered = cl.filteredrevs | |
983 | result = [] |
|
983 | result = [] | |
984 | for n in nodes: |
|
984 | for n in nodes: | |
985 | r = nm.get(n) |
|
985 | r = nm.get(n) | |
986 | resp = not (r is None or r in filtered) |
|
986 | resp = not (r is None or r in filtered) | |
987 | result.append(resp) |
|
987 | result.append(resp) | |
988 | return result |
|
988 | return result | |
989 |
|
989 | |||
990 | def local(self): |
|
990 | def local(self): | |
991 | return self |
|
991 | return self | |
992 |
|
992 | |||
993 | def publishing(self): |
|
993 | def publishing(self): | |
994 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
994 | # it's safe (and desirable) to trust the publish flag unconditionally | |
995 | # so that we don't finalize changes shared between users via ssh or nfs |
|
995 | # so that we don't finalize changes shared between users via ssh or nfs | |
996 | return self.ui.configbool('phases', 'publish', untrusted=True) |
|
996 | return self.ui.configbool('phases', 'publish', untrusted=True) | |
997 |
|
997 | |||
998 | def cancopy(self): |
|
998 | def cancopy(self): | |
999 | # so statichttprepo's override of local() works |
|
999 | # so statichttprepo's override of local() works | |
1000 | if not self.local(): |
|
1000 | if not self.local(): | |
1001 | return False |
|
1001 | return False | |
1002 | if not self.publishing(): |
|
1002 | if not self.publishing(): | |
1003 | return True |
|
1003 | return True | |
1004 | # if publishing we can't copy if there is filtered content |
|
1004 | # if publishing we can't copy if there is filtered content | |
1005 | return not self.filtered('visible').changelog.filteredrevs |
|
1005 | return not self.filtered('visible').changelog.filteredrevs | |
1006 |
|
1006 | |||
1007 | def shared(self): |
|
1007 | def shared(self): | |
1008 | '''the type of shared repository (None if not shared)''' |
|
1008 | '''the type of shared repository (None if not shared)''' | |
1009 | if self.sharedpath != self.path: |
|
1009 | if self.sharedpath != self.path: | |
1010 | return 'store' |
|
1010 | return 'store' | |
1011 | return None |
|
1011 | return None | |
1012 |
|
1012 | |||
1013 | def wjoin(self, f, *insidef): |
|
1013 | def wjoin(self, f, *insidef): | |
1014 | return self.vfs.reljoin(self.root, f, *insidef) |
|
1014 | return self.vfs.reljoin(self.root, f, *insidef) | |
1015 |
|
1015 | |||
1016 | def file(self, f): |
|
1016 | def file(self, f): | |
1017 | if f[0] == '/': |
|
1017 | if f[0] == '/': | |
1018 | f = f[1:] |
|
1018 | f = f[1:] | |
1019 | return filelog.filelog(self.svfs, f) |
|
1019 | return filelog.filelog(self.svfs, f) | |
1020 |
|
1020 | |||
1021 | def changectx(self, changeid): |
|
1021 | def changectx(self, changeid): | |
1022 | return self[changeid] |
|
1022 | return self[changeid] | |
1023 |
|
1023 | |||
1024 | def setparents(self, p1, p2=nullid): |
|
1024 | def setparents(self, p1, p2=nullid): | |
1025 | with self.dirstate.parentchange(): |
|
1025 | with self.dirstate.parentchange(): | |
1026 | copies = self.dirstate.setparents(p1, p2) |
|
1026 | copies = self.dirstate.setparents(p1, p2) | |
1027 | pctx = self[p1] |
|
1027 | pctx = self[p1] | |
1028 | if copies: |
|
1028 | if copies: | |
1029 | # Adjust copy records, the dirstate cannot do it, it |
|
1029 | # Adjust copy records, the dirstate cannot do it, it | |
1030 | # requires access to parents manifests. Preserve them |
|
1030 | # requires access to parents manifests. Preserve them | |
1031 | # only for entries added to first parent. |
|
1031 | # only for entries added to first parent. | |
1032 | for f in copies: |
|
1032 | for f in copies: | |
1033 | if f not in pctx and copies[f] in pctx: |
|
1033 | if f not in pctx and copies[f] in pctx: | |
1034 | self.dirstate.copy(copies[f], f) |
|
1034 | self.dirstate.copy(copies[f], f) | |
1035 | if p2 == nullid: |
|
1035 | if p2 == nullid: | |
1036 | for f, s in sorted(self.dirstate.copies().items()): |
|
1036 | for f, s in sorted(self.dirstate.copies().items()): | |
1037 | if f not in pctx and s not in pctx: |
|
1037 | if f not in pctx and s not in pctx: | |
1038 | self.dirstate.copy(None, f) |
|
1038 | self.dirstate.copy(None, f) | |
1039 |
|
1039 | |||
1040 | def filectx(self, path, changeid=None, fileid=None): |
|
1040 | def filectx(self, path, changeid=None, fileid=None): | |
1041 | """changeid can be a changeset revision, node, or tag. |
|
1041 | """changeid can be a changeset revision, node, or tag. | |
1042 | fileid can be a file revision or node.""" |
|
1042 | fileid can be a file revision or node.""" | |
1043 | return context.filectx(self, path, changeid, fileid) |
|
1043 | return context.filectx(self, path, changeid, fileid) | |
1044 |
|
1044 | |||
1045 | def getcwd(self): |
|
1045 | def getcwd(self): | |
1046 | return self.dirstate.getcwd() |
|
1046 | return self.dirstate.getcwd() | |
1047 |
|
1047 | |||
1048 | def pathto(self, f, cwd=None): |
|
1048 | def pathto(self, f, cwd=None): | |
1049 | return self.dirstate.pathto(f, cwd) |
|
1049 | return self.dirstate.pathto(f, cwd) | |
1050 |
|
1050 | |||
1051 | def _loadfilter(self, filter): |
|
1051 | def _loadfilter(self, filter): | |
1052 | if filter not in self.filterpats: |
|
1052 | if filter not in self.filterpats: | |
1053 | l = [] |
|
1053 | l = [] | |
1054 | for pat, cmd in self.ui.configitems(filter): |
|
1054 | for pat, cmd in self.ui.configitems(filter): | |
1055 | if cmd == '!': |
|
1055 | if cmd == '!': | |
1056 | continue |
|
1056 | continue | |
1057 | mf = matchmod.match(self.root, '', [pat]) |
|
1057 | mf = matchmod.match(self.root, '', [pat]) | |
1058 | fn = None |
|
1058 | fn = None | |
1059 | params = cmd |
|
1059 | params = cmd | |
1060 | for name, filterfn in self._datafilters.iteritems(): |
|
1060 | for name, filterfn in self._datafilters.iteritems(): | |
1061 | if cmd.startswith(name): |
|
1061 | if cmd.startswith(name): | |
1062 | fn = filterfn |
|
1062 | fn = filterfn | |
1063 | params = cmd[len(name):].lstrip() |
|
1063 | params = cmd[len(name):].lstrip() | |
1064 | break |
|
1064 | break | |
1065 | if not fn: |
|
1065 | if not fn: | |
1066 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
1066 | fn = lambda s, c, **kwargs: util.filter(s, c) | |
1067 | # Wrap old filters not supporting keyword arguments |
|
1067 | # Wrap old filters not supporting keyword arguments | |
1068 | if not inspect.getargspec(fn)[2]: |
|
1068 | if not inspect.getargspec(fn)[2]: | |
1069 | oldfn = fn |
|
1069 | oldfn = fn | |
1070 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
1070 | fn = lambda s, c, **kwargs: oldfn(s, c) | |
1071 | l.append((mf, fn, params)) |
|
1071 | l.append((mf, fn, params)) | |
1072 | self.filterpats[filter] = l |
|
1072 | self.filterpats[filter] = l | |
1073 | return self.filterpats[filter] |
|
1073 | return self.filterpats[filter] | |
1074 |
|
1074 | |||
1075 | def _filter(self, filterpats, filename, data): |
|
1075 | def _filter(self, filterpats, filename, data): | |
1076 | for mf, fn, cmd in filterpats: |
|
1076 | for mf, fn, cmd in filterpats: | |
1077 | if mf(filename): |
|
1077 | if mf(filename): | |
1078 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
1078 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) | |
1079 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
1079 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) | |
1080 | break |
|
1080 | break | |
1081 |
|
1081 | |||
1082 | return data |
|
1082 | return data | |
1083 |
|
1083 | |||
1084 | @unfilteredpropertycache |
|
1084 | @unfilteredpropertycache | |
1085 | def _encodefilterpats(self): |
|
1085 | def _encodefilterpats(self): | |
1086 | return self._loadfilter('encode') |
|
1086 | return self._loadfilter('encode') | |
1087 |
|
1087 | |||
1088 | @unfilteredpropertycache |
|
1088 | @unfilteredpropertycache | |
1089 | def _decodefilterpats(self): |
|
1089 | def _decodefilterpats(self): | |
1090 | return self._loadfilter('decode') |
|
1090 | return self._loadfilter('decode') | |
1091 |
|
1091 | |||
1092 | def adddatafilter(self, name, filter): |
|
1092 | def adddatafilter(self, name, filter): | |
1093 | self._datafilters[name] = filter |
|
1093 | self._datafilters[name] = filter | |
1094 |
|
1094 | |||
1095 | def wread(self, filename): |
|
1095 | def wread(self, filename): | |
1096 | if self.wvfs.islink(filename): |
|
1096 | if self.wvfs.islink(filename): | |
1097 | data = self.wvfs.readlink(filename) |
|
1097 | data = self.wvfs.readlink(filename) | |
1098 | else: |
|
1098 | else: | |
1099 | data = self.wvfs.read(filename) |
|
1099 | data = self.wvfs.read(filename) | |
1100 | return self._filter(self._encodefilterpats, filename, data) |
|
1100 | return self._filter(self._encodefilterpats, filename, data) | |
1101 |
|
1101 | |||
1102 | def wwrite(self, filename, data, flags, backgroundclose=False): |
|
1102 | def wwrite(self, filename, data, flags, backgroundclose=False): | |
1103 | """write ``data`` into ``filename`` in the working directory |
|
1103 | """write ``data`` into ``filename`` in the working directory | |
1104 |
|
1104 | |||
1105 | This returns length of written (maybe decoded) data. |
|
1105 | This returns length of written (maybe decoded) data. | |
1106 | """ |
|
1106 | """ | |
1107 | data = self._filter(self._decodefilterpats, filename, data) |
|
1107 | data = self._filter(self._decodefilterpats, filename, data) | |
1108 | if 'l' in flags: |
|
1108 | if 'l' in flags: | |
1109 | self.wvfs.symlink(data, filename) |
|
1109 | self.wvfs.symlink(data, filename) | |
1110 | else: |
|
1110 | else: | |
1111 | self.wvfs.write(filename, data, backgroundclose=backgroundclose) |
|
1111 | self.wvfs.write(filename, data, backgroundclose=backgroundclose) | |
1112 | if 'x' in flags: |
|
1112 | if 'x' in flags: | |
1113 | self.wvfs.setflags(filename, False, True) |
|
1113 | self.wvfs.setflags(filename, False, True) | |
1114 | return len(data) |
|
1114 | return len(data) | |
1115 |
|
1115 | |||
1116 | def wwritedata(self, filename, data): |
|
1116 | def wwritedata(self, filename, data): | |
1117 | return self._filter(self._decodefilterpats, filename, data) |
|
1117 | return self._filter(self._decodefilterpats, filename, data) | |
1118 |
|
1118 | |||
1119 | def currenttransaction(self): |
|
1119 | def currenttransaction(self): | |
1120 | """return the current transaction or None if non exists""" |
|
1120 | """return the current transaction or None if non exists""" | |
1121 | if self._transref: |
|
1121 | if self._transref: | |
1122 | tr = self._transref() |
|
1122 | tr = self._transref() | |
1123 | else: |
|
1123 | else: | |
1124 | tr = None |
|
1124 | tr = None | |
1125 |
|
1125 | |||
1126 | if tr and tr.running(): |
|
1126 | if tr and tr.running(): | |
1127 | return tr |
|
1127 | return tr | |
1128 | return None |
|
1128 | return None | |
1129 |
|
1129 | |||
1130 | def transaction(self, desc, report=None): |
|
1130 | def transaction(self, desc, report=None): | |
1131 | if (self.ui.configbool('devel', 'all-warnings') |
|
1131 | if (self.ui.configbool('devel', 'all-warnings') | |
1132 | or self.ui.configbool('devel', 'check-locks')): |
|
1132 | or self.ui.configbool('devel', 'check-locks')): | |
1133 | if self._currentlock(self._lockref) is None: |
|
1133 | if self._currentlock(self._lockref) is None: | |
1134 | raise error.ProgrammingError('transaction requires locking') |
|
1134 | raise error.ProgrammingError('transaction requires locking') | |
1135 | tr = self.currenttransaction() |
|
1135 | tr = self.currenttransaction() | |
1136 | if tr is not None: |
|
1136 | if tr is not None: | |
1137 | scmutil.registersummarycallback(self, tr, desc) |
|
|||
1138 | return tr.nest() |
|
1137 | return tr.nest() | |
1139 |
|
1138 | |||
1140 | # abort here if the journal already exists |
|
1139 | # abort here if the journal already exists | |
1141 | if self.svfs.exists("journal"): |
|
1140 | if self.svfs.exists("journal"): | |
1142 | raise error.RepoError( |
|
1141 | raise error.RepoError( | |
1143 | _("abandoned transaction found"), |
|
1142 | _("abandoned transaction found"), | |
1144 | hint=_("run 'hg recover' to clean up transaction")) |
|
1143 | hint=_("run 'hg recover' to clean up transaction")) | |
1145 |
|
1144 | |||
1146 | idbase = "%.40f#%f" % (random.random(), time.time()) |
|
1145 | idbase = "%.40f#%f" % (random.random(), time.time()) | |
1147 | ha = hex(hashlib.sha1(idbase).digest()) |
|
1146 | ha = hex(hashlib.sha1(idbase).digest()) | |
1148 | txnid = 'TXN:' + ha |
|
1147 | txnid = 'TXN:' + ha | |
1149 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
1148 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) | |
1150 |
|
1149 | |||
1151 | self._writejournal(desc) |
|
1150 | self._writejournal(desc) | |
1152 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
1151 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] | |
1153 | if report: |
|
1152 | if report: | |
1154 | rp = report |
|
1153 | rp = report | |
1155 | else: |
|
1154 | else: | |
1156 | rp = self.ui.warn |
|
1155 | rp = self.ui.warn | |
1157 | vfsmap = {'plain': self.vfs} # root of .hg/ |
|
1156 | vfsmap = {'plain': self.vfs} # root of .hg/ | |
1158 | # we must avoid cyclic reference between repo and transaction. |
|
1157 | # we must avoid cyclic reference between repo and transaction. | |
1159 | reporef = weakref.ref(self) |
|
1158 | reporef = weakref.ref(self) | |
1160 | # Code to track tag movement |
|
1159 | # Code to track tag movement | |
1161 | # |
|
1160 | # | |
1162 | # Since tags are all handled as file content, it is actually quite hard |
|
1161 | # Since tags are all handled as file content, it is actually quite hard | |
1163 | # to track these movement from a code perspective. So we fallback to a |
|
1162 | # to track these movement from a code perspective. So we fallback to a | |
1164 | # tracking at the repository level. One could envision to track changes |
|
1163 | # tracking at the repository level. One could envision to track changes | |
1165 | # to the '.hgtags' file through changegroup apply but that fails to |
|
1164 | # to the '.hgtags' file through changegroup apply but that fails to | |
1166 | # cope with case where transaction expose new heads without changegroup |
|
1165 | # cope with case where transaction expose new heads without changegroup | |
1167 | # being involved (eg: phase movement). |
|
1166 | # being involved (eg: phase movement). | |
1168 | # |
|
1167 | # | |
1169 | # For now, We gate the feature behind a flag since this likely comes |
|
1168 | # For now, We gate the feature behind a flag since this likely comes | |
1170 | # with performance impacts. The current code run more often than needed |
|
1169 | # with performance impacts. The current code run more often than needed | |
1171 | # and do not use caches as much as it could. The current focus is on |
|
1170 | # and do not use caches as much as it could. The current focus is on | |
1172 | # the behavior of the feature so we disable it by default. The flag |
|
1171 | # the behavior of the feature so we disable it by default. The flag | |
1173 | # will be removed when we are happy with the performance impact. |
|
1172 | # will be removed when we are happy with the performance impact. | |
1174 | # |
|
1173 | # | |
1175 | # Once this feature is no longer experimental move the following |
|
1174 | # Once this feature is no longer experimental move the following | |
1176 | # documentation to the appropriate help section: |
|
1175 | # documentation to the appropriate help section: | |
1177 | # |
|
1176 | # | |
1178 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched |
|
1177 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched | |
1179 | # tags (new or changed or deleted tags). In addition the details of |
|
1178 | # tags (new or changed or deleted tags). In addition the details of | |
1180 | # these changes are made available in a file at: |
|
1179 | # these changes are made available in a file at: | |
1181 | # ``REPOROOT/.hg/changes/tags.changes``. |
|
1180 | # ``REPOROOT/.hg/changes/tags.changes``. | |
1182 | # Make sure you check for HG_TAG_MOVED before reading that file as it |
|
1181 | # Make sure you check for HG_TAG_MOVED before reading that file as it | |
1183 | # might exist from a previous transaction even if no tag were touched |
|
1182 | # might exist from a previous transaction even if no tag were touched | |
1184 | # in this one. Changes are recorded in a line base format:: |
|
1183 | # in this one. Changes are recorded in a line base format:: | |
1185 | # |
|
1184 | # | |
1186 | # <action> <hex-node> <tag-name>\n |
|
1185 | # <action> <hex-node> <tag-name>\n | |
1187 | # |
|
1186 | # | |
1188 | # Actions are defined as follow: |
|
1187 | # Actions are defined as follow: | |
1189 | # "-R": tag is removed, |
|
1188 | # "-R": tag is removed, | |
1190 | # "+A": tag is added, |
|
1189 | # "+A": tag is added, | |
1191 | # "-M": tag is moved (old value), |
|
1190 | # "-M": tag is moved (old value), | |
1192 | # "+M": tag is moved (new value), |
|
1191 | # "+M": tag is moved (new value), | |
1193 | tracktags = lambda x: None |
|
1192 | tracktags = lambda x: None | |
1194 | # experimental config: experimental.hook-track-tags |
|
1193 | # experimental config: experimental.hook-track-tags | |
1195 | shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags') |
|
1194 | shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags') | |
1196 | if desc != 'strip' and shouldtracktags: |
|
1195 | if desc != 'strip' and shouldtracktags: | |
1197 | oldheads = self.changelog.headrevs() |
|
1196 | oldheads = self.changelog.headrevs() | |
1198 | def tracktags(tr2): |
|
1197 | def tracktags(tr2): | |
1199 | repo = reporef() |
|
1198 | repo = reporef() | |
1200 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) |
|
1199 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) | |
1201 | newheads = repo.changelog.headrevs() |
|
1200 | newheads = repo.changelog.headrevs() | |
1202 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
1201 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) | |
1203 | # notes: we compare lists here. |
|
1202 | # notes: we compare lists here. | |
1204 | # As we do it only once buiding set would not be cheaper |
|
1203 | # As we do it only once buiding set would not be cheaper | |
1205 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) |
|
1204 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) | |
1206 | if changes: |
|
1205 | if changes: | |
1207 | tr2.hookargs['tag_moved'] = '1' |
|
1206 | tr2.hookargs['tag_moved'] = '1' | |
1208 | with repo.vfs('changes/tags.changes', 'w', |
|
1207 | with repo.vfs('changes/tags.changes', 'w', | |
1209 | atomictemp=True) as changesfile: |
|
1208 | atomictemp=True) as changesfile: | |
1210 | # note: we do not register the file to the transaction |
|
1209 | # note: we do not register the file to the transaction | |
1211 | # because we needs it to still exist on the transaction |
|
1210 | # because we needs it to still exist on the transaction | |
1212 | # is close (for txnclose hooks) |
|
1211 | # is close (for txnclose hooks) | |
1213 | tagsmod.writediff(changesfile, changes) |
|
1212 | tagsmod.writediff(changesfile, changes) | |
1214 | def validate(tr2): |
|
1213 | def validate(tr2): | |
1215 | """will run pre-closing hooks""" |
|
1214 | """will run pre-closing hooks""" | |
1216 | # XXX the transaction API is a bit lacking here so we take a hacky |
|
1215 | # XXX the transaction API is a bit lacking here so we take a hacky | |
1217 | # path for now |
|
1216 | # path for now | |
1218 | # |
|
1217 | # | |
1219 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' |
|
1218 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' | |
1220 | # dict is copied before these run. In addition we needs the data |
|
1219 | # dict is copied before these run. In addition we needs the data | |
1221 | # available to in memory hooks too. |
|
1220 | # available to in memory hooks too. | |
1222 | # |
|
1221 | # | |
1223 | # Moreover, we also need to make sure this runs before txnclose |
|
1222 | # Moreover, we also need to make sure this runs before txnclose | |
1224 | # hooks and there is no "pending" mechanism that would execute |
|
1223 | # hooks and there is no "pending" mechanism that would execute | |
1225 | # logic only if hooks are about to run. |
|
1224 | # logic only if hooks are about to run. | |
1226 | # |
|
1225 | # | |
1227 | # Fixing this limitation of the transaction is also needed to track |
|
1226 | # Fixing this limitation of the transaction is also needed to track | |
1228 | # other families of changes (bookmarks, phases, obsolescence). |
|
1227 | # other families of changes (bookmarks, phases, obsolescence). | |
1229 | # |
|
1228 | # | |
1230 | # This will have to be fixed before we remove the experimental |
|
1229 | # This will have to be fixed before we remove the experimental | |
1231 | # gating. |
|
1230 | # gating. | |
1232 | tracktags(tr2) |
|
1231 | tracktags(tr2) | |
1233 | repo = reporef() |
|
1232 | repo = reporef() | |
1234 | if repo.ui.configbool('experimental', 'single-head-per-branch'): |
|
1233 | if repo.ui.configbool('experimental', 'single-head-per-branch'): | |
1235 | scmutil.enforcesinglehead(repo, tr2, desc) |
|
1234 | scmutil.enforcesinglehead(repo, tr2, desc) | |
1236 | if hook.hashook(repo.ui, 'pretxnclose-bookmark'): |
|
1235 | if hook.hashook(repo.ui, 'pretxnclose-bookmark'): | |
1237 | for name, (old, new) in sorted(tr.changes['bookmarks'].items()): |
|
1236 | for name, (old, new) in sorted(tr.changes['bookmarks'].items()): | |
1238 | args = tr.hookargs.copy() |
|
1237 | args = tr.hookargs.copy() | |
1239 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1238 | args.update(bookmarks.preparehookargs(name, old, new)) | |
1240 | repo.hook('pretxnclose-bookmark', throw=True, |
|
1239 | repo.hook('pretxnclose-bookmark', throw=True, | |
1241 | txnname=desc, |
|
1240 | txnname=desc, | |
1242 | **pycompat.strkwargs(args)) |
|
1241 | **pycompat.strkwargs(args)) | |
1243 | if hook.hashook(repo.ui, 'pretxnclose-phase'): |
|
1242 | if hook.hashook(repo.ui, 'pretxnclose-phase'): | |
1244 | cl = repo.unfiltered().changelog |
|
1243 | cl = repo.unfiltered().changelog | |
1245 | for rev, (old, new) in tr.changes['phases'].items(): |
|
1244 | for rev, (old, new) in tr.changes['phases'].items(): | |
1246 | args = tr.hookargs.copy() |
|
1245 | args = tr.hookargs.copy() | |
1247 | node = hex(cl.node(rev)) |
|
1246 | node = hex(cl.node(rev)) | |
1248 | args.update(phases.preparehookargs(node, old, new)) |
|
1247 | args.update(phases.preparehookargs(node, old, new)) | |
1249 | repo.hook('pretxnclose-phase', throw=True, txnname=desc, |
|
1248 | repo.hook('pretxnclose-phase', throw=True, txnname=desc, | |
1250 | **pycompat.strkwargs(args)) |
|
1249 | **pycompat.strkwargs(args)) | |
1251 |
|
1250 | |||
1252 | repo.hook('pretxnclose', throw=True, |
|
1251 | repo.hook('pretxnclose', throw=True, | |
1253 | txnname=desc, **pycompat.strkwargs(tr.hookargs)) |
|
1252 | txnname=desc, **pycompat.strkwargs(tr.hookargs)) | |
1254 | def releasefn(tr, success): |
|
1253 | def releasefn(tr, success): | |
1255 | repo = reporef() |
|
1254 | repo = reporef() | |
1256 | if success: |
|
1255 | if success: | |
1257 | # this should be explicitly invoked here, because |
|
1256 | # this should be explicitly invoked here, because | |
1258 | # in-memory changes aren't written out at closing |
|
1257 | # in-memory changes aren't written out at closing | |
1259 | # transaction, if tr.addfilegenerator (via |
|
1258 | # transaction, if tr.addfilegenerator (via | |
1260 | # dirstate.write or so) isn't invoked while |
|
1259 | # dirstate.write or so) isn't invoked while | |
1261 | # transaction running |
|
1260 | # transaction running | |
1262 | repo.dirstate.write(None) |
|
1261 | repo.dirstate.write(None) | |
1263 | else: |
|
1262 | else: | |
1264 | # discard all changes (including ones already written |
|
1263 | # discard all changes (including ones already written | |
1265 | # out) in this transaction |
|
1264 | # out) in this transaction | |
1266 | repo.dirstate.restorebackup(None, 'journal.dirstate') |
|
1265 | repo.dirstate.restorebackup(None, 'journal.dirstate') | |
1267 |
|
1266 | |||
1268 | repo.invalidate(clearfilecache=True) |
|
1267 | repo.invalidate(clearfilecache=True) | |
1269 |
|
1268 | |||
1270 | tr = transaction.transaction(rp, self.svfs, vfsmap, |
|
1269 | tr = transaction.transaction(rp, self.svfs, vfsmap, | |
1271 | "journal", |
|
1270 | "journal", | |
1272 | "undo", |
|
1271 | "undo", | |
1273 | aftertrans(renames), |
|
1272 | aftertrans(renames), | |
1274 | self.store.createmode, |
|
1273 | self.store.createmode, | |
1275 | validator=validate, |
|
1274 | validator=validate, | |
1276 | releasefn=releasefn, |
|
1275 | releasefn=releasefn, | |
1277 | checkambigfiles=_cachedfiles) |
|
1276 | checkambigfiles=_cachedfiles) | |
1278 | tr.changes['revs'] = xrange(0, 0) |
|
1277 | tr.changes['revs'] = xrange(0, 0) | |
1279 | tr.changes['obsmarkers'] = set() |
|
1278 | tr.changes['obsmarkers'] = set() | |
1280 | tr.changes['phases'] = {} |
|
1279 | tr.changes['phases'] = {} | |
1281 | tr.changes['bookmarks'] = {} |
|
1280 | tr.changes['bookmarks'] = {} | |
1282 |
|
1281 | |||
1283 | tr.hookargs['txnid'] = txnid |
|
1282 | tr.hookargs['txnid'] = txnid | |
1284 | # note: writing the fncache only during finalize mean that the file is |
|
1283 | # note: writing the fncache only during finalize mean that the file is | |
1285 | # outdated when running hooks. As fncache is used for streaming clone, |
|
1284 | # outdated when running hooks. As fncache is used for streaming clone, | |
1286 | # this is not expected to break anything that happen during the hooks. |
|
1285 | # this is not expected to break anything that happen during the hooks. | |
1287 | tr.addfinalize('flush-fncache', self.store.write) |
|
1286 | tr.addfinalize('flush-fncache', self.store.write) | |
1288 | def txnclosehook(tr2): |
|
1287 | def txnclosehook(tr2): | |
1289 | """To be run if transaction is successful, will schedule a hook run |
|
1288 | """To be run if transaction is successful, will schedule a hook run | |
1290 | """ |
|
1289 | """ | |
1291 | # Don't reference tr2 in hook() so we don't hold a reference. |
|
1290 | # Don't reference tr2 in hook() so we don't hold a reference. | |
1292 | # This reduces memory consumption when there are multiple |
|
1291 | # This reduces memory consumption when there are multiple | |
1293 | # transactions per lock. This can likely go away if issue5045 |
|
1292 | # transactions per lock. This can likely go away if issue5045 | |
1294 | # fixes the function accumulation. |
|
1293 | # fixes the function accumulation. | |
1295 | hookargs = tr2.hookargs |
|
1294 | hookargs = tr2.hookargs | |
1296 |
|
1295 | |||
1297 | def hookfunc(): |
|
1296 | def hookfunc(): | |
1298 | repo = reporef() |
|
1297 | repo = reporef() | |
1299 | if hook.hashook(repo.ui, 'txnclose-bookmark'): |
|
1298 | if hook.hashook(repo.ui, 'txnclose-bookmark'): | |
1300 | bmchanges = sorted(tr.changes['bookmarks'].items()) |
|
1299 | bmchanges = sorted(tr.changes['bookmarks'].items()) | |
1301 | for name, (old, new) in bmchanges: |
|
1300 | for name, (old, new) in bmchanges: | |
1302 | args = tr.hookargs.copy() |
|
1301 | args = tr.hookargs.copy() | |
1303 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1302 | args.update(bookmarks.preparehookargs(name, old, new)) | |
1304 | repo.hook('txnclose-bookmark', throw=False, |
|
1303 | repo.hook('txnclose-bookmark', throw=False, | |
1305 | txnname=desc, **pycompat.strkwargs(args)) |
|
1304 | txnname=desc, **pycompat.strkwargs(args)) | |
1306 |
|
1305 | |||
1307 | if hook.hashook(repo.ui, 'txnclose-phase'): |
|
1306 | if hook.hashook(repo.ui, 'txnclose-phase'): | |
1308 | cl = repo.unfiltered().changelog |
|
1307 | cl = repo.unfiltered().changelog | |
1309 | phasemv = sorted(tr.changes['phases'].items()) |
|
1308 | phasemv = sorted(tr.changes['phases'].items()) | |
1310 | for rev, (old, new) in phasemv: |
|
1309 | for rev, (old, new) in phasemv: | |
1311 | args = tr.hookargs.copy() |
|
1310 | args = tr.hookargs.copy() | |
1312 | node = hex(cl.node(rev)) |
|
1311 | node = hex(cl.node(rev)) | |
1313 | args.update(phases.preparehookargs(node, old, new)) |
|
1312 | args.update(phases.preparehookargs(node, old, new)) | |
1314 | repo.hook('txnclose-phase', throw=False, txnname=desc, |
|
1313 | repo.hook('txnclose-phase', throw=False, txnname=desc, | |
1315 | **pycompat.strkwargs(args)) |
|
1314 | **pycompat.strkwargs(args)) | |
1316 |
|
1315 | |||
1317 | repo.hook('txnclose', throw=False, txnname=desc, |
|
1316 | repo.hook('txnclose', throw=False, txnname=desc, | |
1318 | **pycompat.strkwargs(hookargs)) |
|
1317 | **pycompat.strkwargs(hookargs)) | |
1319 | reporef()._afterlock(hookfunc) |
|
1318 | reporef()._afterlock(hookfunc) | |
1320 | tr.addfinalize('txnclose-hook', txnclosehook) |
|
1319 | tr.addfinalize('txnclose-hook', txnclosehook) | |
1321 | tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) |
|
1320 | tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) | |
1322 | def txnaborthook(tr2): |
|
1321 | def txnaborthook(tr2): | |
1323 | """To be run if transaction is aborted |
|
1322 | """To be run if transaction is aborted | |
1324 | """ |
|
1323 | """ | |
1325 | reporef().hook('txnabort', throw=False, txnname=desc, |
|
1324 | reporef().hook('txnabort', throw=False, txnname=desc, | |
1326 | **tr2.hookargs) |
|
1325 | **tr2.hookargs) | |
1327 | tr.addabort('txnabort-hook', txnaborthook) |
|
1326 | tr.addabort('txnabort-hook', txnaborthook) | |
1328 | # avoid eager cache invalidation. in-memory data should be identical |
|
1327 | # avoid eager cache invalidation. in-memory data should be identical | |
1329 | # to stored data if transaction has no error. |
|
1328 | # to stored data if transaction has no error. | |
1330 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) |
|
1329 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) | |
1331 | self._transref = weakref.ref(tr) |
|
1330 | self._transref = weakref.ref(tr) | |
1332 | scmutil.registersummarycallback(self, tr, desc) |
|
1331 | scmutil.registersummarycallback(self, tr, desc) | |
1333 | return tr |
|
1332 | return tr | |
1334 |
|
1333 | |||
1335 | def _journalfiles(self): |
|
1334 | def _journalfiles(self): | |
1336 | return ((self.svfs, 'journal'), |
|
1335 | return ((self.svfs, 'journal'), | |
1337 | (self.vfs, 'journal.dirstate'), |
|
1336 | (self.vfs, 'journal.dirstate'), | |
1338 | (self.vfs, 'journal.branch'), |
|
1337 | (self.vfs, 'journal.branch'), | |
1339 | (self.vfs, 'journal.desc'), |
|
1338 | (self.vfs, 'journal.desc'), | |
1340 | (self.vfs, 'journal.bookmarks'), |
|
1339 | (self.vfs, 'journal.bookmarks'), | |
1341 | (self.svfs, 'journal.phaseroots')) |
|
1340 | (self.svfs, 'journal.phaseroots')) | |
1342 |
|
1341 | |||
1343 | def undofiles(self): |
|
1342 | def undofiles(self): | |
1344 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
1343 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] | |
1345 |
|
1344 | |||
1346 | @unfilteredmethod |
|
1345 | @unfilteredmethod | |
1347 | def _writejournal(self, desc): |
|
1346 | def _writejournal(self, desc): | |
1348 | self.dirstate.savebackup(None, 'journal.dirstate') |
|
1347 | self.dirstate.savebackup(None, 'journal.dirstate') | |
1349 | self.vfs.write("journal.branch", |
|
1348 | self.vfs.write("journal.branch", | |
1350 | encoding.fromlocal(self.dirstate.branch())) |
|
1349 | encoding.fromlocal(self.dirstate.branch())) | |
1351 | self.vfs.write("journal.desc", |
|
1350 | self.vfs.write("journal.desc", | |
1352 | "%d\n%s\n" % (len(self), desc)) |
|
1351 | "%d\n%s\n" % (len(self), desc)) | |
1353 | self.vfs.write("journal.bookmarks", |
|
1352 | self.vfs.write("journal.bookmarks", | |
1354 | self.vfs.tryread("bookmarks")) |
|
1353 | self.vfs.tryread("bookmarks")) | |
1355 | self.svfs.write("journal.phaseroots", |
|
1354 | self.svfs.write("journal.phaseroots", | |
1356 | self.svfs.tryread("phaseroots")) |
|
1355 | self.svfs.tryread("phaseroots")) | |
1357 |
|
1356 | |||
1358 | def recover(self): |
|
1357 | def recover(self): | |
1359 | with self.lock(): |
|
1358 | with self.lock(): | |
1360 | if self.svfs.exists("journal"): |
|
1359 | if self.svfs.exists("journal"): | |
1361 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
1360 | self.ui.status(_("rolling back interrupted transaction\n")) | |
1362 | vfsmap = {'': self.svfs, |
|
1361 | vfsmap = {'': self.svfs, | |
1363 | 'plain': self.vfs,} |
|
1362 | 'plain': self.vfs,} | |
1364 | transaction.rollback(self.svfs, vfsmap, "journal", |
|
1363 | transaction.rollback(self.svfs, vfsmap, "journal", | |
1365 | self.ui.warn, |
|
1364 | self.ui.warn, | |
1366 | checkambigfiles=_cachedfiles) |
|
1365 | checkambigfiles=_cachedfiles) | |
1367 | self.invalidate() |
|
1366 | self.invalidate() | |
1368 | return True |
|
1367 | return True | |
1369 | else: |
|
1368 | else: | |
1370 | self.ui.warn(_("no interrupted transaction available\n")) |
|
1369 | self.ui.warn(_("no interrupted transaction available\n")) | |
1371 | return False |
|
1370 | return False | |
1372 |
|
1371 | |||
1373 | def rollback(self, dryrun=False, force=False): |
|
1372 | def rollback(self, dryrun=False, force=False): | |
1374 | wlock = lock = dsguard = None |
|
1373 | wlock = lock = dsguard = None | |
1375 | try: |
|
1374 | try: | |
1376 | wlock = self.wlock() |
|
1375 | wlock = self.wlock() | |
1377 | lock = self.lock() |
|
1376 | lock = self.lock() | |
1378 | if self.svfs.exists("undo"): |
|
1377 | if self.svfs.exists("undo"): | |
1379 | dsguard = dirstateguard.dirstateguard(self, 'rollback') |
|
1378 | dsguard = dirstateguard.dirstateguard(self, 'rollback') | |
1380 |
|
1379 | |||
1381 | return self._rollback(dryrun, force, dsguard) |
|
1380 | return self._rollback(dryrun, force, dsguard) | |
1382 | else: |
|
1381 | else: | |
1383 | self.ui.warn(_("no rollback information available\n")) |
|
1382 | self.ui.warn(_("no rollback information available\n")) | |
1384 | return 1 |
|
1383 | return 1 | |
1385 | finally: |
|
1384 | finally: | |
1386 | release(dsguard, lock, wlock) |
|
1385 | release(dsguard, lock, wlock) | |
1387 |
|
1386 | |||
1388 | @unfilteredmethod # Until we get smarter cache management |
|
1387 | @unfilteredmethod # Until we get smarter cache management | |
1389 | def _rollback(self, dryrun, force, dsguard): |
|
1388 | def _rollback(self, dryrun, force, dsguard): | |
1390 | ui = self.ui |
|
1389 | ui = self.ui | |
1391 | try: |
|
1390 | try: | |
1392 | args = self.vfs.read('undo.desc').splitlines() |
|
1391 | args = self.vfs.read('undo.desc').splitlines() | |
1393 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
1392 | (oldlen, desc, detail) = (int(args[0]), args[1], None) | |
1394 | if len(args) >= 3: |
|
1393 | if len(args) >= 3: | |
1395 | detail = args[2] |
|
1394 | detail = args[2] | |
1396 | oldtip = oldlen - 1 |
|
1395 | oldtip = oldlen - 1 | |
1397 |
|
1396 | |||
1398 | if detail and ui.verbose: |
|
1397 | if detail and ui.verbose: | |
1399 | msg = (_('repository tip rolled back to revision %d' |
|
1398 | msg = (_('repository tip rolled back to revision %d' | |
1400 | ' (undo %s: %s)\n') |
|
1399 | ' (undo %s: %s)\n') | |
1401 | % (oldtip, desc, detail)) |
|
1400 | % (oldtip, desc, detail)) | |
1402 | else: |
|
1401 | else: | |
1403 | msg = (_('repository tip rolled back to revision %d' |
|
1402 | msg = (_('repository tip rolled back to revision %d' | |
1404 | ' (undo %s)\n') |
|
1403 | ' (undo %s)\n') | |
1405 | % (oldtip, desc)) |
|
1404 | % (oldtip, desc)) | |
1406 | except IOError: |
|
1405 | except IOError: | |
1407 | msg = _('rolling back unknown transaction\n') |
|
1406 | msg = _('rolling back unknown transaction\n') | |
1408 | desc = None |
|
1407 | desc = None | |
1409 |
|
1408 | |||
1410 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
1409 | if not force and self['.'] != self['tip'] and desc == 'commit': | |
1411 | raise error.Abort( |
|
1410 | raise error.Abort( | |
1412 | _('rollback of last commit while not checked out ' |
|
1411 | _('rollback of last commit while not checked out ' | |
1413 | 'may lose data'), hint=_('use -f to force')) |
|
1412 | 'may lose data'), hint=_('use -f to force')) | |
1414 |
|
1413 | |||
1415 | ui.status(msg) |
|
1414 | ui.status(msg) | |
1416 | if dryrun: |
|
1415 | if dryrun: | |
1417 | return 0 |
|
1416 | return 0 | |
1418 |
|
1417 | |||
1419 | parents = self.dirstate.parents() |
|
1418 | parents = self.dirstate.parents() | |
1420 | self.destroying() |
|
1419 | self.destroying() | |
1421 | vfsmap = {'plain': self.vfs, '': self.svfs} |
|
1420 | vfsmap = {'plain': self.vfs, '': self.svfs} | |
1422 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn, |
|
1421 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn, | |
1423 | checkambigfiles=_cachedfiles) |
|
1422 | checkambigfiles=_cachedfiles) | |
1424 | if self.vfs.exists('undo.bookmarks'): |
|
1423 | if self.vfs.exists('undo.bookmarks'): | |
1425 | self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) |
|
1424 | self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) | |
1426 | if self.svfs.exists('undo.phaseroots'): |
|
1425 | if self.svfs.exists('undo.phaseroots'): | |
1427 | self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True) |
|
1426 | self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True) | |
1428 | self.invalidate() |
|
1427 | self.invalidate() | |
1429 |
|
1428 | |||
1430 | parentgone = (parents[0] not in self.changelog.nodemap or |
|
1429 | parentgone = (parents[0] not in self.changelog.nodemap or | |
1431 | parents[1] not in self.changelog.nodemap) |
|
1430 | parents[1] not in self.changelog.nodemap) | |
1432 | if parentgone: |
|
1431 | if parentgone: | |
1433 | # prevent dirstateguard from overwriting already restored one |
|
1432 | # prevent dirstateguard from overwriting already restored one | |
1434 | dsguard.close() |
|
1433 | dsguard.close() | |
1435 |
|
1434 | |||
1436 | self.dirstate.restorebackup(None, 'undo.dirstate') |
|
1435 | self.dirstate.restorebackup(None, 'undo.dirstate') | |
1437 | try: |
|
1436 | try: | |
1438 | branch = self.vfs.read('undo.branch') |
|
1437 | branch = self.vfs.read('undo.branch') | |
1439 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
1438 | self.dirstate.setbranch(encoding.tolocal(branch)) | |
1440 | except IOError: |
|
1439 | except IOError: | |
1441 | ui.warn(_('named branch could not be reset: ' |
|
1440 | ui.warn(_('named branch could not be reset: ' | |
1442 | 'current branch is still \'%s\'\n') |
|
1441 | 'current branch is still \'%s\'\n') | |
1443 | % self.dirstate.branch()) |
|
1442 | % self.dirstate.branch()) | |
1444 |
|
1443 | |||
1445 | parents = tuple([p.rev() for p in self[None].parents()]) |
|
1444 | parents = tuple([p.rev() for p in self[None].parents()]) | |
1446 | if len(parents) > 1: |
|
1445 | if len(parents) > 1: | |
1447 | ui.status(_('working directory now based on ' |
|
1446 | ui.status(_('working directory now based on ' | |
1448 | 'revisions %d and %d\n') % parents) |
|
1447 | 'revisions %d and %d\n') % parents) | |
1449 | else: |
|
1448 | else: | |
1450 | ui.status(_('working directory now based on ' |
|
1449 | ui.status(_('working directory now based on ' | |
1451 | 'revision %d\n') % parents) |
|
1450 | 'revision %d\n') % parents) | |
1452 | mergemod.mergestate.clean(self, self['.'].node()) |
|
1451 | mergemod.mergestate.clean(self, self['.'].node()) | |
1453 |
|
1452 | |||
1454 | # TODO: if we know which new heads may result from this rollback, pass |
|
1453 | # TODO: if we know which new heads may result from this rollback, pass | |
1455 | # them to destroy(), which will prevent the branchhead cache from being |
|
1454 | # them to destroy(), which will prevent the branchhead cache from being | |
1456 | # invalidated. |
|
1455 | # invalidated. | |
1457 | self.destroyed() |
|
1456 | self.destroyed() | |
1458 | return 0 |
|
1457 | return 0 | |
1459 |
|
1458 | |||
1460 | def _buildcacheupdater(self, newtransaction): |
|
1459 | def _buildcacheupdater(self, newtransaction): | |
1461 | """called during transaction to build the callback updating cache |
|
1460 | """called during transaction to build the callback updating cache | |
1462 |
|
1461 | |||
1463 | Lives on the repository to help extension who might want to augment |
|
1462 | Lives on the repository to help extension who might want to augment | |
1464 | this logic. For this purpose, the created transaction is passed to the |
|
1463 | this logic. For this purpose, the created transaction is passed to the | |
1465 | method. |
|
1464 | method. | |
1466 | """ |
|
1465 | """ | |
1467 | # we must avoid cyclic reference between repo and transaction. |
|
1466 | # we must avoid cyclic reference between repo and transaction. | |
1468 | reporef = weakref.ref(self) |
|
1467 | reporef = weakref.ref(self) | |
1469 | def updater(tr): |
|
1468 | def updater(tr): | |
1470 | repo = reporef() |
|
1469 | repo = reporef() | |
1471 | repo.updatecaches(tr) |
|
1470 | repo.updatecaches(tr) | |
1472 | return updater |
|
1471 | return updater | |
1473 |
|
1472 | |||
1474 | @unfilteredmethod |
|
1473 | @unfilteredmethod | |
1475 | def updatecaches(self, tr=None): |
|
1474 | def updatecaches(self, tr=None): | |
1476 | """warm appropriate caches |
|
1475 | """warm appropriate caches | |
1477 |
|
1476 | |||
1478 | If this function is called after a transaction closed. The transaction |
|
1477 | If this function is called after a transaction closed. The transaction | |
1479 | will be available in the 'tr' argument. This can be used to selectively |
|
1478 | will be available in the 'tr' argument. This can be used to selectively | |
1480 | update caches relevant to the changes in that transaction. |
|
1479 | update caches relevant to the changes in that transaction. | |
1481 | """ |
|
1480 | """ | |
1482 | if tr is not None and tr.hookargs.get('source') == 'strip': |
|
1481 | if tr is not None and tr.hookargs.get('source') == 'strip': | |
1483 | # During strip, many caches are invalid but |
|
1482 | # During strip, many caches are invalid but | |
1484 | # later call to `destroyed` will refresh them. |
|
1483 | # later call to `destroyed` will refresh them. | |
1485 | return |
|
1484 | return | |
1486 |
|
1485 | |||
1487 | if tr is None or tr.changes['revs']: |
|
1486 | if tr is None or tr.changes['revs']: | |
1488 | # updating the unfiltered branchmap should refresh all the others, |
|
1487 | # updating the unfiltered branchmap should refresh all the others, | |
1489 | self.ui.debug('updating the branch cache\n') |
|
1488 | self.ui.debug('updating the branch cache\n') | |
1490 | branchmap.updatecache(self.filtered('served')) |
|
1489 | branchmap.updatecache(self.filtered('served')) | |
1491 |
|
1490 | |||
1492 | def invalidatecaches(self): |
|
1491 | def invalidatecaches(self): | |
1493 |
|
1492 | |||
1494 | if '_tagscache' in vars(self): |
|
1493 | if '_tagscache' in vars(self): | |
1495 | # can't use delattr on proxy |
|
1494 | # can't use delattr on proxy | |
1496 | del self.__dict__['_tagscache'] |
|
1495 | del self.__dict__['_tagscache'] | |
1497 |
|
1496 | |||
1498 | self.unfiltered()._branchcaches.clear() |
|
1497 | self.unfiltered()._branchcaches.clear() | |
1499 | self.invalidatevolatilesets() |
|
1498 | self.invalidatevolatilesets() | |
1500 | self._sparsesignaturecache.clear() |
|
1499 | self._sparsesignaturecache.clear() | |
1501 |
|
1500 | |||
1502 | def invalidatevolatilesets(self): |
|
1501 | def invalidatevolatilesets(self): | |
1503 | self.filteredrevcache.clear() |
|
1502 | self.filteredrevcache.clear() | |
1504 | obsolete.clearobscaches(self) |
|
1503 | obsolete.clearobscaches(self) | |
1505 |
|
1504 | |||
1506 | def invalidatedirstate(self): |
|
1505 | def invalidatedirstate(self): | |
1507 | '''Invalidates the dirstate, causing the next call to dirstate |
|
1506 | '''Invalidates the dirstate, causing the next call to dirstate | |
1508 | to check if it was modified since the last time it was read, |
|
1507 | to check if it was modified since the last time it was read, | |
1509 | rereading it if it has. |
|
1508 | rereading it if it has. | |
1510 |
|
1509 | |||
1511 | This is different to dirstate.invalidate() that it doesn't always |
|
1510 | This is different to dirstate.invalidate() that it doesn't always | |
1512 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
1511 | rereads the dirstate. Use dirstate.invalidate() if you want to | |
1513 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
1512 | explicitly read the dirstate again (i.e. restoring it to a previous | |
1514 | known good state).''' |
|
1513 | known good state).''' | |
1515 | if hasunfilteredcache(self, 'dirstate'): |
|
1514 | if hasunfilteredcache(self, 'dirstate'): | |
1516 | for k in self.dirstate._filecache: |
|
1515 | for k in self.dirstate._filecache: | |
1517 | try: |
|
1516 | try: | |
1518 | delattr(self.dirstate, k) |
|
1517 | delattr(self.dirstate, k) | |
1519 | except AttributeError: |
|
1518 | except AttributeError: | |
1520 | pass |
|
1519 | pass | |
1521 | delattr(self.unfiltered(), 'dirstate') |
|
1520 | delattr(self.unfiltered(), 'dirstate') | |
1522 |
|
1521 | |||
1523 | def invalidate(self, clearfilecache=False): |
|
1522 | def invalidate(self, clearfilecache=False): | |
1524 | '''Invalidates both store and non-store parts other than dirstate |
|
1523 | '''Invalidates both store and non-store parts other than dirstate | |
1525 |
|
1524 | |||
1526 | If a transaction is running, invalidation of store is omitted, |
|
1525 | If a transaction is running, invalidation of store is omitted, | |
1527 | because discarding in-memory changes might cause inconsistency |
|
1526 | because discarding in-memory changes might cause inconsistency | |
1528 | (e.g. incomplete fncache causes unintentional failure, but |
|
1527 | (e.g. incomplete fncache causes unintentional failure, but | |
1529 | redundant one doesn't). |
|
1528 | redundant one doesn't). | |
1530 | ''' |
|
1529 | ''' | |
1531 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
1530 | unfiltered = self.unfiltered() # all file caches are stored unfiltered | |
1532 | for k in list(self._filecache.keys()): |
|
1531 | for k in list(self._filecache.keys()): | |
1533 | # dirstate is invalidated separately in invalidatedirstate() |
|
1532 | # dirstate is invalidated separately in invalidatedirstate() | |
1534 | if k == 'dirstate': |
|
1533 | if k == 'dirstate': | |
1535 | continue |
|
1534 | continue | |
1536 | if (k == 'changelog' and |
|
1535 | if (k == 'changelog' and | |
1537 | self.currenttransaction() and |
|
1536 | self.currenttransaction() and | |
1538 | self.changelog._delayed): |
|
1537 | self.changelog._delayed): | |
1539 | # The changelog object may store unwritten revisions. We don't |
|
1538 | # The changelog object may store unwritten revisions. We don't | |
1540 | # want to lose them. |
|
1539 | # want to lose them. | |
1541 | # TODO: Solve the problem instead of working around it. |
|
1540 | # TODO: Solve the problem instead of working around it. | |
1542 | continue |
|
1541 | continue | |
1543 |
|
1542 | |||
1544 | if clearfilecache: |
|
1543 | if clearfilecache: | |
1545 | del self._filecache[k] |
|
1544 | del self._filecache[k] | |
1546 | try: |
|
1545 | try: | |
1547 | delattr(unfiltered, k) |
|
1546 | delattr(unfiltered, k) | |
1548 | except AttributeError: |
|
1547 | except AttributeError: | |
1549 | pass |
|
1548 | pass | |
1550 | self.invalidatecaches() |
|
1549 | self.invalidatecaches() | |
1551 | if not self.currenttransaction(): |
|
1550 | if not self.currenttransaction(): | |
1552 | # TODO: Changing contents of store outside transaction |
|
1551 | # TODO: Changing contents of store outside transaction | |
1553 | # causes inconsistency. We should make in-memory store |
|
1552 | # causes inconsistency. We should make in-memory store | |
1554 | # changes detectable, and abort if changed. |
|
1553 | # changes detectable, and abort if changed. | |
1555 | self.store.invalidatecaches() |
|
1554 | self.store.invalidatecaches() | |
1556 |
|
1555 | |||
1557 | def invalidateall(self): |
|
1556 | def invalidateall(self): | |
1558 | '''Fully invalidates both store and non-store parts, causing the |
|
1557 | '''Fully invalidates both store and non-store parts, causing the | |
1559 | subsequent operation to reread any outside changes.''' |
|
1558 | subsequent operation to reread any outside changes.''' | |
1560 | # extension should hook this to invalidate its caches |
|
1559 | # extension should hook this to invalidate its caches | |
1561 | self.invalidate() |
|
1560 | self.invalidate() | |
1562 | self.invalidatedirstate() |
|
1561 | self.invalidatedirstate() | |
1563 |
|
1562 | |||
1564 | @unfilteredmethod |
|
1563 | @unfilteredmethod | |
1565 | def _refreshfilecachestats(self, tr): |
|
1564 | def _refreshfilecachestats(self, tr): | |
1566 | """Reload stats of cached files so that they are flagged as valid""" |
|
1565 | """Reload stats of cached files so that they are flagged as valid""" | |
1567 | for k, ce in self._filecache.items(): |
|
1566 | for k, ce in self._filecache.items(): | |
1568 | if k == 'dirstate' or k not in self.__dict__: |
|
1567 | if k == 'dirstate' or k not in self.__dict__: | |
1569 | continue |
|
1568 | continue | |
1570 | ce.refresh() |
|
1569 | ce.refresh() | |
1571 |
|
1570 | |||
1572 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, |
|
1571 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, | |
1573 | inheritchecker=None, parentenvvar=None): |
|
1572 | inheritchecker=None, parentenvvar=None): | |
1574 | parentlock = None |
|
1573 | parentlock = None | |
1575 | # the contents of parentenvvar are used by the underlying lock to |
|
1574 | # the contents of parentenvvar are used by the underlying lock to | |
1576 | # determine whether it can be inherited |
|
1575 | # determine whether it can be inherited | |
1577 | if parentenvvar is not None: |
|
1576 | if parentenvvar is not None: | |
1578 | parentlock = encoding.environ.get(parentenvvar) |
|
1577 | parentlock = encoding.environ.get(parentenvvar) | |
1579 |
|
1578 | |||
1580 | timeout = 0 |
|
1579 | timeout = 0 | |
1581 | warntimeout = 0 |
|
1580 | warntimeout = 0 | |
1582 | if wait: |
|
1581 | if wait: | |
1583 | timeout = self.ui.configint("ui", "timeout") |
|
1582 | timeout = self.ui.configint("ui", "timeout") | |
1584 | warntimeout = self.ui.configint("ui", "timeout.warn") |
|
1583 | warntimeout = self.ui.configint("ui", "timeout.warn") | |
1585 |
|
1584 | |||
1586 | l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout, |
|
1585 | l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout, | |
1587 | releasefn=releasefn, |
|
1586 | releasefn=releasefn, | |
1588 | acquirefn=acquirefn, desc=desc, |
|
1587 | acquirefn=acquirefn, desc=desc, | |
1589 | inheritchecker=inheritchecker, |
|
1588 | inheritchecker=inheritchecker, | |
1590 | parentlock=parentlock) |
|
1589 | parentlock=parentlock) | |
1591 | return l |
|
1590 | return l | |
1592 |
|
1591 | |||
1593 | def _afterlock(self, callback): |
|
1592 | def _afterlock(self, callback): | |
1594 | """add a callback to be run when the repository is fully unlocked |
|
1593 | """add a callback to be run when the repository is fully unlocked | |
1595 |
|
1594 | |||
1596 | The callback will be executed when the outermost lock is released |
|
1595 | The callback will be executed when the outermost lock is released | |
1597 | (with wlock being higher level than 'lock').""" |
|
1596 | (with wlock being higher level than 'lock').""" | |
1598 | for ref in (self._wlockref, self._lockref): |
|
1597 | for ref in (self._wlockref, self._lockref): | |
1599 | l = ref and ref() |
|
1598 | l = ref and ref() | |
1600 | if l and l.held: |
|
1599 | if l and l.held: | |
1601 | l.postrelease.append(callback) |
|
1600 | l.postrelease.append(callback) | |
1602 | break |
|
1601 | break | |
1603 | else: # no lock have been found. |
|
1602 | else: # no lock have been found. | |
1604 | callback() |
|
1603 | callback() | |
1605 |
|
1604 | |||
1606 | def lock(self, wait=True): |
|
1605 | def lock(self, wait=True): | |
1607 | '''Lock the repository store (.hg/store) and return a weak reference |
|
1606 | '''Lock the repository store (.hg/store) and return a weak reference | |
1608 | to the lock. Use this before modifying the store (e.g. committing or |
|
1607 | to the lock. Use this before modifying the store (e.g. committing or | |
1609 | stripping). If you are opening a transaction, get a lock as well.) |
|
1608 | stripping). If you are opening a transaction, get a lock as well.) | |
1610 |
|
1609 | |||
1611 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1610 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires | |
1612 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1611 | 'wlock' first to avoid a dead-lock hazard.''' | |
1613 | l = self._currentlock(self._lockref) |
|
1612 | l = self._currentlock(self._lockref) | |
1614 | if l is not None: |
|
1613 | if l is not None: | |
1615 | l.lock() |
|
1614 | l.lock() | |
1616 | return l |
|
1615 | return l | |
1617 |
|
1616 | |||
1618 | l = self._lock(self.svfs, "lock", wait, None, |
|
1617 | l = self._lock(self.svfs, "lock", wait, None, | |
1619 | self.invalidate, _('repository %s') % self.origroot) |
|
1618 | self.invalidate, _('repository %s') % self.origroot) | |
1620 | self._lockref = weakref.ref(l) |
|
1619 | self._lockref = weakref.ref(l) | |
1621 | return l |
|
1620 | return l | |
1622 |
|
1621 | |||
1623 | def _wlockchecktransaction(self): |
|
1622 | def _wlockchecktransaction(self): | |
1624 | if self.currenttransaction() is not None: |
|
1623 | if self.currenttransaction() is not None: | |
1625 | raise error.LockInheritanceContractViolation( |
|
1624 | raise error.LockInheritanceContractViolation( | |
1626 | 'wlock cannot be inherited in the middle of a transaction') |
|
1625 | 'wlock cannot be inherited in the middle of a transaction') | |
1627 |
|
1626 | |||
1628 | def wlock(self, wait=True): |
|
1627 | def wlock(self, wait=True): | |
1629 | '''Lock the non-store parts of the repository (everything under |
|
1628 | '''Lock the non-store parts of the repository (everything under | |
1630 | .hg except .hg/store) and return a weak reference to the lock. |
|
1629 | .hg except .hg/store) and return a weak reference to the lock. | |
1631 |
|
1630 | |||
1632 | Use this before modifying files in .hg. |
|
1631 | Use this before modifying files in .hg. | |
1633 |
|
1632 | |||
1634 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1633 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires | |
1635 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1634 | 'wlock' first to avoid a dead-lock hazard.''' | |
1636 | l = self._wlockref and self._wlockref() |
|
1635 | l = self._wlockref and self._wlockref() | |
1637 | if l is not None and l.held: |
|
1636 | if l is not None and l.held: | |
1638 | l.lock() |
|
1637 | l.lock() | |
1639 | return l |
|
1638 | return l | |
1640 |
|
1639 | |||
1641 | # We do not need to check for non-waiting lock acquisition. Such |
|
1640 | # We do not need to check for non-waiting lock acquisition. Such | |
1642 | # acquisition would not cause dead-lock as they would just fail. |
|
1641 | # acquisition would not cause dead-lock as they would just fail. | |
1643 | if wait and (self.ui.configbool('devel', 'all-warnings') |
|
1642 | if wait and (self.ui.configbool('devel', 'all-warnings') | |
1644 | or self.ui.configbool('devel', 'check-locks')): |
|
1643 | or self.ui.configbool('devel', 'check-locks')): | |
1645 | if self._currentlock(self._lockref) is not None: |
|
1644 | if self._currentlock(self._lockref) is not None: | |
1646 | self.ui.develwarn('"wlock" acquired after "lock"') |
|
1645 | self.ui.develwarn('"wlock" acquired after "lock"') | |
1647 |
|
1646 | |||
1648 | def unlock(): |
|
1647 | def unlock(): | |
1649 | if self.dirstate.pendingparentchange(): |
|
1648 | if self.dirstate.pendingparentchange(): | |
1650 | self.dirstate.invalidate() |
|
1649 | self.dirstate.invalidate() | |
1651 | else: |
|
1650 | else: | |
1652 | self.dirstate.write(None) |
|
1651 | self.dirstate.write(None) | |
1653 |
|
1652 | |||
1654 | self._filecache['dirstate'].refresh() |
|
1653 | self._filecache['dirstate'].refresh() | |
1655 |
|
1654 | |||
1656 | l = self._lock(self.vfs, "wlock", wait, unlock, |
|
1655 | l = self._lock(self.vfs, "wlock", wait, unlock, | |
1657 | self.invalidatedirstate, _('working directory of %s') % |
|
1656 | self.invalidatedirstate, _('working directory of %s') % | |
1658 | self.origroot, |
|
1657 | self.origroot, | |
1659 | inheritchecker=self._wlockchecktransaction, |
|
1658 | inheritchecker=self._wlockchecktransaction, | |
1660 | parentenvvar='HG_WLOCK_LOCKER') |
|
1659 | parentenvvar='HG_WLOCK_LOCKER') | |
1661 | self._wlockref = weakref.ref(l) |
|
1660 | self._wlockref = weakref.ref(l) | |
1662 | return l |
|
1661 | return l | |
1663 |
|
1662 | |||
1664 | def _currentlock(self, lockref): |
|
1663 | def _currentlock(self, lockref): | |
1665 | """Returns the lock if it's held, or None if it's not.""" |
|
1664 | """Returns the lock if it's held, or None if it's not.""" | |
1666 | if lockref is None: |
|
1665 | if lockref is None: | |
1667 | return None |
|
1666 | return None | |
1668 | l = lockref() |
|
1667 | l = lockref() | |
1669 | if l is None or not l.held: |
|
1668 | if l is None or not l.held: | |
1670 | return None |
|
1669 | return None | |
1671 | return l |
|
1670 | return l | |
1672 |
|
1671 | |||
1673 | def currentwlock(self): |
|
1672 | def currentwlock(self): | |
1674 | """Returns the wlock if it's held, or None if it's not.""" |
|
1673 | """Returns the wlock if it's held, or None if it's not.""" | |
1675 | return self._currentlock(self._wlockref) |
|
1674 | return self._currentlock(self._wlockref) | |
1676 |
|
1675 | |||
1677 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
|
1676 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | |
1678 | """ |
|
1677 | """ | |
1679 | commit an individual file as part of a larger transaction |
|
1678 | commit an individual file as part of a larger transaction | |
1680 | """ |
|
1679 | """ | |
1681 |
|
1680 | |||
1682 | fname = fctx.path() |
|
1681 | fname = fctx.path() | |
1683 | fparent1 = manifest1.get(fname, nullid) |
|
1682 | fparent1 = manifest1.get(fname, nullid) | |
1684 | fparent2 = manifest2.get(fname, nullid) |
|
1683 | fparent2 = manifest2.get(fname, nullid) | |
1685 | if isinstance(fctx, context.filectx): |
|
1684 | if isinstance(fctx, context.filectx): | |
1686 | node = fctx.filenode() |
|
1685 | node = fctx.filenode() | |
1687 | if node in [fparent1, fparent2]: |
|
1686 | if node in [fparent1, fparent2]: | |
1688 | self.ui.debug('reusing %s filelog entry\n' % fname) |
|
1687 | self.ui.debug('reusing %s filelog entry\n' % fname) | |
1689 | if manifest1.flags(fname) != fctx.flags(): |
|
1688 | if manifest1.flags(fname) != fctx.flags(): | |
1690 | changelist.append(fname) |
|
1689 | changelist.append(fname) | |
1691 | return node |
|
1690 | return node | |
1692 |
|
1691 | |||
1693 | flog = self.file(fname) |
|
1692 | flog = self.file(fname) | |
1694 | meta = {} |
|
1693 | meta = {} | |
1695 | copy = fctx.renamed() |
|
1694 | copy = fctx.renamed() | |
1696 | if copy and copy[0] != fname: |
|
1695 | if copy and copy[0] != fname: | |
1697 | # Mark the new revision of this file as a copy of another |
|
1696 | # Mark the new revision of this file as a copy of another | |
1698 | # file. This copy data will effectively act as a parent |
|
1697 | # file. This copy data will effectively act as a parent | |
1699 | # of this new revision. If this is a merge, the first |
|
1698 | # of this new revision. If this is a merge, the first | |
1700 | # parent will be the nullid (meaning "look up the copy data") |
|
1699 | # parent will be the nullid (meaning "look up the copy data") | |
1701 | # and the second one will be the other parent. For example: |
|
1700 | # and the second one will be the other parent. For example: | |
1702 | # |
|
1701 | # | |
1703 | # 0 --- 1 --- 3 rev1 changes file foo |
|
1702 | # 0 --- 1 --- 3 rev1 changes file foo | |
1704 | # \ / rev2 renames foo to bar and changes it |
|
1703 | # \ / rev2 renames foo to bar and changes it | |
1705 | # \- 2 -/ rev3 should have bar with all changes and |
|
1704 | # \- 2 -/ rev3 should have bar with all changes and | |
1706 | # should record that bar descends from |
|
1705 | # should record that bar descends from | |
1707 | # bar in rev2 and foo in rev1 |
|
1706 | # bar in rev2 and foo in rev1 | |
1708 | # |
|
1707 | # | |
1709 | # this allows this merge to succeed: |
|
1708 | # this allows this merge to succeed: | |
1710 | # |
|
1709 | # | |
1711 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
1710 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 | |
1712 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
1711 | # \ / merging rev3 and rev4 should use bar@rev2 | |
1713 | # \- 2 --- 4 as the merge base |
|
1712 | # \- 2 --- 4 as the merge base | |
1714 | # |
|
1713 | # | |
1715 |
|
1714 | |||
1716 | cfname = copy[0] |
|
1715 | cfname = copy[0] | |
1717 | crev = manifest1.get(cfname) |
|
1716 | crev = manifest1.get(cfname) | |
1718 | newfparent = fparent2 |
|
1717 | newfparent = fparent2 | |
1719 |
|
1718 | |||
1720 | if manifest2: # branch merge |
|
1719 | if manifest2: # branch merge | |
1721 | if fparent2 == nullid or crev is None: # copied on remote side |
|
1720 | if fparent2 == nullid or crev is None: # copied on remote side | |
1722 | if cfname in manifest2: |
|
1721 | if cfname in manifest2: | |
1723 | crev = manifest2[cfname] |
|
1722 | crev = manifest2[cfname] | |
1724 | newfparent = fparent1 |
|
1723 | newfparent = fparent1 | |
1725 |
|
1724 | |||
1726 | # Here, we used to search backwards through history to try to find |
|
1725 | # Here, we used to search backwards through history to try to find | |
1727 | # where the file copy came from if the source of a copy was not in |
|
1726 | # where the file copy came from if the source of a copy was not in | |
1728 | # the parent directory. However, this doesn't actually make sense to |
|
1727 | # the parent directory. However, this doesn't actually make sense to | |
1729 | # do (what does a copy from something not in your working copy even |
|
1728 | # do (what does a copy from something not in your working copy even | |
1730 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn |
|
1729 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn | |
1731 | # the user that copy information was dropped, so if they didn't |
|
1730 | # the user that copy information was dropped, so if they didn't | |
1732 | # expect this outcome it can be fixed, but this is the correct |
|
1731 | # expect this outcome it can be fixed, but this is the correct | |
1733 | # behavior in this circumstance. |
|
1732 | # behavior in this circumstance. | |
1734 |
|
1733 | |||
1735 | if crev: |
|
1734 | if crev: | |
1736 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) |
|
1735 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) | |
1737 | meta["copy"] = cfname |
|
1736 | meta["copy"] = cfname | |
1738 | meta["copyrev"] = hex(crev) |
|
1737 | meta["copyrev"] = hex(crev) | |
1739 | fparent1, fparent2 = nullid, newfparent |
|
1738 | fparent1, fparent2 = nullid, newfparent | |
1740 | else: |
|
1739 | else: | |
1741 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
1740 | self.ui.warn(_("warning: can't find ancestor for '%s' " | |
1742 | "copied from '%s'!\n") % (fname, cfname)) |
|
1741 | "copied from '%s'!\n") % (fname, cfname)) | |
1743 |
|
1742 | |||
1744 | elif fparent1 == nullid: |
|
1743 | elif fparent1 == nullid: | |
1745 | fparent1, fparent2 = fparent2, nullid |
|
1744 | fparent1, fparent2 = fparent2, nullid | |
1746 | elif fparent2 != nullid: |
|
1745 | elif fparent2 != nullid: | |
1747 | # is one parent an ancestor of the other? |
|
1746 | # is one parent an ancestor of the other? | |
1748 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) |
|
1747 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) | |
1749 | if fparent1 in fparentancestors: |
|
1748 | if fparent1 in fparentancestors: | |
1750 | fparent1, fparent2 = fparent2, nullid |
|
1749 | fparent1, fparent2 = fparent2, nullid | |
1751 | elif fparent2 in fparentancestors: |
|
1750 | elif fparent2 in fparentancestors: | |
1752 | fparent2 = nullid |
|
1751 | fparent2 = nullid | |
1753 |
|
1752 | |||
1754 | # is the file changed? |
|
1753 | # is the file changed? | |
1755 | text = fctx.data() |
|
1754 | text = fctx.data() | |
1756 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
1755 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: | |
1757 | changelist.append(fname) |
|
1756 | changelist.append(fname) | |
1758 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
1757 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) | |
1759 | # are just the flags changed during merge? |
|
1758 | # are just the flags changed during merge? | |
1760 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
|
1759 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): | |
1761 | changelist.append(fname) |
|
1760 | changelist.append(fname) | |
1762 |
|
1761 | |||
1763 | return fparent1 |
|
1762 | return fparent1 | |
1764 |
|
1763 | |||
1765 | def checkcommitpatterns(self, wctx, vdirs, match, status, fail): |
|
1764 | def checkcommitpatterns(self, wctx, vdirs, match, status, fail): | |
1766 | """check for commit arguments that aren't committable""" |
|
1765 | """check for commit arguments that aren't committable""" | |
1767 | if match.isexact() or match.prefix(): |
|
1766 | if match.isexact() or match.prefix(): | |
1768 | matched = set(status.modified + status.added + status.removed) |
|
1767 | matched = set(status.modified + status.added + status.removed) | |
1769 |
|
1768 | |||
1770 | for f in match.files(): |
|
1769 | for f in match.files(): | |
1771 | f = self.dirstate.normalize(f) |
|
1770 | f = self.dirstate.normalize(f) | |
1772 | if f == '.' or f in matched or f in wctx.substate: |
|
1771 | if f == '.' or f in matched or f in wctx.substate: | |
1773 | continue |
|
1772 | continue | |
1774 | if f in status.deleted: |
|
1773 | if f in status.deleted: | |
1775 | fail(f, _('file not found!')) |
|
1774 | fail(f, _('file not found!')) | |
1776 | if f in vdirs: # visited directory |
|
1775 | if f in vdirs: # visited directory | |
1777 | d = f + '/' |
|
1776 | d = f + '/' | |
1778 | for mf in matched: |
|
1777 | for mf in matched: | |
1779 | if mf.startswith(d): |
|
1778 | if mf.startswith(d): | |
1780 | break |
|
1779 | break | |
1781 | else: |
|
1780 | else: | |
1782 | fail(f, _("no match under directory!")) |
|
1781 | fail(f, _("no match under directory!")) | |
1783 | elif f not in self.dirstate: |
|
1782 | elif f not in self.dirstate: | |
1784 | fail(f, _("file not tracked!")) |
|
1783 | fail(f, _("file not tracked!")) | |
1785 |
|
1784 | |||
1786 | @unfilteredmethod |
|
1785 | @unfilteredmethod | |
1787 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
1786 | def commit(self, text="", user=None, date=None, match=None, force=False, | |
1788 | editor=False, extra=None): |
|
1787 | editor=False, extra=None): | |
1789 | """Add a new revision to current repository. |
|
1788 | """Add a new revision to current repository. | |
1790 |
|
1789 | |||
1791 | Revision information is gathered from the working directory, |
|
1790 | Revision information is gathered from the working directory, | |
1792 | match can be used to filter the committed files. If editor is |
|
1791 | match can be used to filter the committed files. If editor is | |
1793 | supplied, it is called to get a commit message. |
|
1792 | supplied, it is called to get a commit message. | |
1794 | """ |
|
1793 | """ | |
1795 | if extra is None: |
|
1794 | if extra is None: | |
1796 | extra = {} |
|
1795 | extra = {} | |
1797 |
|
1796 | |||
1798 | def fail(f, msg): |
|
1797 | def fail(f, msg): | |
1799 | raise error.Abort('%s: %s' % (f, msg)) |
|
1798 | raise error.Abort('%s: %s' % (f, msg)) | |
1800 |
|
1799 | |||
1801 | if not match: |
|
1800 | if not match: | |
1802 | match = matchmod.always(self.root, '') |
|
1801 | match = matchmod.always(self.root, '') | |
1803 |
|
1802 | |||
1804 | if not force: |
|
1803 | if not force: | |
1805 | vdirs = [] |
|
1804 | vdirs = [] | |
1806 | match.explicitdir = vdirs.append |
|
1805 | match.explicitdir = vdirs.append | |
1807 | match.bad = fail |
|
1806 | match.bad = fail | |
1808 |
|
1807 | |||
1809 | wlock = lock = tr = None |
|
1808 | wlock = lock = tr = None | |
1810 | try: |
|
1809 | try: | |
1811 | wlock = self.wlock() |
|
1810 | wlock = self.wlock() | |
1812 | lock = self.lock() # for recent changelog (see issue4368) |
|
1811 | lock = self.lock() # for recent changelog (see issue4368) | |
1813 |
|
1812 | |||
1814 | wctx = self[None] |
|
1813 | wctx = self[None] | |
1815 | merge = len(wctx.parents()) > 1 |
|
1814 | merge = len(wctx.parents()) > 1 | |
1816 |
|
1815 | |||
1817 | if not force and merge and not match.always(): |
|
1816 | if not force and merge and not match.always(): | |
1818 | raise error.Abort(_('cannot partially commit a merge ' |
|
1817 | raise error.Abort(_('cannot partially commit a merge ' | |
1819 | '(do not specify files or patterns)')) |
|
1818 | '(do not specify files or patterns)')) | |
1820 |
|
1819 | |||
1821 | status = self.status(match=match, clean=force) |
|
1820 | status = self.status(match=match, clean=force) | |
1822 | if force: |
|
1821 | if force: | |
1823 | status.modified.extend(status.clean) # mq may commit clean files |
|
1822 | status.modified.extend(status.clean) # mq may commit clean files | |
1824 |
|
1823 | |||
1825 | # check subrepos |
|
1824 | # check subrepos | |
1826 | subs, commitsubs, newstate = subrepo.precommit( |
|
1825 | subs, commitsubs, newstate = subrepo.precommit( | |
1827 | self.ui, wctx, status, match, force=force) |
|
1826 | self.ui, wctx, status, match, force=force) | |
1828 |
|
1827 | |||
1829 | # make sure all explicit patterns are matched |
|
1828 | # make sure all explicit patterns are matched | |
1830 | if not force: |
|
1829 | if not force: | |
1831 | self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
|
1830 | self.checkcommitpatterns(wctx, vdirs, match, status, fail) | |
1832 |
|
1831 | |||
1833 | cctx = context.workingcommitctx(self, status, |
|
1832 | cctx = context.workingcommitctx(self, status, | |
1834 | text, user, date, extra) |
|
1833 | text, user, date, extra) | |
1835 |
|
1834 | |||
1836 | # internal config: ui.allowemptycommit |
|
1835 | # internal config: ui.allowemptycommit | |
1837 | allowemptycommit = (wctx.branch() != wctx.p1().branch() |
|
1836 | allowemptycommit = (wctx.branch() != wctx.p1().branch() | |
1838 | or extra.get('close') or merge or cctx.files() |
|
1837 | or extra.get('close') or merge or cctx.files() | |
1839 | or self.ui.configbool('ui', 'allowemptycommit')) |
|
1838 | or self.ui.configbool('ui', 'allowemptycommit')) | |
1840 | if not allowemptycommit: |
|
1839 | if not allowemptycommit: | |
1841 | return None |
|
1840 | return None | |
1842 |
|
1841 | |||
1843 | if merge and cctx.deleted(): |
|
1842 | if merge and cctx.deleted(): | |
1844 | raise error.Abort(_("cannot commit merge with missing files")) |
|
1843 | raise error.Abort(_("cannot commit merge with missing files")) | |
1845 |
|
1844 | |||
1846 | ms = mergemod.mergestate.read(self) |
|
1845 | ms = mergemod.mergestate.read(self) | |
1847 | mergeutil.checkunresolved(ms) |
|
1846 | mergeutil.checkunresolved(ms) | |
1848 |
|
1847 | |||
1849 | if editor: |
|
1848 | if editor: | |
1850 | cctx._text = editor(self, cctx, subs) |
|
1849 | cctx._text = editor(self, cctx, subs) | |
1851 | edited = (text != cctx._text) |
|
1850 | edited = (text != cctx._text) | |
1852 |
|
1851 | |||
1853 | # Save commit message in case this transaction gets rolled back |
|
1852 | # Save commit message in case this transaction gets rolled back | |
1854 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
1853 | # (e.g. by a pretxncommit hook). Leave the content alone on | |
1855 | # the assumption that the user will use the same editor again. |
|
1854 | # the assumption that the user will use the same editor again. | |
1856 | msgfn = self.savecommitmessage(cctx._text) |
|
1855 | msgfn = self.savecommitmessage(cctx._text) | |
1857 |
|
1856 | |||
1858 | # commit subs and write new state |
|
1857 | # commit subs and write new state | |
1859 | if subs: |
|
1858 | if subs: | |
1860 | for s in sorted(commitsubs): |
|
1859 | for s in sorted(commitsubs): | |
1861 | sub = wctx.sub(s) |
|
1860 | sub = wctx.sub(s) | |
1862 | self.ui.status(_('committing subrepository %s\n') % |
|
1861 | self.ui.status(_('committing subrepository %s\n') % | |
1863 | subrepo.subrelpath(sub)) |
|
1862 | subrepo.subrelpath(sub)) | |
1864 | sr = sub.commit(cctx._text, user, date) |
|
1863 | sr = sub.commit(cctx._text, user, date) | |
1865 | newstate[s] = (newstate[s][0], sr) |
|
1864 | newstate[s] = (newstate[s][0], sr) | |
1866 | subrepo.writestate(self, newstate) |
|
1865 | subrepo.writestate(self, newstate) | |
1867 |
|
1866 | |||
1868 | p1, p2 = self.dirstate.parents() |
|
1867 | p1, p2 = self.dirstate.parents() | |
1869 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1868 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | |
1870 | try: |
|
1869 | try: | |
1871 | self.hook("precommit", throw=True, parent1=hookp1, |
|
1870 | self.hook("precommit", throw=True, parent1=hookp1, | |
1872 | parent2=hookp2) |
|
1871 | parent2=hookp2) | |
1873 | tr = self.transaction('commit') |
|
1872 | tr = self.transaction('commit') | |
1874 | ret = self.commitctx(cctx, True) |
|
1873 | ret = self.commitctx(cctx, True) | |
1875 | except: # re-raises |
|
1874 | except: # re-raises | |
1876 | if edited: |
|
1875 | if edited: | |
1877 | self.ui.write( |
|
1876 | self.ui.write( | |
1878 | _('note: commit message saved in %s\n') % msgfn) |
|
1877 | _('note: commit message saved in %s\n') % msgfn) | |
1879 | raise |
|
1878 | raise | |
1880 | # update bookmarks, dirstate and mergestate |
|
1879 | # update bookmarks, dirstate and mergestate | |
1881 | bookmarks.update(self, [p1, p2], ret) |
|
1880 | bookmarks.update(self, [p1, p2], ret) | |
1882 | cctx.markcommitted(ret) |
|
1881 | cctx.markcommitted(ret) | |
1883 | ms.reset() |
|
1882 | ms.reset() | |
1884 | tr.close() |
|
1883 | tr.close() | |
1885 |
|
1884 | |||
1886 | finally: |
|
1885 | finally: | |
1887 | lockmod.release(tr, lock, wlock) |
|
1886 | lockmod.release(tr, lock, wlock) | |
1888 |
|
1887 | |||
1889 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
|
1888 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): | |
1890 | # hack for command that use a temporary commit (eg: histedit) |
|
1889 | # hack for command that use a temporary commit (eg: histedit) | |
1891 | # temporary commit got stripped before hook release |
|
1890 | # temporary commit got stripped before hook release | |
1892 | if self.changelog.hasnode(ret): |
|
1891 | if self.changelog.hasnode(ret): | |
1893 | self.hook("commit", node=node, parent1=parent1, |
|
1892 | self.hook("commit", node=node, parent1=parent1, | |
1894 | parent2=parent2) |
|
1893 | parent2=parent2) | |
1895 | self._afterlock(commithook) |
|
1894 | self._afterlock(commithook) | |
1896 | return ret |
|
1895 | return ret | |
1897 |
|
1896 | |||
1898 | @unfilteredmethod |
|
1897 | @unfilteredmethod | |
1899 | def commitctx(self, ctx, error=False): |
|
1898 | def commitctx(self, ctx, error=False): | |
1900 | """Add a new revision to current repository. |
|
1899 | """Add a new revision to current repository. | |
1901 | Revision information is passed via the context argument. |
|
1900 | Revision information is passed via the context argument. | |
1902 | """ |
|
1901 | """ | |
1903 |
|
1902 | |||
1904 | tr = None |
|
1903 | tr = None | |
1905 | p1, p2 = ctx.p1(), ctx.p2() |
|
1904 | p1, p2 = ctx.p1(), ctx.p2() | |
1906 | user = ctx.user() |
|
1905 | user = ctx.user() | |
1907 |
|
1906 | |||
1908 | lock = self.lock() |
|
1907 | lock = self.lock() | |
1909 | try: |
|
1908 | try: | |
1910 | tr = self.transaction("commit") |
|
1909 | tr = self.transaction("commit") | |
1911 | trp = weakref.proxy(tr) |
|
1910 | trp = weakref.proxy(tr) | |
1912 |
|
1911 | |||
1913 | if ctx.manifestnode(): |
|
1912 | if ctx.manifestnode(): | |
1914 | # reuse an existing manifest revision |
|
1913 | # reuse an existing manifest revision | |
1915 | mn = ctx.manifestnode() |
|
1914 | mn = ctx.manifestnode() | |
1916 | files = ctx.files() |
|
1915 | files = ctx.files() | |
1917 | elif ctx.files(): |
|
1916 | elif ctx.files(): | |
1918 | m1ctx = p1.manifestctx() |
|
1917 | m1ctx = p1.manifestctx() | |
1919 | m2ctx = p2.manifestctx() |
|
1918 | m2ctx = p2.manifestctx() | |
1920 | mctx = m1ctx.copy() |
|
1919 | mctx = m1ctx.copy() | |
1921 |
|
1920 | |||
1922 | m = mctx.read() |
|
1921 | m = mctx.read() | |
1923 | m1 = m1ctx.read() |
|
1922 | m1 = m1ctx.read() | |
1924 | m2 = m2ctx.read() |
|
1923 | m2 = m2ctx.read() | |
1925 |
|
1924 | |||
1926 | # check in files |
|
1925 | # check in files | |
1927 | added = [] |
|
1926 | added = [] | |
1928 | changed = [] |
|
1927 | changed = [] | |
1929 | removed = list(ctx.removed()) |
|
1928 | removed = list(ctx.removed()) | |
1930 | linkrev = len(self) |
|
1929 | linkrev = len(self) | |
1931 | self.ui.note(_("committing files:\n")) |
|
1930 | self.ui.note(_("committing files:\n")) | |
1932 | for f in sorted(ctx.modified() + ctx.added()): |
|
1931 | for f in sorted(ctx.modified() + ctx.added()): | |
1933 | self.ui.note(f + "\n") |
|
1932 | self.ui.note(f + "\n") | |
1934 | try: |
|
1933 | try: | |
1935 | fctx = ctx[f] |
|
1934 | fctx = ctx[f] | |
1936 | if fctx is None: |
|
1935 | if fctx is None: | |
1937 | removed.append(f) |
|
1936 | removed.append(f) | |
1938 | else: |
|
1937 | else: | |
1939 | added.append(f) |
|
1938 | added.append(f) | |
1940 | m[f] = self._filecommit(fctx, m1, m2, linkrev, |
|
1939 | m[f] = self._filecommit(fctx, m1, m2, linkrev, | |
1941 | trp, changed) |
|
1940 | trp, changed) | |
1942 | m.setflag(f, fctx.flags()) |
|
1941 | m.setflag(f, fctx.flags()) | |
1943 | except OSError as inst: |
|
1942 | except OSError as inst: | |
1944 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1943 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1945 | raise |
|
1944 | raise | |
1946 | except IOError as inst: |
|
1945 | except IOError as inst: | |
1947 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
1946 | errcode = getattr(inst, 'errno', errno.ENOENT) | |
1948 | if error or errcode and errcode != errno.ENOENT: |
|
1947 | if error or errcode and errcode != errno.ENOENT: | |
1949 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1948 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1950 | raise |
|
1949 | raise | |
1951 |
|
1950 | |||
1952 | # update manifest |
|
1951 | # update manifest | |
1953 | self.ui.note(_("committing manifest\n")) |
|
1952 | self.ui.note(_("committing manifest\n")) | |
1954 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
1953 | removed = [f for f in sorted(removed) if f in m1 or f in m2] | |
1955 | drop = [f for f in removed if f in m] |
|
1954 | drop = [f for f in removed if f in m] | |
1956 | for f in drop: |
|
1955 | for f in drop: | |
1957 | del m[f] |
|
1956 | del m[f] | |
1958 | mn = mctx.write(trp, linkrev, |
|
1957 | mn = mctx.write(trp, linkrev, | |
1959 | p1.manifestnode(), p2.manifestnode(), |
|
1958 | p1.manifestnode(), p2.manifestnode(), | |
1960 | added, drop) |
|
1959 | added, drop) | |
1961 | files = changed + removed |
|
1960 | files = changed + removed | |
1962 | else: |
|
1961 | else: | |
1963 | mn = p1.manifestnode() |
|
1962 | mn = p1.manifestnode() | |
1964 | files = [] |
|
1963 | files = [] | |
1965 |
|
1964 | |||
1966 | # update changelog |
|
1965 | # update changelog | |
1967 | self.ui.note(_("committing changelog\n")) |
|
1966 | self.ui.note(_("committing changelog\n")) | |
1968 | self.changelog.delayupdate(tr) |
|
1967 | self.changelog.delayupdate(tr) | |
1969 | n = self.changelog.add(mn, files, ctx.description(), |
|
1968 | n = self.changelog.add(mn, files, ctx.description(), | |
1970 | trp, p1.node(), p2.node(), |
|
1969 | trp, p1.node(), p2.node(), | |
1971 | user, ctx.date(), ctx.extra().copy()) |
|
1970 | user, ctx.date(), ctx.extra().copy()) | |
1972 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
1971 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
1973 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
1972 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, | |
1974 | parent2=xp2) |
|
1973 | parent2=xp2) | |
1975 | # set the new commit is proper phase |
|
1974 | # set the new commit is proper phase | |
1976 | targetphase = subrepo.newcommitphase(self.ui, ctx) |
|
1975 | targetphase = subrepo.newcommitphase(self.ui, ctx) | |
1977 | if targetphase: |
|
1976 | if targetphase: | |
1978 | # retract boundary do not alter parent changeset. |
|
1977 | # retract boundary do not alter parent changeset. | |
1979 | # if a parent have higher the resulting phase will |
|
1978 | # if a parent have higher the resulting phase will | |
1980 | # be compliant anyway |
|
1979 | # be compliant anyway | |
1981 | # |
|
1980 | # | |
1982 | # if minimal phase was 0 we don't need to retract anything |
|
1981 | # if minimal phase was 0 we don't need to retract anything | |
1983 | phases.registernew(self, tr, targetphase, [n]) |
|
1982 | phases.registernew(self, tr, targetphase, [n]) | |
1984 | tr.close() |
|
1983 | tr.close() | |
1985 | return n |
|
1984 | return n | |
1986 | finally: |
|
1985 | finally: | |
1987 | if tr: |
|
1986 | if tr: | |
1988 | tr.release() |
|
1987 | tr.release() | |
1989 | lock.release() |
|
1988 | lock.release() | |
1990 |
|
1989 | |||
1991 | @unfilteredmethod |
|
1990 | @unfilteredmethod | |
1992 | def destroying(self): |
|
1991 | def destroying(self): | |
1993 | '''Inform the repository that nodes are about to be destroyed. |
|
1992 | '''Inform the repository that nodes are about to be destroyed. | |
1994 | Intended for use by strip and rollback, so there's a common |
|
1993 | Intended for use by strip and rollback, so there's a common | |
1995 | place for anything that has to be done before destroying history. |
|
1994 | place for anything that has to be done before destroying history. | |
1996 |
|
1995 | |||
1997 | This is mostly useful for saving state that is in memory and waiting |
|
1996 | This is mostly useful for saving state that is in memory and waiting | |
1998 | to be flushed when the current lock is released. Because a call to |
|
1997 | to be flushed when the current lock is released. Because a call to | |
1999 | destroyed is imminent, the repo will be invalidated causing those |
|
1998 | destroyed is imminent, the repo will be invalidated causing those | |
2000 | changes to stay in memory (waiting for the next unlock), or vanish |
|
1999 | changes to stay in memory (waiting for the next unlock), or vanish | |
2001 | completely. |
|
2000 | completely. | |
2002 | ''' |
|
2001 | ''' | |
2003 | # When using the same lock to commit and strip, the phasecache is left |
|
2002 | # When using the same lock to commit and strip, the phasecache is left | |
2004 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
2003 | # dirty after committing. Then when we strip, the repo is invalidated, | |
2005 | # causing those changes to disappear. |
|
2004 | # causing those changes to disappear. | |
2006 | if '_phasecache' in vars(self): |
|
2005 | if '_phasecache' in vars(self): | |
2007 | self._phasecache.write() |
|
2006 | self._phasecache.write() | |
2008 |
|
2007 | |||
2009 | @unfilteredmethod |
|
2008 | @unfilteredmethod | |
2010 | def destroyed(self): |
|
2009 | def destroyed(self): | |
2011 | '''Inform the repository that nodes have been destroyed. |
|
2010 | '''Inform the repository that nodes have been destroyed. | |
2012 | Intended for use by strip and rollback, so there's a common |
|
2011 | Intended for use by strip and rollback, so there's a common | |
2013 | place for anything that has to be done after destroying history. |
|
2012 | place for anything that has to be done after destroying history. | |
2014 | ''' |
|
2013 | ''' | |
2015 | # When one tries to: |
|
2014 | # When one tries to: | |
2016 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
2015 | # 1) destroy nodes thus calling this method (e.g. strip) | |
2017 | # 2) use phasecache somewhere (e.g. commit) |
|
2016 | # 2) use phasecache somewhere (e.g. commit) | |
2018 | # |
|
2017 | # | |
2019 | # then 2) will fail because the phasecache contains nodes that were |
|
2018 | # then 2) will fail because the phasecache contains nodes that were | |
2020 | # removed. We can either remove phasecache from the filecache, |
|
2019 | # removed. We can either remove phasecache from the filecache, | |
2021 | # causing it to reload next time it is accessed, or simply filter |
|
2020 | # causing it to reload next time it is accessed, or simply filter | |
2022 | # the removed nodes now and write the updated cache. |
|
2021 | # the removed nodes now and write the updated cache. | |
2023 | self._phasecache.filterunknown(self) |
|
2022 | self._phasecache.filterunknown(self) | |
2024 | self._phasecache.write() |
|
2023 | self._phasecache.write() | |
2025 |
|
2024 | |||
2026 | # refresh all repository caches |
|
2025 | # refresh all repository caches | |
2027 | self.updatecaches() |
|
2026 | self.updatecaches() | |
2028 |
|
2027 | |||
2029 | # Ensure the persistent tag cache is updated. Doing it now |
|
2028 | # Ensure the persistent tag cache is updated. Doing it now | |
2030 | # means that the tag cache only has to worry about destroyed |
|
2029 | # means that the tag cache only has to worry about destroyed | |
2031 | # heads immediately after a strip/rollback. That in turn |
|
2030 | # heads immediately after a strip/rollback. That in turn | |
2032 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
2031 | # guarantees that "cachetip == currenttip" (comparing both rev | |
2033 | # and node) always means no nodes have been added or destroyed. |
|
2032 | # and node) always means no nodes have been added or destroyed. | |
2034 |
|
2033 | |||
2035 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
2034 | # XXX this is suboptimal when qrefresh'ing: we strip the current | |
2036 | # head, refresh the tag cache, then immediately add a new head. |
|
2035 | # head, refresh the tag cache, then immediately add a new head. | |
2037 | # But I think doing it this way is necessary for the "instant |
|
2036 | # But I think doing it this way is necessary for the "instant | |
2038 | # tag cache retrieval" case to work. |
|
2037 | # tag cache retrieval" case to work. | |
2039 | self.invalidate() |
|
2038 | self.invalidate() | |
2040 |
|
2039 | |||
2041 | def walk(self, match, node=None): |
|
2040 | def walk(self, match, node=None): | |
2042 | ''' |
|
2041 | ''' | |
2043 | walk recursively through the directory tree or a given |
|
2042 | walk recursively through the directory tree or a given | |
2044 | changeset, finding all files matched by the match |
|
2043 | changeset, finding all files matched by the match | |
2045 | function |
|
2044 | function | |
2046 | ''' |
|
2045 | ''' | |
2047 | self.ui.deprecwarn('use repo[node].walk instead of repo.walk', '4.3') |
|
2046 | self.ui.deprecwarn('use repo[node].walk instead of repo.walk', '4.3') | |
2048 | return self[node].walk(match) |
|
2047 | return self[node].walk(match) | |
2049 |
|
2048 | |||
2050 | def status(self, node1='.', node2=None, match=None, |
|
2049 | def status(self, node1='.', node2=None, match=None, | |
2051 | ignored=False, clean=False, unknown=False, |
|
2050 | ignored=False, clean=False, unknown=False, | |
2052 | listsubrepos=False): |
|
2051 | listsubrepos=False): | |
2053 | '''a convenience method that calls node1.status(node2)''' |
|
2052 | '''a convenience method that calls node1.status(node2)''' | |
2054 | return self[node1].status(node2, match, ignored, clean, unknown, |
|
2053 | return self[node1].status(node2, match, ignored, clean, unknown, | |
2055 | listsubrepos) |
|
2054 | listsubrepos) | |
2056 |
|
2055 | |||
2057 | def addpostdsstatus(self, ps): |
|
2056 | def addpostdsstatus(self, ps): | |
2058 | """Add a callback to run within the wlock, at the point at which status |
|
2057 | """Add a callback to run within the wlock, at the point at which status | |
2059 | fixups happen. |
|
2058 | fixups happen. | |
2060 |
|
2059 | |||
2061 | On status completion, callback(wctx, status) will be called with the |
|
2060 | On status completion, callback(wctx, status) will be called with the | |
2062 | wlock held, unless the dirstate has changed from underneath or the wlock |
|
2061 | wlock held, unless the dirstate has changed from underneath or the wlock | |
2063 | couldn't be grabbed. |
|
2062 | couldn't be grabbed. | |
2064 |
|
2063 | |||
2065 | Callbacks should not capture and use a cached copy of the dirstate -- |
|
2064 | Callbacks should not capture and use a cached copy of the dirstate -- | |
2066 | it might change in the meanwhile. Instead, they should access the |
|
2065 | it might change in the meanwhile. Instead, they should access the | |
2067 | dirstate via wctx.repo().dirstate. |
|
2066 | dirstate via wctx.repo().dirstate. | |
2068 |
|
2067 | |||
2069 | This list is emptied out after each status run -- extensions should |
|
2068 | This list is emptied out after each status run -- extensions should | |
2070 | make sure it adds to this list each time dirstate.status is called. |
|
2069 | make sure it adds to this list each time dirstate.status is called. | |
2071 | Extensions should also make sure they don't call this for statuses |
|
2070 | Extensions should also make sure they don't call this for statuses | |
2072 | that don't involve the dirstate. |
|
2071 | that don't involve the dirstate. | |
2073 | """ |
|
2072 | """ | |
2074 |
|
2073 | |||
2075 | # The list is located here for uniqueness reasons -- it is actually |
|
2074 | # The list is located here for uniqueness reasons -- it is actually | |
2076 | # managed by the workingctx, but that isn't unique per-repo. |
|
2075 | # managed by the workingctx, but that isn't unique per-repo. | |
2077 | self._postdsstatus.append(ps) |
|
2076 | self._postdsstatus.append(ps) | |
2078 |
|
2077 | |||
2079 | def postdsstatus(self): |
|
2078 | def postdsstatus(self): | |
2080 | """Used by workingctx to get the list of post-dirstate-status hooks.""" |
|
2079 | """Used by workingctx to get the list of post-dirstate-status hooks.""" | |
2081 | return self._postdsstatus |
|
2080 | return self._postdsstatus | |
2082 |
|
2081 | |||
2083 | def clearpostdsstatus(self): |
|
2082 | def clearpostdsstatus(self): | |
2084 | """Used by workingctx to clear post-dirstate-status hooks.""" |
|
2083 | """Used by workingctx to clear post-dirstate-status hooks.""" | |
2085 | del self._postdsstatus[:] |
|
2084 | del self._postdsstatus[:] | |
2086 |
|
2085 | |||
2087 | def heads(self, start=None): |
|
2086 | def heads(self, start=None): | |
2088 | if start is None: |
|
2087 | if start is None: | |
2089 | cl = self.changelog |
|
2088 | cl = self.changelog | |
2090 | headrevs = reversed(cl.headrevs()) |
|
2089 | headrevs = reversed(cl.headrevs()) | |
2091 | return [cl.node(rev) for rev in headrevs] |
|
2090 | return [cl.node(rev) for rev in headrevs] | |
2092 |
|
2091 | |||
2093 | heads = self.changelog.heads(start) |
|
2092 | heads = self.changelog.heads(start) | |
2094 | # sort the output in rev descending order |
|
2093 | # sort the output in rev descending order | |
2095 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
2094 | return sorted(heads, key=self.changelog.rev, reverse=True) | |
2096 |
|
2095 | |||
2097 | def branchheads(self, branch=None, start=None, closed=False): |
|
2096 | def branchheads(self, branch=None, start=None, closed=False): | |
2098 | '''return a (possibly filtered) list of heads for the given branch |
|
2097 | '''return a (possibly filtered) list of heads for the given branch | |
2099 |
|
2098 | |||
2100 | Heads are returned in topological order, from newest to oldest. |
|
2099 | Heads are returned in topological order, from newest to oldest. | |
2101 | If branch is None, use the dirstate branch. |
|
2100 | If branch is None, use the dirstate branch. | |
2102 | If start is not None, return only heads reachable from start. |
|
2101 | If start is not None, return only heads reachable from start. | |
2103 | If closed is True, return heads that are marked as closed as well. |
|
2102 | If closed is True, return heads that are marked as closed as well. | |
2104 | ''' |
|
2103 | ''' | |
2105 | if branch is None: |
|
2104 | if branch is None: | |
2106 | branch = self[None].branch() |
|
2105 | branch = self[None].branch() | |
2107 | branches = self.branchmap() |
|
2106 | branches = self.branchmap() | |
2108 | if branch not in branches: |
|
2107 | if branch not in branches: | |
2109 | return [] |
|
2108 | return [] | |
2110 | # the cache returns heads ordered lowest to highest |
|
2109 | # the cache returns heads ordered lowest to highest | |
2111 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
2110 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) | |
2112 | if start is not None: |
|
2111 | if start is not None: | |
2113 | # filter out the heads that cannot be reached from startrev |
|
2112 | # filter out the heads that cannot be reached from startrev | |
2114 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
2113 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) | |
2115 | bheads = [h for h in bheads if h in fbheads] |
|
2114 | bheads = [h for h in bheads if h in fbheads] | |
2116 | return bheads |
|
2115 | return bheads | |
2117 |
|
2116 | |||
2118 | def branches(self, nodes): |
|
2117 | def branches(self, nodes): | |
2119 | if not nodes: |
|
2118 | if not nodes: | |
2120 | nodes = [self.changelog.tip()] |
|
2119 | nodes = [self.changelog.tip()] | |
2121 | b = [] |
|
2120 | b = [] | |
2122 | for n in nodes: |
|
2121 | for n in nodes: | |
2123 | t = n |
|
2122 | t = n | |
2124 | while True: |
|
2123 | while True: | |
2125 | p = self.changelog.parents(n) |
|
2124 | p = self.changelog.parents(n) | |
2126 | if p[1] != nullid or p[0] == nullid: |
|
2125 | if p[1] != nullid or p[0] == nullid: | |
2127 | b.append((t, n, p[0], p[1])) |
|
2126 | b.append((t, n, p[0], p[1])) | |
2128 | break |
|
2127 | break | |
2129 | n = p[0] |
|
2128 | n = p[0] | |
2130 | return b |
|
2129 | return b | |
2131 |
|
2130 | |||
2132 | def between(self, pairs): |
|
2131 | def between(self, pairs): | |
2133 | r = [] |
|
2132 | r = [] | |
2134 |
|
2133 | |||
2135 | for top, bottom in pairs: |
|
2134 | for top, bottom in pairs: | |
2136 | n, l, i = top, [], 0 |
|
2135 | n, l, i = top, [], 0 | |
2137 | f = 1 |
|
2136 | f = 1 | |
2138 |
|
2137 | |||
2139 | while n != bottom and n != nullid: |
|
2138 | while n != bottom and n != nullid: | |
2140 | p = self.changelog.parents(n)[0] |
|
2139 | p = self.changelog.parents(n)[0] | |
2141 | if i == f: |
|
2140 | if i == f: | |
2142 | l.append(n) |
|
2141 | l.append(n) | |
2143 | f = f * 2 |
|
2142 | f = f * 2 | |
2144 | n = p |
|
2143 | n = p | |
2145 | i += 1 |
|
2144 | i += 1 | |
2146 |
|
2145 | |||
2147 | r.append(l) |
|
2146 | r.append(l) | |
2148 |
|
2147 | |||
2149 | return r |
|
2148 | return r | |
2150 |
|
2149 | |||
2151 | def checkpush(self, pushop): |
|
2150 | def checkpush(self, pushop): | |
2152 | """Extensions can override this function if additional checks have |
|
2151 | """Extensions can override this function if additional checks have | |
2153 | to be performed before pushing, or call it if they override push |
|
2152 | to be performed before pushing, or call it if they override push | |
2154 | command. |
|
2153 | command. | |
2155 | """ |
|
2154 | """ | |
2156 |
|
2155 | |||
2157 | @unfilteredpropertycache |
|
2156 | @unfilteredpropertycache | |
2158 | def prepushoutgoinghooks(self): |
|
2157 | def prepushoutgoinghooks(self): | |
2159 | """Return util.hooks consists of a pushop with repo, remote, outgoing |
|
2158 | """Return util.hooks consists of a pushop with repo, remote, outgoing | |
2160 | methods, which are called before pushing changesets. |
|
2159 | methods, which are called before pushing changesets. | |
2161 | """ |
|
2160 | """ | |
2162 | return util.hooks() |
|
2161 | return util.hooks() | |
2163 |
|
2162 | |||
2164 | def pushkey(self, namespace, key, old, new): |
|
2163 | def pushkey(self, namespace, key, old, new): | |
2165 | try: |
|
2164 | try: | |
2166 | tr = self.currenttransaction() |
|
2165 | tr = self.currenttransaction() | |
2167 | hookargs = {} |
|
2166 | hookargs = {} | |
2168 | if tr is not None: |
|
2167 | if tr is not None: | |
2169 | hookargs.update(tr.hookargs) |
|
2168 | hookargs.update(tr.hookargs) | |
2170 | hookargs['namespace'] = namespace |
|
2169 | hookargs['namespace'] = namespace | |
2171 | hookargs['key'] = key |
|
2170 | hookargs['key'] = key | |
2172 | hookargs['old'] = old |
|
2171 | hookargs['old'] = old | |
2173 | hookargs['new'] = new |
|
2172 | hookargs['new'] = new | |
2174 | self.hook('prepushkey', throw=True, **hookargs) |
|
2173 | self.hook('prepushkey', throw=True, **hookargs) | |
2175 | except error.HookAbort as exc: |
|
2174 | except error.HookAbort as exc: | |
2176 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) |
|
2175 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) | |
2177 | if exc.hint: |
|
2176 | if exc.hint: | |
2178 | self.ui.write_err(_("(%s)\n") % exc.hint) |
|
2177 | self.ui.write_err(_("(%s)\n") % exc.hint) | |
2179 | return False |
|
2178 | return False | |
2180 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) |
|
2179 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) | |
2181 | ret = pushkey.push(self, namespace, key, old, new) |
|
2180 | ret = pushkey.push(self, namespace, key, old, new) | |
2182 | def runhook(): |
|
2181 | def runhook(): | |
2183 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
2182 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, | |
2184 | ret=ret) |
|
2183 | ret=ret) | |
2185 | self._afterlock(runhook) |
|
2184 | self._afterlock(runhook) | |
2186 | return ret |
|
2185 | return ret | |
2187 |
|
2186 | |||
2188 | def listkeys(self, namespace): |
|
2187 | def listkeys(self, namespace): | |
2189 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
2188 | self.hook('prelistkeys', throw=True, namespace=namespace) | |
2190 | self.ui.debug('listing keys for "%s"\n' % namespace) |
|
2189 | self.ui.debug('listing keys for "%s"\n' % namespace) | |
2191 | values = pushkey.list(self, namespace) |
|
2190 | values = pushkey.list(self, namespace) | |
2192 | self.hook('listkeys', namespace=namespace, values=values) |
|
2191 | self.hook('listkeys', namespace=namespace, values=values) | |
2193 | return values |
|
2192 | return values | |
2194 |
|
2193 | |||
2195 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
2194 | def debugwireargs(self, one, two, three=None, four=None, five=None): | |
2196 | '''used to test argument passing over the wire''' |
|
2195 | '''used to test argument passing over the wire''' | |
2197 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
2196 | return "%s %s %s %s %s" % (one, two, three, four, five) | |
2198 |
|
2197 | |||
2199 | def savecommitmessage(self, text): |
|
2198 | def savecommitmessage(self, text): | |
2200 | fp = self.vfs('last-message.txt', 'wb') |
|
2199 | fp = self.vfs('last-message.txt', 'wb') | |
2201 | try: |
|
2200 | try: | |
2202 | fp.write(text) |
|
2201 | fp.write(text) | |
2203 | finally: |
|
2202 | finally: | |
2204 | fp.close() |
|
2203 | fp.close() | |
2205 | return self.pathto(fp.name[len(self.root) + 1:]) |
|
2204 | return self.pathto(fp.name[len(self.root) + 1:]) | |
2206 |
|
2205 | |||
2207 | # used to avoid circular references so destructors work |
|
2206 | # used to avoid circular references so destructors work | |
2208 | def aftertrans(files): |
|
2207 | def aftertrans(files): | |
2209 | renamefiles = [tuple(t) for t in files] |
|
2208 | renamefiles = [tuple(t) for t in files] | |
2210 | def a(): |
|
2209 | def a(): | |
2211 | for vfs, src, dest in renamefiles: |
|
2210 | for vfs, src, dest in renamefiles: | |
2212 | # if src and dest refer to a same file, vfs.rename is a no-op, |
|
2211 | # if src and dest refer to a same file, vfs.rename is a no-op, | |
2213 | # leaving both src and dest on disk. delete dest to make sure |
|
2212 | # leaving both src and dest on disk. delete dest to make sure | |
2214 | # the rename couldn't be such a no-op. |
|
2213 | # the rename couldn't be such a no-op. | |
2215 | vfs.tryunlink(dest) |
|
2214 | vfs.tryunlink(dest) | |
2216 | try: |
|
2215 | try: | |
2217 | vfs.rename(src, dest) |
|
2216 | vfs.rename(src, dest) | |
2218 | except OSError: # journal file does not yet exist |
|
2217 | except OSError: # journal file does not yet exist | |
2219 | pass |
|
2218 | pass | |
2220 | return a |
|
2219 | return a | |
2221 |
|
2220 | |||
2222 | def undoname(fn): |
|
2221 | def undoname(fn): | |
2223 | base, name = os.path.split(fn) |
|
2222 | base, name = os.path.split(fn) | |
2224 | assert name.startswith('journal') |
|
2223 | assert name.startswith('journal') | |
2225 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
2224 | return os.path.join(base, name.replace('journal', 'undo', 1)) | |
2226 |
|
2225 | |||
2227 | def instance(ui, path, create): |
|
2226 | def instance(ui, path, create): | |
2228 | return localrepository(ui, util.urllocalpath(path), create) |
|
2227 | return localrepository(ui, util.urllocalpath(path), create) | |
2229 |
|
2228 | |||
2230 | def islocal(path): |
|
2229 | def islocal(path): | |
2231 | return True |
|
2230 | return True | |
2232 |
|
2231 | |||
2233 | def newreporequirements(repo): |
|
2232 | def newreporequirements(repo): | |
2234 | """Determine the set of requirements for a new local repository. |
|
2233 | """Determine the set of requirements for a new local repository. | |
2235 |
|
2234 | |||
2236 | Extensions can wrap this function to specify custom requirements for |
|
2235 | Extensions can wrap this function to specify custom requirements for | |
2237 | new repositories. |
|
2236 | new repositories. | |
2238 | """ |
|
2237 | """ | |
2239 | ui = repo.ui |
|
2238 | ui = repo.ui | |
2240 | requirements = {'revlogv1'} |
|
2239 | requirements = {'revlogv1'} | |
2241 | if ui.configbool('format', 'usestore'): |
|
2240 | if ui.configbool('format', 'usestore'): | |
2242 | requirements.add('store') |
|
2241 | requirements.add('store') | |
2243 | if ui.configbool('format', 'usefncache'): |
|
2242 | if ui.configbool('format', 'usefncache'): | |
2244 | requirements.add('fncache') |
|
2243 | requirements.add('fncache') | |
2245 | if ui.configbool('format', 'dotencode'): |
|
2244 | if ui.configbool('format', 'dotencode'): | |
2246 | requirements.add('dotencode') |
|
2245 | requirements.add('dotencode') | |
2247 |
|
2246 | |||
2248 | compengine = ui.config('experimental', 'format.compression') |
|
2247 | compengine = ui.config('experimental', 'format.compression') | |
2249 | if compengine not in util.compengines: |
|
2248 | if compengine not in util.compengines: | |
2250 | raise error.Abort(_('compression engine %s defined by ' |
|
2249 | raise error.Abort(_('compression engine %s defined by ' | |
2251 | 'experimental.format.compression not available') % |
|
2250 | 'experimental.format.compression not available') % | |
2252 | compengine, |
|
2251 | compengine, | |
2253 | hint=_('run "hg debuginstall" to list available ' |
|
2252 | hint=_('run "hg debuginstall" to list available ' | |
2254 | 'compression engines')) |
|
2253 | 'compression engines')) | |
2255 |
|
2254 | |||
2256 | # zlib is the historical default and doesn't need an explicit requirement. |
|
2255 | # zlib is the historical default and doesn't need an explicit requirement. | |
2257 | if compengine != 'zlib': |
|
2256 | if compengine != 'zlib': | |
2258 | requirements.add('exp-compression-%s' % compengine) |
|
2257 | requirements.add('exp-compression-%s' % compengine) | |
2259 |
|
2258 | |||
2260 | if scmutil.gdinitconfig(ui): |
|
2259 | if scmutil.gdinitconfig(ui): | |
2261 | requirements.add('generaldelta') |
|
2260 | requirements.add('generaldelta') | |
2262 | if ui.configbool('experimental', 'treemanifest'): |
|
2261 | if ui.configbool('experimental', 'treemanifest'): | |
2263 | requirements.add('treemanifest') |
|
2262 | requirements.add('treemanifest') | |
2264 | if ui.configbool('experimental', 'manifestv2'): |
|
2263 | if ui.configbool('experimental', 'manifestv2'): | |
2265 | requirements.add('manifestv2') |
|
2264 | requirements.add('manifestv2') | |
2266 |
|
2265 | |||
2267 | revlogv2 = ui.config('experimental', 'revlogv2') |
|
2266 | revlogv2 = ui.config('experimental', 'revlogv2') | |
2268 | if revlogv2 == 'enable-unstable-format-and-corrupt-my-data': |
|
2267 | if revlogv2 == 'enable-unstable-format-and-corrupt-my-data': | |
2269 | requirements.remove('revlogv1') |
|
2268 | requirements.remove('revlogv1') | |
2270 | # generaldelta is implied by revlogv2. |
|
2269 | # generaldelta is implied by revlogv2. | |
2271 | requirements.discard('generaldelta') |
|
2270 | requirements.discard('generaldelta') | |
2272 | requirements.add(REVLOGV2_REQUIREMENT) |
|
2271 | requirements.add(REVLOGV2_REQUIREMENT) | |
2273 |
|
2272 | |||
2274 | return requirements |
|
2273 | return requirements |
@@ -1,1010 +1,1008 | |||||
1 | #require killdaemons |
|
1 | #require killdaemons | |
2 |
|
2 | |||
3 | $ cat <<EOF >> $HGRCPATH |
|
3 | $ cat <<EOF >> $HGRCPATH | |
4 | > [extensions] |
|
4 | > [extensions] | |
5 | > transplant= |
|
5 | > transplant= | |
6 | > EOF |
|
6 | > EOF | |
7 |
|
7 | |||
8 | $ hg init t |
|
8 | $ hg init t | |
9 | $ cd t |
|
9 | $ cd t | |
10 | $ hg transplant |
|
10 | $ hg transplant | |
11 | abort: no source URL, branch revision, or revision list provided |
|
11 | abort: no source URL, branch revision, or revision list provided | |
12 | [255] |
|
12 | [255] | |
13 | $ hg transplant --continue --all |
|
13 | $ hg transplant --continue --all | |
14 | abort: --continue is incompatible with --branch, --all and --merge |
|
14 | abort: --continue is incompatible with --branch, --all and --merge | |
15 | [255] |
|
15 | [255] | |
16 | $ hg transplant --all tip |
|
16 | $ hg transplant --all tip | |
17 | abort: --all requires a branch revision |
|
17 | abort: --all requires a branch revision | |
18 | [255] |
|
18 | [255] | |
19 | $ hg transplant --all --branch default tip |
|
19 | $ hg transplant --all --branch default tip | |
20 | abort: --all is incompatible with a revision list |
|
20 | abort: --all is incompatible with a revision list | |
21 | [255] |
|
21 | [255] | |
22 | $ echo r1 > r1 |
|
22 | $ echo r1 > r1 | |
23 | $ hg ci -Amr1 -d'0 0' |
|
23 | $ hg ci -Amr1 -d'0 0' | |
24 | adding r1 |
|
24 | adding r1 | |
25 | $ hg co -q null |
|
25 | $ hg co -q null | |
26 | $ hg transplant tip |
|
26 | $ hg transplant tip | |
27 | abort: no revision checked out |
|
27 | abort: no revision checked out | |
28 | [255] |
|
28 | [255] | |
29 | $ hg up -q |
|
29 | $ hg up -q | |
30 | $ echo r2 > r2 |
|
30 | $ echo r2 > r2 | |
31 | $ hg ci -Amr2 -d'1 0' |
|
31 | $ hg ci -Amr2 -d'1 0' | |
32 | adding r2 |
|
32 | adding r2 | |
33 | $ hg up 0 |
|
33 | $ hg up 0 | |
34 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
34 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
35 |
|
35 | |||
36 | $ echo b1 > b1 |
|
36 | $ echo b1 > b1 | |
37 | $ hg ci -Amb1 -d '0 0' |
|
37 | $ hg ci -Amb1 -d '0 0' | |
38 | adding b1 |
|
38 | adding b1 | |
39 | created new head |
|
39 | created new head | |
40 | $ hg merge 1 |
|
40 | $ hg merge 1 | |
41 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
41 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
42 | (branch merge, don't forget to commit) |
|
42 | (branch merge, don't forget to commit) | |
43 | $ hg transplant 1 |
|
43 | $ hg transplant 1 | |
44 | abort: outstanding uncommitted merges |
|
44 | abort: outstanding uncommitted merges | |
45 | [255] |
|
45 | [255] | |
46 | $ hg up -qC tip |
|
46 | $ hg up -qC tip | |
47 | $ echo b0 > b1 |
|
47 | $ echo b0 > b1 | |
48 | $ hg transplant 1 |
|
48 | $ hg transplant 1 | |
49 | abort: outstanding local changes |
|
49 | abort: outstanding local changes | |
50 | [255] |
|
50 | [255] | |
51 | $ hg up -qC tip |
|
51 | $ hg up -qC tip | |
52 | $ echo b2 > b2 |
|
52 | $ echo b2 > b2 | |
53 | $ hg ci -Amb2 -d '1 0' |
|
53 | $ hg ci -Amb2 -d '1 0' | |
54 | adding b2 |
|
54 | adding b2 | |
55 | $ echo b3 > b3 |
|
55 | $ echo b3 > b3 | |
56 | $ hg ci -Amb3 -d '2 0' |
|
56 | $ hg ci -Amb3 -d '2 0' | |
57 | adding b3 |
|
57 | adding b3 | |
58 |
|
58 | |||
59 | $ hg log --template '{rev} {parents} {desc}\n' |
|
59 | $ hg log --template '{rev} {parents} {desc}\n' | |
60 | 4 b3 |
|
60 | 4 b3 | |
61 | 3 b2 |
|
61 | 3 b2 | |
62 | 2 0:17ab29e464c6 b1 |
|
62 | 2 0:17ab29e464c6 b1 | |
63 | 1 r2 |
|
63 | 1 r2 | |
64 | 0 r1 |
|
64 | 0 r1 | |
65 |
|
65 | |||
66 | $ hg clone . ../rebase |
|
66 | $ hg clone . ../rebase | |
67 | updating to branch default |
|
67 | updating to branch default | |
68 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
68 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
69 | $ hg init ../emptydest |
|
69 | $ hg init ../emptydest | |
70 | $ cd ../emptydest |
|
70 | $ cd ../emptydest | |
71 | $ hg transplant --source=../t > /dev/null |
|
71 | $ hg transplant --source=../t > /dev/null | |
72 | $ cd ../rebase |
|
72 | $ cd ../rebase | |
73 |
|
73 | |||
74 | $ hg up -C 1 |
|
74 | $ hg up -C 1 | |
75 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
75 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
76 |
|
76 | |||
77 | rebase b onto r1 |
|
77 | rebase b onto r1 | |
78 | (this also tests that editor is not invoked if '--edit' is not specified) |
|
78 | (this also tests that editor is not invoked if '--edit' is not specified) | |
79 |
|
79 | |||
80 | $ HGEDITOR=cat hg transplant -a -b tip |
|
80 | $ HGEDITOR=cat hg transplant -a -b tip | |
81 | applying 37a1297eb21b |
|
81 | applying 37a1297eb21b | |
82 | 37a1297eb21b transplanted to e234d668f844 |
|
82 | 37a1297eb21b transplanted to e234d668f844 | |
83 | applying 722f4667af76 |
|
83 | applying 722f4667af76 | |
84 | 722f4667af76 transplanted to 539f377d78df |
|
84 | 722f4667af76 transplanted to 539f377d78df | |
85 | applying a53251cdf717 |
|
85 | applying a53251cdf717 | |
86 | a53251cdf717 transplanted to ffd6818a3975 |
|
86 | a53251cdf717 transplanted to ffd6818a3975 | |
87 | $ hg log --template '{rev} {parents} {desc}\n' |
|
87 | $ hg log --template '{rev} {parents} {desc}\n' | |
88 | 7 b3 |
|
88 | 7 b3 | |
89 | 6 b2 |
|
89 | 6 b2 | |
90 | 5 1:d11e3596cc1a b1 |
|
90 | 5 1:d11e3596cc1a b1 | |
91 | 4 b3 |
|
91 | 4 b3 | |
92 | 3 b2 |
|
92 | 3 b2 | |
93 | 2 0:17ab29e464c6 b1 |
|
93 | 2 0:17ab29e464c6 b1 | |
94 | 1 r2 |
|
94 | 1 r2 | |
95 | 0 r1 |
|
95 | 0 r1 | |
96 |
|
96 | |||
97 | test format of transplant_source |
|
97 | test format of transplant_source | |
98 |
|
98 | |||
99 | $ hg log -r7 --debug | grep transplant_source |
|
99 | $ hg log -r7 --debug | grep transplant_source | |
100 | extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
100 | extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
101 | $ hg log -r7 -T '{extras}\n' |
|
101 | $ hg log -r7 -T '{extras}\n' | |
102 | branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
102 | branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
103 | $ hg log -r7 -T '{join(extras, " ")}\n' |
|
103 | $ hg log -r7 -T '{join(extras, " ")}\n' | |
104 | branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
104 | branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
105 |
|
105 | |||
106 | test transplanted revset |
|
106 | test transplanted revset | |
107 |
|
107 | |||
108 | $ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n' |
|
108 | $ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n' | |
109 | 5 1:d11e3596cc1a b1 |
|
109 | 5 1:d11e3596cc1a b1 | |
110 | 6 b2 |
|
110 | 6 b2 | |
111 | 7 b3 |
|
111 | 7 b3 | |
112 | $ hg log -r 'transplanted(head())' --template '{rev} {parents} {desc}\n' |
|
112 | $ hg log -r 'transplanted(head())' --template '{rev} {parents} {desc}\n' | |
113 | 7 b3 |
|
113 | 7 b3 | |
114 | $ hg help revisions.transplanted |
|
114 | $ hg help revisions.transplanted | |
115 | "transplanted([set])" |
|
115 | "transplanted([set])" | |
116 | Transplanted changesets in set, or all transplanted changesets. |
|
116 | Transplanted changesets in set, or all transplanted changesets. | |
117 |
|
117 | |||
118 |
|
118 | |||
119 | test transplanted keyword |
|
119 | test transplanted keyword | |
120 |
|
120 | |||
121 | $ hg log --template '{rev} {transplanted}\n' |
|
121 | $ hg log --template '{rev} {transplanted}\n' | |
122 | 7 a53251cdf717679d1907b289f991534be05c997a |
|
122 | 7 a53251cdf717679d1907b289f991534be05c997a | |
123 | 6 722f4667af767100cb15b6a79324bf8abbfe1ef4 |
|
123 | 6 722f4667af767100cb15b6a79324bf8abbfe1ef4 | |
124 | 5 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21 |
|
124 | 5 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21 | |
125 | 4 |
|
125 | 4 | |
126 | 3 |
|
126 | 3 | |
127 | 2 |
|
127 | 2 | |
128 | 1 |
|
128 | 1 | |
129 | 0 |
|
129 | 0 | |
130 |
|
130 | |||
131 | test destination() revset predicate with a transplant of a transplant; new |
|
131 | test destination() revset predicate with a transplant of a transplant; new | |
132 | clone so subsequent rollback isn't affected |
|
132 | clone so subsequent rollback isn't affected | |
133 | (this also tests that editor is invoked if '--edit' is specified) |
|
133 | (this also tests that editor is invoked if '--edit' is specified) | |
134 |
|
134 | |||
135 | $ hg clone -q . ../destination |
|
135 | $ hg clone -q . ../destination | |
136 | $ cd ../destination |
|
136 | $ cd ../destination | |
137 | $ hg up -Cq 0 |
|
137 | $ hg up -Cq 0 | |
138 | $ hg branch -q b4 |
|
138 | $ hg branch -q b4 | |
139 | $ hg ci -qm "b4" |
|
139 | $ hg ci -qm "b4" | |
140 | $ hg status --rev "7^1" --rev 7 |
|
140 | $ hg status --rev "7^1" --rev 7 | |
141 | A b3 |
|
141 | A b3 | |
142 | $ cat > $TESTTMP/checkeditform.sh <<EOF |
|
142 | $ cat > $TESTTMP/checkeditform.sh <<EOF | |
143 | > env | grep HGEDITFORM |
|
143 | > env | grep HGEDITFORM | |
144 | > true |
|
144 | > true | |
145 | > EOF |
|
145 | > EOF | |
146 | $ cat > $TESTTMP/checkeditform-n-cat.sh <<EOF |
|
146 | $ cat > $TESTTMP/checkeditform-n-cat.sh <<EOF | |
147 | > env | grep HGEDITFORM |
|
147 | > env | grep HGEDITFORM | |
148 | > cat \$* |
|
148 | > cat \$* | |
149 | > EOF |
|
149 | > EOF | |
150 | $ HGEDITOR="sh $TESTTMP/checkeditform-n-cat.sh" hg transplant --edit 7 |
|
150 | $ HGEDITOR="sh $TESTTMP/checkeditform-n-cat.sh" hg transplant --edit 7 | |
151 | applying ffd6818a3975 |
|
151 | applying ffd6818a3975 | |
152 | HGEDITFORM=transplant.normal |
|
152 | HGEDITFORM=transplant.normal | |
153 | b3 |
|
153 | b3 | |
154 |
|
154 | |||
155 |
|
155 | |||
156 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
156 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
157 | HG: Leave message empty to abort commit. |
|
157 | HG: Leave message empty to abort commit. | |
158 | HG: -- |
|
158 | HG: -- | |
159 | HG: user: test |
|
159 | HG: user: test | |
160 | HG: branch 'b4' |
|
160 | HG: branch 'b4' | |
161 | HG: added b3 |
|
161 | HG: added b3 | |
162 | ffd6818a3975 transplanted to 502236fa76bb |
|
162 | ffd6818a3975 transplanted to 502236fa76bb | |
163 |
|
163 | |||
164 |
|
164 | |||
165 | $ hg log -r 'destination()' |
|
165 | $ hg log -r 'destination()' | |
166 | changeset: 5:e234d668f844 |
|
166 | changeset: 5:e234d668f844 | |
167 | parent: 1:d11e3596cc1a |
|
167 | parent: 1:d11e3596cc1a | |
168 | user: test |
|
168 | user: test | |
169 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
169 | date: Thu Jan 01 00:00:00 1970 +0000 | |
170 | summary: b1 |
|
170 | summary: b1 | |
171 |
|
171 | |||
172 | changeset: 6:539f377d78df |
|
172 | changeset: 6:539f377d78df | |
173 | user: test |
|
173 | user: test | |
174 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
174 | date: Thu Jan 01 00:00:01 1970 +0000 | |
175 | summary: b2 |
|
175 | summary: b2 | |
176 |
|
176 | |||
177 | changeset: 7:ffd6818a3975 |
|
177 | changeset: 7:ffd6818a3975 | |
178 | user: test |
|
178 | user: test | |
179 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
179 | date: Thu Jan 01 00:00:02 1970 +0000 | |
180 | summary: b3 |
|
180 | summary: b3 | |
181 |
|
181 | |||
182 | changeset: 9:502236fa76bb |
|
182 | changeset: 9:502236fa76bb | |
183 | branch: b4 |
|
183 | branch: b4 | |
184 | tag: tip |
|
184 | tag: tip | |
185 | user: test |
|
185 | user: test | |
186 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
186 | date: Thu Jan 01 00:00:02 1970 +0000 | |
187 | summary: b3 |
|
187 | summary: b3 | |
188 |
|
188 | |||
189 | $ hg log -r 'destination(a53251cdf717)' |
|
189 | $ hg log -r 'destination(a53251cdf717)' | |
190 | changeset: 7:ffd6818a3975 |
|
190 | changeset: 7:ffd6818a3975 | |
191 | user: test |
|
191 | user: test | |
192 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
192 | date: Thu Jan 01 00:00:02 1970 +0000 | |
193 | summary: b3 |
|
193 | summary: b3 | |
194 |
|
194 | |||
195 | changeset: 9:502236fa76bb |
|
195 | changeset: 9:502236fa76bb | |
196 | branch: b4 |
|
196 | branch: b4 | |
197 | tag: tip |
|
197 | tag: tip | |
198 | user: test |
|
198 | user: test | |
199 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
199 | date: Thu Jan 01 00:00:02 1970 +0000 | |
200 | summary: b3 |
|
200 | summary: b3 | |
201 |
|
201 | |||
202 |
|
202 | |||
203 | test subset parameter in reverse order |
|
203 | test subset parameter in reverse order | |
204 | $ hg log -r 'reverse(all()) and destination(a53251cdf717)' |
|
204 | $ hg log -r 'reverse(all()) and destination(a53251cdf717)' | |
205 | changeset: 9:502236fa76bb |
|
205 | changeset: 9:502236fa76bb | |
206 | branch: b4 |
|
206 | branch: b4 | |
207 | tag: tip |
|
207 | tag: tip | |
208 | user: test |
|
208 | user: test | |
209 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
209 | date: Thu Jan 01 00:00:02 1970 +0000 | |
210 | summary: b3 |
|
210 | summary: b3 | |
211 |
|
211 | |||
212 | changeset: 7:ffd6818a3975 |
|
212 | changeset: 7:ffd6818a3975 | |
213 | user: test |
|
213 | user: test | |
214 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
214 | date: Thu Jan 01 00:00:02 1970 +0000 | |
215 | summary: b3 |
|
215 | summary: b3 | |
216 |
|
216 | |||
217 |
|
217 | |||
218 | back to the original dir |
|
218 | back to the original dir | |
219 | $ cd ../rebase |
|
219 | $ cd ../rebase | |
220 |
|
220 | |||
221 | rollback the transplant |
|
221 | rollback the transplant | |
222 | $ hg rollback |
|
222 | $ hg rollback | |
223 | repository tip rolled back to revision 4 (undo transplant) |
|
223 | repository tip rolled back to revision 4 (undo transplant) | |
224 | working directory now based on revision 1 |
|
224 | working directory now based on revision 1 | |
225 | $ hg tip -q |
|
225 | $ hg tip -q | |
226 | 4:a53251cdf717 |
|
226 | 4:a53251cdf717 | |
227 | $ hg parents -q |
|
227 | $ hg parents -q | |
228 | 1:d11e3596cc1a |
|
228 | 1:d11e3596cc1a | |
229 | $ hg status |
|
229 | $ hg status | |
230 | ? b1 |
|
230 | ? b1 | |
231 | ? b2 |
|
231 | ? b2 | |
232 | ? b3 |
|
232 | ? b3 | |
233 |
|
233 | |||
234 | $ hg clone ../t ../prune |
|
234 | $ hg clone ../t ../prune | |
235 | updating to branch default |
|
235 | updating to branch default | |
236 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
236 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
237 | $ cd ../prune |
|
237 | $ cd ../prune | |
238 |
|
238 | |||
239 | $ hg up -C 1 |
|
239 | $ hg up -C 1 | |
240 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
240 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
241 |
|
241 | |||
242 | rebase b onto r1, skipping b2 |
|
242 | rebase b onto r1, skipping b2 | |
243 |
|
243 | |||
244 | $ hg transplant -a -b tip -p 3 |
|
244 | $ hg transplant -a -b tip -p 3 | |
245 | applying 37a1297eb21b |
|
245 | applying 37a1297eb21b | |
246 | 37a1297eb21b transplanted to e234d668f844 |
|
246 | 37a1297eb21b transplanted to e234d668f844 | |
247 | applying a53251cdf717 |
|
247 | applying a53251cdf717 | |
248 | a53251cdf717 transplanted to 7275fda4d04f |
|
248 | a53251cdf717 transplanted to 7275fda4d04f | |
249 | $ hg log --template '{rev} {parents} {desc}\n' |
|
249 | $ hg log --template '{rev} {parents} {desc}\n' | |
250 | 6 b3 |
|
250 | 6 b3 | |
251 | 5 1:d11e3596cc1a b1 |
|
251 | 5 1:d11e3596cc1a b1 | |
252 | 4 b3 |
|
252 | 4 b3 | |
253 | 3 b2 |
|
253 | 3 b2 | |
254 | 2 0:17ab29e464c6 b1 |
|
254 | 2 0:17ab29e464c6 b1 | |
255 | 1 r2 |
|
255 | 1 r2 | |
256 | 0 r1 |
|
256 | 0 r1 | |
257 |
|
257 | |||
258 | test same-parent transplant with --log |
|
258 | test same-parent transplant with --log | |
259 |
|
259 | |||
260 | $ hg clone -r 1 ../t ../sameparent |
|
260 | $ hg clone -r 1 ../t ../sameparent | |
261 | adding changesets |
|
261 | adding changesets | |
262 | adding manifests |
|
262 | adding manifests | |
263 | adding file changes |
|
263 | adding file changes | |
264 | added 2 changesets with 2 changes to 2 files |
|
264 | added 2 changesets with 2 changes to 2 files | |
265 | new changesets 17ab29e464c6:d11e3596cc1a |
|
265 | new changesets 17ab29e464c6:d11e3596cc1a | |
266 | updating to branch default |
|
266 | updating to branch default | |
267 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
267 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
268 | $ cd ../sameparent |
|
268 | $ cd ../sameparent | |
269 | $ hg transplant --log -s ../prune 5 |
|
269 | $ hg transplant --log -s ../prune 5 | |
270 | searching for changes |
|
270 | searching for changes | |
271 | applying e234d668f844 |
|
271 | applying e234d668f844 | |
272 | e234d668f844 transplanted to e07aea8ecf9c |
|
272 | e234d668f844 transplanted to e07aea8ecf9c | |
273 | $ hg log --template '{rev} {parents} {desc}\n' |
|
273 | $ hg log --template '{rev} {parents} {desc}\n' | |
274 | 2 b1 |
|
274 | 2 b1 | |
275 | (transplanted from e234d668f844e1b1a765f01db83a32c0c7bfa170) |
|
275 | (transplanted from e234d668f844e1b1a765f01db83a32c0c7bfa170) | |
276 | 1 r2 |
|
276 | 1 r2 | |
277 | 0 r1 |
|
277 | 0 r1 | |
278 | remote transplant, and also test that transplant doesn't break with |
|
278 | remote transplant, and also test that transplant doesn't break with | |
279 | format-breaking diffopts |
|
279 | format-breaking diffopts | |
280 |
|
280 | |||
281 | $ hg clone -r 1 ../t ../remote |
|
281 | $ hg clone -r 1 ../t ../remote | |
282 | adding changesets |
|
282 | adding changesets | |
283 | adding manifests |
|
283 | adding manifests | |
284 | adding file changes |
|
284 | adding file changes | |
285 | added 2 changesets with 2 changes to 2 files |
|
285 | added 2 changesets with 2 changes to 2 files | |
286 | new changesets 17ab29e464c6:d11e3596cc1a |
|
286 | new changesets 17ab29e464c6:d11e3596cc1a | |
287 | updating to branch default |
|
287 | updating to branch default | |
288 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
288 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
289 | $ cd ../remote |
|
289 | $ cd ../remote | |
290 | $ hg --config diff.noprefix=True transplant --log -s ../t 2 4 |
|
290 | $ hg --config diff.noprefix=True transplant --log -s ../t 2 4 | |
291 | searching for changes |
|
291 | searching for changes | |
292 | applying 37a1297eb21b |
|
292 | applying 37a1297eb21b | |
293 | 37a1297eb21b transplanted to c19cf0ccb069 |
|
293 | 37a1297eb21b transplanted to c19cf0ccb069 | |
294 | applying a53251cdf717 |
|
294 | applying a53251cdf717 | |
295 | a53251cdf717 transplanted to f7fe5bf98525 |
|
295 | a53251cdf717 transplanted to f7fe5bf98525 | |
296 | $ hg log --template '{rev} {parents} {desc}\n' |
|
296 | $ hg log --template '{rev} {parents} {desc}\n' | |
297 | 3 b3 |
|
297 | 3 b3 | |
298 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) |
|
298 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) | |
299 | 2 b1 |
|
299 | 2 b1 | |
300 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) |
|
300 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) | |
301 | 1 r2 |
|
301 | 1 r2 | |
302 | 0 r1 |
|
302 | 0 r1 | |
303 |
|
303 | |||
304 | skip previous transplants |
|
304 | skip previous transplants | |
305 |
|
305 | |||
306 | $ hg transplant -s ../t -a -b 4 |
|
306 | $ hg transplant -s ../t -a -b 4 | |
307 | searching for changes |
|
307 | searching for changes | |
308 | applying 722f4667af76 |
|
308 | applying 722f4667af76 | |
309 | 722f4667af76 transplanted to 47156cd86c0b |
|
309 | 722f4667af76 transplanted to 47156cd86c0b | |
310 | $ hg log --template '{rev} {parents} {desc}\n' |
|
310 | $ hg log --template '{rev} {parents} {desc}\n' | |
311 | 4 b2 |
|
311 | 4 b2 | |
312 | 3 b3 |
|
312 | 3 b3 | |
313 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) |
|
313 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) | |
314 | 2 b1 |
|
314 | 2 b1 | |
315 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) |
|
315 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) | |
316 | 1 r2 |
|
316 | 1 r2 | |
317 | 0 r1 |
|
317 | 0 r1 | |
318 |
|
318 | |||
319 | skip local changes transplanted to the source |
|
319 | skip local changes transplanted to the source | |
320 |
|
320 | |||
321 | $ echo b4 > b4 |
|
321 | $ echo b4 > b4 | |
322 | $ hg ci -Amb4 -d '3 0' |
|
322 | $ hg ci -Amb4 -d '3 0' | |
323 | adding b4 |
|
323 | adding b4 | |
324 | $ hg clone ../t ../pullback |
|
324 | $ hg clone ../t ../pullback | |
325 | updating to branch default |
|
325 | updating to branch default | |
326 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
326 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
327 | $ cd ../pullback |
|
327 | $ cd ../pullback | |
328 | $ hg transplant -s ../remote -a -b tip |
|
328 | $ hg transplant -s ../remote -a -b tip | |
329 | searching for changes |
|
329 | searching for changes | |
330 | applying 4333daefcb15 |
|
330 | applying 4333daefcb15 | |
331 | 4333daefcb15 transplanted to 5f42c04e07cc |
|
331 | 4333daefcb15 transplanted to 5f42c04e07cc | |
332 |
|
332 | |||
333 |
|
333 | |||
334 | remote transplant with pull |
|
334 | remote transplant with pull | |
335 |
|
335 | |||
336 | $ hg serve -R ../t -p $HGPORT -d --pid-file=../t.pid |
|
336 | $ hg serve -R ../t -p $HGPORT -d --pid-file=../t.pid | |
337 | $ cat ../t.pid >> $DAEMON_PIDS |
|
337 | $ cat ../t.pid >> $DAEMON_PIDS | |
338 |
|
338 | |||
339 | $ hg clone -r 0 ../t ../rp |
|
339 | $ hg clone -r 0 ../t ../rp | |
340 | adding changesets |
|
340 | adding changesets | |
341 | adding manifests |
|
341 | adding manifests | |
342 | adding file changes |
|
342 | adding file changes | |
343 | added 1 changesets with 1 changes to 1 files |
|
343 | added 1 changesets with 1 changes to 1 files | |
344 | new changesets 17ab29e464c6 |
|
344 | new changesets 17ab29e464c6 | |
345 | updating to branch default |
|
345 | updating to branch default | |
346 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
346 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
347 | $ cd ../rp |
|
347 | $ cd ../rp | |
348 | $ hg transplant -s http://localhost:$HGPORT/ 37a1297eb21b a53251cdf717 |
|
348 | $ hg transplant -s http://localhost:$HGPORT/ 37a1297eb21b a53251cdf717 | |
349 | searching for changes |
|
349 | searching for changes | |
350 | searching for changes |
|
350 | searching for changes | |
351 | adding changesets |
|
351 | adding changesets | |
352 | adding manifests |
|
352 | adding manifests | |
353 | adding file changes |
|
353 | adding file changes | |
354 | added 1 changesets with 1 changes to 1 files |
|
354 | added 1 changesets with 1 changes to 1 files | |
355 | applying a53251cdf717 |
|
355 | applying a53251cdf717 | |
356 | a53251cdf717 transplanted to 8d9279348abb |
|
356 | a53251cdf717 transplanted to 8d9279348abb | |
357 | new changesets 37a1297eb21b:8d9279348abb |
|
|||
358 | $ hg log --template '{rev} {parents} {desc}\n' |
|
357 | $ hg log --template '{rev} {parents} {desc}\n' | |
359 | 2 b3 |
|
358 | 2 b3 | |
360 | 1 b1 |
|
359 | 1 b1 | |
361 | 0 r1 |
|
360 | 0 r1 | |
362 |
|
361 | |||
363 | remote transplant without pull |
|
362 | remote transplant without pull | |
364 | (It was using "2" and "4" (as the previous transplant used to) which referenced |
|
363 | (It was using "2" and "4" (as the previous transplant used to) which referenced | |
365 | revision different from one run to another) |
|
364 | revision different from one run to another) | |
366 |
|
365 | |||
367 | $ hg pull -q http://localhost:$HGPORT/ |
|
366 | $ hg pull -q http://localhost:$HGPORT/ | |
368 | $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76 |
|
367 | $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76 | |
369 | skipping already applied revision 2:8d9279348abb |
|
368 | skipping already applied revision 2:8d9279348abb | |
370 | applying 722f4667af76 |
|
369 | applying 722f4667af76 | |
371 | 722f4667af76 transplanted to 76e321915884 |
|
370 | 722f4667af76 transplanted to 76e321915884 | |
372 |
|
371 | |||
373 | transplant --continue |
|
372 | transplant --continue | |
374 |
|
373 | |||
375 | $ hg init ../tc |
|
374 | $ hg init ../tc | |
376 | $ cd ../tc |
|
375 | $ cd ../tc | |
377 | $ cat <<EOF > foo |
|
376 | $ cat <<EOF > foo | |
378 | > foo |
|
377 | > foo | |
379 | > bar |
|
378 | > bar | |
380 | > baz |
|
379 | > baz | |
381 | > EOF |
|
380 | > EOF | |
382 | $ echo toremove > toremove |
|
381 | $ echo toremove > toremove | |
383 | $ echo baz > baz |
|
382 | $ echo baz > baz | |
384 | $ hg ci -Amfoo |
|
383 | $ hg ci -Amfoo | |
385 | adding baz |
|
384 | adding baz | |
386 | adding foo |
|
385 | adding foo | |
387 | adding toremove |
|
386 | adding toremove | |
388 | $ cat <<EOF > foo |
|
387 | $ cat <<EOF > foo | |
389 | > foo2 |
|
388 | > foo2 | |
390 | > bar2 |
|
389 | > bar2 | |
391 | > baz2 |
|
390 | > baz2 | |
392 | > EOF |
|
391 | > EOF | |
393 | $ rm toremove |
|
392 | $ rm toremove | |
394 | $ echo added > added |
|
393 | $ echo added > added | |
395 | $ hg ci -Amfoo2 |
|
394 | $ hg ci -Amfoo2 | |
396 | adding added |
|
395 | adding added | |
397 | removing toremove |
|
396 | removing toremove | |
398 | $ echo bar > bar |
|
397 | $ echo bar > bar | |
399 | $ cat > baz <<EOF |
|
398 | $ cat > baz <<EOF | |
400 | > before baz |
|
399 | > before baz | |
401 | > baz |
|
400 | > baz | |
402 | > after baz |
|
401 | > after baz | |
403 | > EOF |
|
402 | > EOF | |
404 | $ hg ci -Ambar |
|
403 | $ hg ci -Ambar | |
405 | adding bar |
|
404 | adding bar | |
406 | $ echo bar2 >> bar |
|
405 | $ echo bar2 >> bar | |
407 | $ hg ci -mbar2 |
|
406 | $ hg ci -mbar2 | |
408 | $ hg up 0 |
|
407 | $ hg up 0 | |
409 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
408 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
410 | $ echo foobar > foo |
|
409 | $ echo foobar > foo | |
411 | $ hg ci -mfoobar |
|
410 | $ hg ci -mfoobar | |
412 | created new head |
|
411 | created new head | |
413 | $ hg transplant 1:3 |
|
412 | $ hg transplant 1:3 | |
414 | applying 46ae92138f3c |
|
413 | applying 46ae92138f3c | |
415 | patching file foo |
|
414 | patching file foo | |
416 | Hunk #1 FAILED at 0 |
|
415 | Hunk #1 FAILED at 0 | |
417 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej |
|
416 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej | |
418 | patch failed to apply |
|
417 | patch failed to apply | |
419 | abort: fix up the working directory and run hg transplant --continue |
|
418 | abort: fix up the working directory and run hg transplant --continue | |
420 | [255] |
|
419 | [255] | |
421 |
|
420 | |||
422 | transplant -c shouldn't use an old changeset |
|
421 | transplant -c shouldn't use an old changeset | |
423 |
|
422 | |||
424 | $ hg up -C |
|
423 | $ hg up -C | |
425 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
424 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
426 | updated to "e8643552fde5: foobar" |
|
425 | updated to "e8643552fde5: foobar" | |
427 | 1 other heads for branch "default" |
|
426 | 1 other heads for branch "default" | |
428 | $ rm added |
|
427 | $ rm added | |
429 | $ hg transplant --continue |
|
428 | $ hg transplant --continue | |
430 | abort: no transplant to continue |
|
429 | abort: no transplant to continue | |
431 | [255] |
|
430 | [255] | |
432 | $ hg transplant 1 |
|
431 | $ hg transplant 1 | |
433 | applying 46ae92138f3c |
|
432 | applying 46ae92138f3c | |
434 | patching file foo |
|
433 | patching file foo | |
435 | Hunk #1 FAILED at 0 |
|
434 | Hunk #1 FAILED at 0 | |
436 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej |
|
435 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej | |
437 | patch failed to apply |
|
436 | patch failed to apply | |
438 | abort: fix up the working directory and run hg transplant --continue |
|
437 | abort: fix up the working directory and run hg transplant --continue | |
439 | [255] |
|
438 | [255] | |
440 | $ cp .hg/transplant/journal .hg/transplant/journal.orig |
|
439 | $ cp .hg/transplant/journal .hg/transplant/journal.orig | |
441 | $ cat .hg/transplant/journal |
|
440 | $ cat .hg/transplant/journal | |
442 | # User test |
|
441 | # User test | |
443 | # Date 0 0 |
|
442 | # Date 0 0 | |
444 | # Node ID 46ae92138f3ce0249f6789650403286ead052b6d |
|
443 | # Node ID 46ae92138f3ce0249f6789650403286ead052b6d | |
445 | # Parent e8643552fde58f57515e19c4b373a57c96e62af3 |
|
444 | # Parent e8643552fde58f57515e19c4b373a57c96e62af3 | |
446 | foo2 |
|
445 | foo2 | |
447 | $ grep -v 'Date' .hg/transplant/journal.orig > .hg/transplant/journal |
|
446 | $ grep -v 'Date' .hg/transplant/journal.orig > .hg/transplant/journal | |
448 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
447 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
449 | abort: filter corrupted changeset (no user or date) |
|
448 | abort: filter corrupted changeset (no user or date) | |
450 | [255] |
|
449 | [255] | |
451 | $ cp .hg/transplant/journal.orig .hg/transplant/journal |
|
450 | $ cp .hg/transplant/journal.orig .hg/transplant/journal | |
452 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
451 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
453 | HGEDITFORM=transplant.normal |
|
452 | HGEDITFORM=transplant.normal | |
454 | 46ae92138f3c transplanted as 9159dada197d |
|
453 | 46ae92138f3c transplanted as 9159dada197d | |
455 | $ hg transplant 1:3 |
|
454 | $ hg transplant 1:3 | |
456 | skipping already applied revision 1:46ae92138f3c |
|
455 | skipping already applied revision 1:46ae92138f3c | |
457 | applying 9d6d6b5a8275 |
|
456 | applying 9d6d6b5a8275 | |
458 | 9d6d6b5a8275 transplanted to 2d17a10c922f |
|
457 | 9d6d6b5a8275 transplanted to 2d17a10c922f | |
459 | applying 1dab759070cf |
|
458 | applying 1dab759070cf | |
460 | 1dab759070cf transplanted to e06a69927eb0 |
|
459 | 1dab759070cf transplanted to e06a69927eb0 | |
461 | $ hg locate |
|
460 | $ hg locate | |
462 | added |
|
461 | added | |
463 | bar |
|
462 | bar | |
464 | baz |
|
463 | baz | |
465 | foo |
|
464 | foo | |
466 |
|
465 | |||
467 | test multiple revisions and --continue |
|
466 | test multiple revisions and --continue | |
468 |
|
467 | |||
469 | $ hg up -qC 0 |
|
468 | $ hg up -qC 0 | |
470 | $ echo bazbaz > baz |
|
469 | $ echo bazbaz > baz | |
471 | $ hg ci -Am anotherbaz baz |
|
470 | $ hg ci -Am anotherbaz baz | |
472 | created new head |
|
471 | created new head | |
473 | $ hg transplant 1:3 |
|
472 | $ hg transplant 1:3 | |
474 | applying 46ae92138f3c |
|
473 | applying 46ae92138f3c | |
475 | 46ae92138f3c transplanted to 1024233ea0ba |
|
474 | 46ae92138f3c transplanted to 1024233ea0ba | |
476 | applying 9d6d6b5a8275 |
|
475 | applying 9d6d6b5a8275 | |
477 | patching file baz |
|
476 | patching file baz | |
478 | Hunk #1 FAILED at 0 |
|
477 | Hunk #1 FAILED at 0 | |
479 | 1 out of 1 hunks FAILED -- saving rejects to file baz.rej |
|
478 | 1 out of 1 hunks FAILED -- saving rejects to file baz.rej | |
480 | patch failed to apply |
|
479 | patch failed to apply | |
481 | abort: fix up the working directory and run hg transplant --continue |
|
480 | abort: fix up the working directory and run hg transplant --continue | |
482 | [255] |
|
481 | [255] | |
483 | $ hg transplant 1:3 |
|
482 | $ hg transplant 1:3 | |
484 | abort: transplant in progress |
|
483 | abort: transplant in progress | |
485 | (use 'hg transplant --continue' or 'hg update' to abort) |
|
484 | (use 'hg transplant --continue' or 'hg update' to abort) | |
486 | [255] |
|
485 | [255] | |
487 | $ echo fixed > baz |
|
486 | $ echo fixed > baz | |
488 | $ hg transplant --continue |
|
487 | $ hg transplant --continue | |
489 | 9d6d6b5a8275 transplanted as d80c49962290 |
|
488 | 9d6d6b5a8275 transplanted as d80c49962290 | |
490 | applying 1dab759070cf |
|
489 | applying 1dab759070cf | |
491 | 1dab759070cf transplanted to aa0ffe6bd5ae |
|
490 | 1dab759070cf transplanted to aa0ffe6bd5ae | |
492 |
|
491 | |||
493 | $ cd .. |
|
492 | $ cd .. | |
494 |
|
493 | |||
495 | Issue1111: Test transplant --merge |
|
494 | Issue1111: Test transplant --merge | |
496 |
|
495 | |||
497 | $ hg init t1111 |
|
496 | $ hg init t1111 | |
498 | $ cd t1111 |
|
497 | $ cd t1111 | |
499 | $ echo a > a |
|
498 | $ echo a > a | |
500 | $ hg ci -Am adda |
|
499 | $ hg ci -Am adda | |
501 | adding a |
|
500 | adding a | |
502 | $ echo b >> a |
|
501 | $ echo b >> a | |
503 | $ hg ci -m appendb |
|
502 | $ hg ci -m appendb | |
504 | $ echo c >> a |
|
503 | $ echo c >> a | |
505 | $ hg ci -m appendc |
|
504 | $ hg ci -m appendc | |
506 | $ hg up -C 0 |
|
505 | $ hg up -C 0 | |
507 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
506 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
508 | $ echo d >> a |
|
507 | $ echo d >> a | |
509 | $ hg ci -m appendd |
|
508 | $ hg ci -m appendd | |
510 | created new head |
|
509 | created new head | |
511 |
|
510 | |||
512 | transplant |
|
511 | transplant | |
513 |
|
512 | |||
514 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant -m 1 -e |
|
513 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant -m 1 -e | |
515 | applying 42dc4432fd35 |
|
514 | applying 42dc4432fd35 | |
516 | HGEDITFORM=transplant.merge |
|
515 | HGEDITFORM=transplant.merge | |
517 | 1:42dc4432fd35 merged at a9f4acbac129 |
|
516 | 1:42dc4432fd35 merged at a9f4acbac129 | |
518 | $ hg update -q -C 2 |
|
517 | $ hg update -q -C 2 | |
519 | $ cat > a <<EOF |
|
518 | $ cat > a <<EOF | |
520 | > x |
|
519 | > x | |
521 | > y |
|
520 | > y | |
522 | > z |
|
521 | > z | |
523 | > EOF |
|
522 | > EOF | |
524 | $ hg commit -m replace |
|
523 | $ hg commit -m replace | |
525 | $ hg update -q -C 4 |
|
524 | $ hg update -q -C 4 | |
526 | $ hg transplant -m 5 |
|
525 | $ hg transplant -m 5 | |
527 | applying 600a3cdcb41d |
|
526 | applying 600a3cdcb41d | |
528 | patching file a |
|
527 | patching file a | |
529 | Hunk #1 FAILED at 0 |
|
528 | Hunk #1 FAILED at 0 | |
530 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
529 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
531 | patch failed to apply |
|
530 | patch failed to apply | |
532 | abort: fix up the working directory and run hg transplant --continue |
|
531 | abort: fix up the working directory and run hg transplant --continue | |
533 | [255] |
|
532 | [255] | |
534 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
533 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
535 | HGEDITFORM=transplant.merge |
|
534 | HGEDITFORM=transplant.merge | |
536 | 600a3cdcb41d transplanted as a3f88be652e0 |
|
535 | 600a3cdcb41d transplanted as a3f88be652e0 | |
537 |
|
536 | |||
538 | $ cd .. |
|
537 | $ cd .. | |
539 |
|
538 | |||
540 | test transplant into empty repository |
|
539 | test transplant into empty repository | |
541 |
|
540 | |||
542 | $ hg init empty |
|
541 | $ hg init empty | |
543 | $ cd empty |
|
542 | $ cd empty | |
544 | $ hg transplant -s ../t -b tip -a |
|
543 | $ hg transplant -s ../t -b tip -a | |
545 | adding changesets |
|
544 | adding changesets | |
546 | adding manifests |
|
545 | adding manifests | |
547 | adding file changes |
|
546 | adding file changes | |
548 | added 4 changesets with 4 changes to 4 files |
|
547 | added 4 changesets with 4 changes to 4 files | |
549 | new changesets 17ab29e464c6:a53251cdf717 |
|
548 | new changesets 17ab29e464c6:a53251cdf717 | |
550 |
|
549 | |||
551 | test "--merge" causing pull from source repository on local host |
|
550 | test "--merge" causing pull from source repository on local host | |
552 |
|
551 | |||
553 | $ hg --config extensions.mq= -q strip 2 |
|
552 | $ hg --config extensions.mq= -q strip 2 | |
554 | $ hg transplant -s ../t --merge tip |
|
553 | $ hg transplant -s ../t --merge tip | |
555 | searching for changes |
|
554 | searching for changes | |
556 | searching for changes |
|
555 | searching for changes | |
557 | adding changesets |
|
556 | adding changesets | |
558 | adding manifests |
|
557 | adding manifests | |
559 | adding file changes |
|
558 | adding file changes | |
560 | added 2 changesets with 2 changes to 2 files |
|
559 | added 2 changesets with 2 changes to 2 files | |
561 | applying a53251cdf717 |
|
560 | applying a53251cdf717 | |
562 | 4:a53251cdf717 merged at 4831f4dc831a |
|
561 | 4:a53251cdf717 merged at 4831f4dc831a | |
563 | new changesets 722f4667af76:4831f4dc831a |
|
|||
564 |
|
562 | |||
565 | test interactive transplant |
|
563 | test interactive transplant | |
566 |
|
564 | |||
567 | $ hg --config extensions.strip= -q strip 0 |
|
565 | $ hg --config extensions.strip= -q strip 0 | |
568 | $ hg -R ../t log -G --template "{rev}:{node|short}" |
|
566 | $ hg -R ../t log -G --template "{rev}:{node|short}" | |
569 | @ 4:a53251cdf717 |
|
567 | @ 4:a53251cdf717 | |
570 | | |
|
568 | | | |
571 | o 3:722f4667af76 |
|
569 | o 3:722f4667af76 | |
572 | | |
|
570 | | | |
573 | o 2:37a1297eb21b |
|
571 | o 2:37a1297eb21b | |
574 | | |
|
572 | | | |
575 | | o 1:d11e3596cc1a |
|
573 | | o 1:d11e3596cc1a | |
576 | |/ |
|
574 | |/ | |
577 | o 0:17ab29e464c6 |
|
575 | o 0:17ab29e464c6 | |
578 |
|
576 | |||
579 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
577 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
580 | > ? |
|
578 | > ? | |
581 | > x |
|
579 | > x | |
582 | > q |
|
580 | > q | |
583 | > EOF |
|
581 | > EOF | |
584 | 0:17ab29e464c6 |
|
582 | 0:17ab29e464c6 | |
585 | apply changeset? [ynmpcq?]: ? |
|
583 | apply changeset? [ynmpcq?]: ? | |
586 | y: yes, transplant this changeset |
|
584 | y: yes, transplant this changeset | |
587 | n: no, skip this changeset |
|
585 | n: no, skip this changeset | |
588 | m: merge at this changeset |
|
586 | m: merge at this changeset | |
589 | p: show patch |
|
587 | p: show patch | |
590 | c: commit selected changesets |
|
588 | c: commit selected changesets | |
591 | q: quit and cancel transplant |
|
589 | q: quit and cancel transplant | |
592 | ?: ? (show this help) |
|
590 | ?: ? (show this help) | |
593 | apply changeset? [ynmpcq?]: x |
|
591 | apply changeset? [ynmpcq?]: x | |
594 | unrecognized response |
|
592 | unrecognized response | |
595 | apply changeset? [ynmpcq?]: q |
|
593 | apply changeset? [ynmpcq?]: q | |
596 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
594 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
597 | > p |
|
595 | > p | |
598 | > y |
|
596 | > y | |
599 | > n |
|
597 | > n | |
600 | > n |
|
598 | > n | |
601 | > m |
|
599 | > m | |
602 | > c |
|
600 | > c | |
603 | > EOF |
|
601 | > EOF | |
604 | 0:17ab29e464c6 |
|
602 | 0:17ab29e464c6 | |
605 | apply changeset? [ynmpcq?]: p |
|
603 | apply changeset? [ynmpcq?]: p | |
606 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
604 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
607 | +++ b/r1 Thu Jan 01 00:00:00 1970 +0000 |
|
605 | +++ b/r1 Thu Jan 01 00:00:00 1970 +0000 | |
608 | @@ -0,0 +1,1 @@ |
|
606 | @@ -0,0 +1,1 @@ | |
609 | +r1 |
|
607 | +r1 | |
610 | apply changeset? [ynmpcq?]: y |
|
608 | apply changeset? [ynmpcq?]: y | |
611 | 1:d11e3596cc1a |
|
609 | 1:d11e3596cc1a | |
612 | apply changeset? [ynmpcq?]: n |
|
610 | apply changeset? [ynmpcq?]: n | |
613 | 2:37a1297eb21b |
|
611 | 2:37a1297eb21b | |
614 | apply changeset? [ynmpcq?]: n |
|
612 | apply changeset? [ynmpcq?]: n | |
615 | 3:722f4667af76 |
|
613 | 3:722f4667af76 | |
616 | apply changeset? [ynmpcq?]: m |
|
614 | apply changeset? [ynmpcq?]: m | |
617 | 4:a53251cdf717 |
|
615 | 4:a53251cdf717 | |
618 | apply changeset? [ynmpcq?]: c |
|
616 | apply changeset? [ynmpcq?]: c | |
619 | $ hg log -G --template "{node|short}" |
|
617 | $ hg log -G --template "{node|short}" | |
620 | @ 88be5dde5260 |
|
618 | @ 88be5dde5260 | |
621 | |\ |
|
619 | |\ | |
622 | | o 722f4667af76 |
|
620 | | o 722f4667af76 | |
623 | | | |
|
621 | | | | |
624 | | o 37a1297eb21b |
|
622 | | o 37a1297eb21b | |
625 | |/ |
|
623 | |/ | |
626 | o 17ab29e464c6 |
|
624 | o 17ab29e464c6 | |
627 |
|
625 | |||
628 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
626 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
629 | > x |
|
627 | > x | |
630 | > ? |
|
628 | > ? | |
631 | > y |
|
629 | > y | |
632 | > q |
|
630 | > q | |
633 | > EOF |
|
631 | > EOF | |
634 | 1:d11e3596cc1a |
|
632 | 1:d11e3596cc1a | |
635 | apply changeset? [ynmpcq?]: x |
|
633 | apply changeset? [ynmpcq?]: x | |
636 | unrecognized response |
|
634 | unrecognized response | |
637 | apply changeset? [ynmpcq?]: ? |
|
635 | apply changeset? [ynmpcq?]: ? | |
638 | y: yes, transplant this changeset |
|
636 | y: yes, transplant this changeset | |
639 | n: no, skip this changeset |
|
637 | n: no, skip this changeset | |
640 | m: merge at this changeset |
|
638 | m: merge at this changeset | |
641 | p: show patch |
|
639 | p: show patch | |
642 | c: commit selected changesets |
|
640 | c: commit selected changesets | |
643 | q: quit and cancel transplant |
|
641 | q: quit and cancel transplant | |
644 | ?: ? (show this help) |
|
642 | ?: ? (show this help) | |
645 | apply changeset? [ynmpcq?]: y |
|
643 | apply changeset? [ynmpcq?]: y | |
646 | 4:a53251cdf717 |
|
644 | 4:a53251cdf717 | |
647 | apply changeset? [ynmpcq?]: q |
|
645 | apply changeset? [ynmpcq?]: q | |
648 | $ hg heads --template "{node|short}\n" |
|
646 | $ hg heads --template "{node|short}\n" | |
649 | 88be5dde5260 |
|
647 | 88be5dde5260 | |
650 |
|
648 | |||
651 | $ cd .. |
|
649 | $ cd .. | |
652 |
|
650 | |||
653 |
|
651 | |||
654 | #if unix-permissions system-sh |
|
652 | #if unix-permissions system-sh | |
655 |
|
653 | |||
656 | test filter |
|
654 | test filter | |
657 |
|
655 | |||
658 | $ hg init filter |
|
656 | $ hg init filter | |
659 | $ cd filter |
|
657 | $ cd filter | |
660 | $ cat <<'EOF' >test-filter |
|
658 | $ cat <<'EOF' >test-filter | |
661 | > #!/bin/sh |
|
659 | > #!/bin/sh | |
662 | > sed 's/r1/r2/' $1 > $1.new |
|
660 | > sed 's/r1/r2/' $1 > $1.new | |
663 | > mv $1.new $1 |
|
661 | > mv $1.new $1 | |
664 | > EOF |
|
662 | > EOF | |
665 | $ chmod +x test-filter |
|
663 | $ chmod +x test-filter | |
666 | $ hg transplant -s ../t -b tip -a --filter ./test-filter |
|
664 | $ hg transplant -s ../t -b tip -a --filter ./test-filter | |
667 | filtering * (glob) |
|
665 | filtering * (glob) | |
668 | applying 17ab29e464c6 |
|
666 | applying 17ab29e464c6 | |
669 | 17ab29e464c6 transplanted to e9ffc54ea104 |
|
667 | 17ab29e464c6 transplanted to e9ffc54ea104 | |
670 | filtering * (glob) |
|
668 | filtering * (glob) | |
671 | applying 37a1297eb21b |
|
669 | applying 37a1297eb21b | |
672 | 37a1297eb21b transplanted to 348b36d0b6a5 |
|
670 | 37a1297eb21b transplanted to 348b36d0b6a5 | |
673 | filtering * (glob) |
|
671 | filtering * (glob) | |
674 | applying 722f4667af76 |
|
672 | applying 722f4667af76 | |
675 | 722f4667af76 transplanted to 0aa6979afb95 |
|
673 | 722f4667af76 transplanted to 0aa6979afb95 | |
676 | filtering * (glob) |
|
674 | filtering * (glob) | |
677 | applying a53251cdf717 |
|
675 | applying a53251cdf717 | |
678 | a53251cdf717 transplanted to 14f8512272b5 |
|
676 | a53251cdf717 transplanted to 14f8512272b5 | |
679 | $ hg log --template '{rev} {parents} {desc}\n' |
|
677 | $ hg log --template '{rev} {parents} {desc}\n' | |
680 | 3 b3 |
|
678 | 3 b3 | |
681 | 2 b2 |
|
679 | 2 b2 | |
682 | 1 b1 |
|
680 | 1 b1 | |
683 | 0 r2 |
|
681 | 0 r2 | |
684 | $ cd .. |
|
682 | $ cd .. | |
685 |
|
683 | |||
686 |
|
684 | |||
687 | test filter with failed patch |
|
685 | test filter with failed patch | |
688 |
|
686 | |||
689 | $ cd filter |
|
687 | $ cd filter | |
690 | $ hg up 0 |
|
688 | $ hg up 0 | |
691 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
689 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
692 | $ echo foo > b1 |
|
690 | $ echo foo > b1 | |
693 | $ hg ci -Am foo |
|
691 | $ hg ci -Am foo | |
694 | adding b1 |
|
692 | adding b1 | |
695 | adding test-filter |
|
693 | adding test-filter | |
696 | created new head |
|
694 | created new head | |
697 | $ hg transplant 1 --filter ./test-filter |
|
695 | $ hg transplant 1 --filter ./test-filter | |
698 | filtering * (glob) |
|
696 | filtering * (glob) | |
699 | applying 348b36d0b6a5 |
|
697 | applying 348b36d0b6a5 | |
700 | file b1 already exists |
|
698 | file b1 already exists | |
701 | 1 out of 1 hunks FAILED -- saving rejects to file b1.rej |
|
699 | 1 out of 1 hunks FAILED -- saving rejects to file b1.rej | |
702 | patch failed to apply |
|
700 | patch failed to apply | |
703 | abort: fix up the working directory and run hg transplant --continue |
|
701 | abort: fix up the working directory and run hg transplant --continue | |
704 | [255] |
|
702 | [255] | |
705 | $ cd .. |
|
703 | $ cd .. | |
706 |
|
704 | |||
707 | test environment passed to filter |
|
705 | test environment passed to filter | |
708 |
|
706 | |||
709 | $ hg init filter-environment |
|
707 | $ hg init filter-environment | |
710 | $ cd filter-environment |
|
708 | $ cd filter-environment | |
711 | $ cat <<'EOF' >test-filter-environment |
|
709 | $ cat <<'EOF' >test-filter-environment | |
712 | > #!/bin/sh |
|
710 | > #!/bin/sh | |
713 | > echo "Transplant by $HGUSER" >> $1 |
|
711 | > echo "Transplant by $HGUSER" >> $1 | |
714 | > echo "Transplant from rev $HGREVISION" >> $1 |
|
712 | > echo "Transplant from rev $HGREVISION" >> $1 | |
715 | > EOF |
|
713 | > EOF | |
716 | $ chmod +x test-filter-environment |
|
714 | $ chmod +x test-filter-environment | |
717 | $ hg transplant -s ../t --filter ./test-filter-environment 0 |
|
715 | $ hg transplant -s ../t --filter ./test-filter-environment 0 | |
718 | filtering * (glob) |
|
716 | filtering * (glob) | |
719 | applying 17ab29e464c6 |
|
717 | applying 17ab29e464c6 | |
720 | 17ab29e464c6 transplanted to 5190e68026a0 |
|
718 | 17ab29e464c6 transplanted to 5190e68026a0 | |
721 |
|
719 | |||
722 | $ hg log --template '{rev} {parents} {desc}\n' |
|
720 | $ hg log --template '{rev} {parents} {desc}\n' | |
723 | 0 r1 |
|
721 | 0 r1 | |
724 | Transplant by test |
|
722 | Transplant by test | |
725 | Transplant from rev 17ab29e464c6ca53e329470efe2a9918ac617a6f |
|
723 | Transplant from rev 17ab29e464c6ca53e329470efe2a9918ac617a6f | |
726 | $ cd .. |
|
724 | $ cd .. | |
727 |
|
725 | |||
728 | test transplant with filter handles invalid changelog |
|
726 | test transplant with filter handles invalid changelog | |
729 |
|
727 | |||
730 | $ hg init filter-invalid-log |
|
728 | $ hg init filter-invalid-log | |
731 | $ cd filter-invalid-log |
|
729 | $ cd filter-invalid-log | |
732 | $ cat <<'EOF' >test-filter-invalid-log |
|
730 | $ cat <<'EOF' >test-filter-invalid-log | |
733 | > #!/bin/sh |
|
731 | > #!/bin/sh | |
734 | > echo "" > $1 |
|
732 | > echo "" > $1 | |
735 | > EOF |
|
733 | > EOF | |
736 | $ chmod +x test-filter-invalid-log |
|
734 | $ chmod +x test-filter-invalid-log | |
737 | $ hg transplant -s ../t --filter ./test-filter-invalid-log 0 |
|
735 | $ hg transplant -s ../t --filter ./test-filter-invalid-log 0 | |
738 | filtering * (glob) |
|
736 | filtering * (glob) | |
739 | abort: filter corrupted changeset (no user or date) |
|
737 | abort: filter corrupted changeset (no user or date) | |
740 | [255] |
|
738 | [255] | |
741 | $ cd .. |
|
739 | $ cd .. | |
742 |
|
740 | |||
743 | #endif |
|
741 | #endif | |
744 |
|
742 | |||
745 |
|
743 | |||
746 | test with a win32ext like setup (differing EOLs) |
|
744 | test with a win32ext like setup (differing EOLs) | |
747 |
|
745 | |||
748 | $ hg init twin1 |
|
746 | $ hg init twin1 | |
749 | $ cd twin1 |
|
747 | $ cd twin1 | |
750 | $ echo a > a |
|
748 | $ echo a > a | |
751 | $ echo b > b |
|
749 | $ echo b > b | |
752 | $ echo b >> b |
|
750 | $ echo b >> b | |
753 | $ hg ci -Am t |
|
751 | $ hg ci -Am t | |
754 | adding a |
|
752 | adding a | |
755 | adding b |
|
753 | adding b | |
756 | $ echo a > b |
|
754 | $ echo a > b | |
757 | $ echo b >> b |
|
755 | $ echo b >> b | |
758 | $ hg ci -m changeb |
|
756 | $ hg ci -m changeb | |
759 | $ cd .. |
|
757 | $ cd .. | |
760 |
|
758 | |||
761 | $ hg init twin2 |
|
759 | $ hg init twin2 | |
762 | $ cd twin2 |
|
760 | $ cd twin2 | |
763 | $ echo '[patch]' >> .hg/hgrc |
|
761 | $ echo '[patch]' >> .hg/hgrc | |
764 | $ echo 'eol = crlf' >> .hg/hgrc |
|
762 | $ echo 'eol = crlf' >> .hg/hgrc | |
765 | $ $PYTHON -c "file('b', 'wb').write('b\r\nb\r\n')" |
|
763 | $ $PYTHON -c "file('b', 'wb').write('b\r\nb\r\n')" | |
766 | $ hg ci -Am addb |
|
764 | $ hg ci -Am addb | |
767 | adding b |
|
765 | adding b | |
768 | $ hg transplant -s ../twin1 tip |
|
766 | $ hg transplant -s ../twin1 tip | |
769 | searching for changes |
|
767 | searching for changes | |
770 | warning: repository is unrelated |
|
768 | warning: repository is unrelated | |
771 | applying 2e849d776c17 |
|
769 | applying 2e849d776c17 | |
772 | 2e849d776c17 transplanted to 8e65bebc063e |
|
770 | 2e849d776c17 transplanted to 8e65bebc063e | |
773 | $ cat b |
|
771 | $ cat b | |
774 | a\r (esc) |
|
772 | a\r (esc) | |
775 | b\r (esc) |
|
773 | b\r (esc) | |
776 | $ cd .. |
|
774 | $ cd .. | |
777 |
|
775 | |||
778 | test transplant with merge changeset is skipped |
|
776 | test transplant with merge changeset is skipped | |
779 |
|
777 | |||
780 | $ hg init merge1a |
|
778 | $ hg init merge1a | |
781 | $ cd merge1a |
|
779 | $ cd merge1a | |
782 | $ echo a > a |
|
780 | $ echo a > a | |
783 | $ hg ci -Am a |
|
781 | $ hg ci -Am a | |
784 | adding a |
|
782 | adding a | |
785 | $ hg branch b |
|
783 | $ hg branch b | |
786 | marked working directory as branch b |
|
784 | marked working directory as branch b | |
787 | (branches are permanent and global, did you want a bookmark?) |
|
785 | (branches are permanent and global, did you want a bookmark?) | |
788 | $ hg ci -m branchb |
|
786 | $ hg ci -m branchb | |
789 | $ echo b > b |
|
787 | $ echo b > b | |
790 | $ hg ci -Am b |
|
788 | $ hg ci -Am b | |
791 | adding b |
|
789 | adding b | |
792 | $ hg update default |
|
790 | $ hg update default | |
793 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
791 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
794 | $ hg merge b |
|
792 | $ hg merge b | |
795 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
793 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
796 | (branch merge, don't forget to commit) |
|
794 | (branch merge, don't forget to commit) | |
797 | $ hg ci -m mergeb |
|
795 | $ hg ci -m mergeb | |
798 | $ cd .. |
|
796 | $ cd .. | |
799 |
|
797 | |||
800 | $ hg init merge1b |
|
798 | $ hg init merge1b | |
801 | $ cd merge1b |
|
799 | $ cd merge1b | |
802 | $ hg transplant -s ../merge1a tip |
|
800 | $ hg transplant -s ../merge1a tip | |
803 | $ cd .. |
|
801 | $ cd .. | |
804 |
|
802 | |||
805 | test transplant with merge changeset accepts --parent |
|
803 | test transplant with merge changeset accepts --parent | |
806 |
|
804 | |||
807 | $ hg init merge2a |
|
805 | $ hg init merge2a | |
808 | $ cd merge2a |
|
806 | $ cd merge2a | |
809 | $ echo a > a |
|
807 | $ echo a > a | |
810 | $ hg ci -Am a |
|
808 | $ hg ci -Am a | |
811 | adding a |
|
809 | adding a | |
812 | $ hg branch b |
|
810 | $ hg branch b | |
813 | marked working directory as branch b |
|
811 | marked working directory as branch b | |
814 | (branches are permanent and global, did you want a bookmark?) |
|
812 | (branches are permanent and global, did you want a bookmark?) | |
815 | $ hg ci -m branchb |
|
813 | $ hg ci -m branchb | |
816 | $ echo b > b |
|
814 | $ echo b > b | |
817 | $ hg ci -Am b |
|
815 | $ hg ci -Am b | |
818 | adding b |
|
816 | adding b | |
819 | $ hg update default |
|
817 | $ hg update default | |
820 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
818 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
821 | $ hg merge b |
|
819 | $ hg merge b | |
822 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
820 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
823 | (branch merge, don't forget to commit) |
|
821 | (branch merge, don't forget to commit) | |
824 | $ hg ci -m mergeb |
|
822 | $ hg ci -m mergeb | |
825 | $ cd .. |
|
823 | $ cd .. | |
826 |
|
824 | |||
827 | $ hg init merge2b |
|
825 | $ hg init merge2b | |
828 | $ cd merge2b |
|
826 | $ cd merge2b | |
829 | $ hg transplant -s ../merge2a --parent tip tip |
|
827 | $ hg transplant -s ../merge2a --parent tip tip | |
830 | abort: be9f9b39483f is not a parent of be9f9b39483f |
|
828 | abort: be9f9b39483f is not a parent of be9f9b39483f | |
831 | [255] |
|
829 | [255] | |
832 | $ hg transplant -s ../merge2a --parent 0 tip |
|
830 | $ hg transplant -s ../merge2a --parent 0 tip | |
833 | applying be9f9b39483f |
|
831 | applying be9f9b39483f | |
834 | be9f9b39483f transplanted to 9959e51f94d1 |
|
832 | be9f9b39483f transplanted to 9959e51f94d1 | |
835 | $ cd .. |
|
833 | $ cd .. | |
836 |
|
834 | |||
837 | test transplanting a patch turning into a no-op |
|
835 | test transplanting a patch turning into a no-op | |
838 |
|
836 | |||
839 | $ hg init binarysource |
|
837 | $ hg init binarysource | |
840 | $ cd binarysource |
|
838 | $ cd binarysource | |
841 | $ echo a > a |
|
839 | $ echo a > a | |
842 | $ hg ci -Am adda a |
|
840 | $ hg ci -Am adda a | |
843 | >>> file('b', 'wb').write('\0b1') |
|
841 | >>> file('b', 'wb').write('\0b1') | |
844 | $ hg ci -Am addb b |
|
842 | $ hg ci -Am addb b | |
845 | >>> file('b', 'wb').write('\0b2') |
|
843 | >>> file('b', 'wb').write('\0b2') | |
846 | $ hg ci -m changeb b |
|
844 | $ hg ci -m changeb b | |
847 | $ cd .. |
|
845 | $ cd .. | |
848 |
|
846 | |||
849 | $ hg clone -r0 binarysource binarydest |
|
847 | $ hg clone -r0 binarysource binarydest | |
850 | adding changesets |
|
848 | adding changesets | |
851 | adding manifests |
|
849 | adding manifests | |
852 | adding file changes |
|
850 | adding file changes | |
853 | added 1 changesets with 1 changes to 1 files |
|
851 | added 1 changesets with 1 changes to 1 files | |
854 | new changesets 07f494440405 |
|
852 | new changesets 07f494440405 | |
855 | updating to branch default |
|
853 | updating to branch default | |
856 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
854 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
857 | $ cd binarydest |
|
855 | $ cd binarydest | |
858 | $ cp ../binarysource/b b |
|
856 | $ cp ../binarysource/b b | |
859 | $ hg ci -Am addb2 b |
|
857 | $ hg ci -Am addb2 b | |
860 | $ hg transplant -s ../binarysource 2 |
|
858 | $ hg transplant -s ../binarysource 2 | |
861 | searching for changes |
|
859 | searching for changes | |
862 | applying 7a7d57e15850 |
|
860 | applying 7a7d57e15850 | |
863 | skipping emptied changeset 7a7d57e15850 |
|
861 | skipping emptied changeset 7a7d57e15850 | |
864 |
|
862 | |||
865 | Test empty result in --continue |
|
863 | Test empty result in --continue | |
866 |
|
864 | |||
867 | $ hg transplant -s ../binarysource 1 |
|
865 | $ hg transplant -s ../binarysource 1 | |
868 | searching for changes |
|
866 | searching for changes | |
869 | applying 645035761929 |
|
867 | applying 645035761929 | |
870 | file b already exists |
|
868 | file b already exists | |
871 | 1 out of 1 hunks FAILED -- saving rejects to file b.rej |
|
869 | 1 out of 1 hunks FAILED -- saving rejects to file b.rej | |
872 | patch failed to apply |
|
870 | patch failed to apply | |
873 | abort: fix up the working directory and run hg transplant --continue |
|
871 | abort: fix up the working directory and run hg transplant --continue | |
874 | [255] |
|
872 | [255] | |
875 | $ hg status |
|
873 | $ hg status | |
876 | ? b.rej |
|
874 | ? b.rej | |
877 | $ hg transplant --continue |
|
875 | $ hg transplant --continue | |
878 | 645035761929 skipped due to empty diff |
|
876 | 645035761929 skipped due to empty diff | |
879 |
|
877 | |||
880 | $ cd .. |
|
878 | $ cd .. | |
881 |
|
879 | |||
882 | Explicitly kill daemons to let the test exit on Windows |
|
880 | Explicitly kill daemons to let the test exit on Windows | |
883 |
|
881 | |||
884 | $ killdaemons.py |
|
882 | $ killdaemons.py | |
885 |
|
883 | |||
886 | Test that patch-ed files are treated as "modified", when transplant is |
|
884 | Test that patch-ed files are treated as "modified", when transplant is | |
887 | aborted by failure of patching, even if none of mode, size and |
|
885 | aborted by failure of patching, even if none of mode, size and | |
888 | timestamp of them isn't changed on the filesystem (see also issue4583) |
|
886 | timestamp of them isn't changed on the filesystem (see also issue4583) | |
889 |
|
887 | |||
890 | $ cd t |
|
888 | $ cd t | |
891 |
|
889 | |||
892 | $ cat > $TESTTMP/abort.py <<EOF |
|
890 | $ cat > $TESTTMP/abort.py <<EOF | |
893 | > # emulate that patch.patch() is aborted at patching on "abort" file |
|
891 | > # emulate that patch.patch() is aborted at patching on "abort" file | |
894 | > from mercurial import error, extensions, patch as patchmod |
|
892 | > from mercurial import error, extensions, patch as patchmod | |
895 | > def patch(orig, ui, repo, patchname, |
|
893 | > def patch(orig, ui, repo, patchname, | |
896 | > strip=1, prefix='', files=None, |
|
894 | > strip=1, prefix='', files=None, | |
897 | > eolmode='strict', similarity=0): |
|
895 | > eolmode='strict', similarity=0): | |
898 | > if files is None: |
|
896 | > if files is None: | |
899 | > files = set() |
|
897 | > files = set() | |
900 | > r = orig(ui, repo, patchname, |
|
898 | > r = orig(ui, repo, patchname, | |
901 | > strip=strip, prefix=prefix, files=files, |
|
899 | > strip=strip, prefix=prefix, files=files, | |
902 | > eolmode=eolmode, similarity=similarity) |
|
900 | > eolmode=eolmode, similarity=similarity) | |
903 | > if 'abort' in files: |
|
901 | > if 'abort' in files: | |
904 | > raise error.PatchError('intentional error while patching') |
|
902 | > raise error.PatchError('intentional error while patching') | |
905 | > return r |
|
903 | > return r | |
906 | > def extsetup(ui): |
|
904 | > def extsetup(ui): | |
907 | > extensions.wrapfunction(patchmod, 'patch', patch) |
|
905 | > extensions.wrapfunction(patchmod, 'patch', patch) | |
908 | > EOF |
|
906 | > EOF | |
909 |
|
907 | |||
910 | $ echo X1 > r1 |
|
908 | $ echo X1 > r1 | |
911 | $ hg diff --nodates r1 |
|
909 | $ hg diff --nodates r1 | |
912 | diff -r a53251cdf717 r1 |
|
910 | diff -r a53251cdf717 r1 | |
913 | --- a/r1 |
|
911 | --- a/r1 | |
914 | +++ b/r1 |
|
912 | +++ b/r1 | |
915 | @@ -1,1 +1,1 @@ |
|
913 | @@ -1,1 +1,1 @@ | |
916 | -r1 |
|
914 | -r1 | |
917 | +X1 |
|
915 | +X1 | |
918 | $ hg commit -m "X1 as r1" |
|
916 | $ hg commit -m "X1 as r1" | |
919 |
|
917 | |||
920 | $ echo 'marking to abort patching' > abort |
|
918 | $ echo 'marking to abort patching' > abort | |
921 | $ hg add abort |
|
919 | $ hg add abort | |
922 | $ echo Y1 > r1 |
|
920 | $ echo Y1 > r1 | |
923 | $ hg diff --nodates r1 |
|
921 | $ hg diff --nodates r1 | |
924 | diff -r 22c515968f13 r1 |
|
922 | diff -r 22c515968f13 r1 | |
925 | --- a/r1 |
|
923 | --- a/r1 | |
926 | +++ b/r1 |
|
924 | +++ b/r1 | |
927 | @@ -1,1 +1,1 @@ |
|
925 | @@ -1,1 +1,1 @@ | |
928 | -X1 |
|
926 | -X1 | |
929 | +Y1 |
|
927 | +Y1 | |
930 | $ hg commit -m "Y1 as r1" |
|
928 | $ hg commit -m "Y1 as r1" | |
931 |
|
929 | |||
932 | $ hg update -q -C d11e3596cc1a |
|
930 | $ hg update -q -C d11e3596cc1a | |
933 | $ cat r1 |
|
931 | $ cat r1 | |
934 | r1 |
|
932 | r1 | |
935 |
|
933 | |||
936 | $ cat >> .hg/hgrc <<EOF |
|
934 | $ cat >> .hg/hgrc <<EOF | |
937 | > [fakedirstatewritetime] |
|
935 | > [fakedirstatewritetime] | |
938 | > # emulate invoking dirstate.write() via repo.status() or markcommitted() |
|
936 | > # emulate invoking dirstate.write() via repo.status() or markcommitted() | |
939 | > # at 2000-01-01 00:00 |
|
937 | > # at 2000-01-01 00:00 | |
940 | > fakenow = 200001010000 |
|
938 | > fakenow = 200001010000 | |
941 | > |
|
939 | > | |
942 | > # emulate invoking patch.internalpatch() at 2000-01-01 00:00 |
|
940 | > # emulate invoking patch.internalpatch() at 2000-01-01 00:00 | |
943 | > [fakepatchtime] |
|
941 | > [fakepatchtime] | |
944 | > fakenow = 200001010000 |
|
942 | > fakenow = 200001010000 | |
945 | > |
|
943 | > | |
946 | > [extensions] |
|
944 | > [extensions] | |
947 | > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py |
|
945 | > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py | |
948 | > fakepatchtime = $TESTDIR/fakepatchtime.py |
|
946 | > fakepatchtime = $TESTDIR/fakepatchtime.py | |
949 | > abort = $TESTTMP/abort.py |
|
947 | > abort = $TESTTMP/abort.py | |
950 | > EOF |
|
948 | > EOF | |
951 | $ hg transplant "22c515968f13::" |
|
949 | $ hg transplant "22c515968f13::" | |
952 | applying 22c515968f13 |
|
950 | applying 22c515968f13 | |
953 | 22c515968f13 transplanted to * (glob) |
|
951 | 22c515968f13 transplanted to * (glob) | |
954 | applying e38700ba9dd3 |
|
952 | applying e38700ba9dd3 | |
955 | intentional error while patching |
|
953 | intentional error while patching | |
956 | abort: fix up the working directory and run hg transplant --continue |
|
954 | abort: fix up the working directory and run hg transplant --continue | |
957 | [255] |
|
955 | [255] | |
958 | $ cat >> .hg/hgrc <<EOF |
|
956 | $ cat >> .hg/hgrc <<EOF | |
959 | > [hooks] |
|
957 | > [hooks] | |
960 | > fakedirstatewritetime = ! |
|
958 | > fakedirstatewritetime = ! | |
961 | > fakepatchtime = ! |
|
959 | > fakepatchtime = ! | |
962 | > [extensions] |
|
960 | > [extensions] | |
963 | > abort = ! |
|
961 | > abort = ! | |
964 | > EOF |
|
962 | > EOF | |
965 |
|
963 | |||
966 | $ cat r1 |
|
964 | $ cat r1 | |
967 | Y1 |
|
965 | Y1 | |
968 | $ hg debugstate | grep ' r1$' |
|
966 | $ hg debugstate | grep ' r1$' | |
969 | n 644 3 unset r1 |
|
967 | n 644 3 unset r1 | |
970 | $ hg status -A r1 |
|
968 | $ hg status -A r1 | |
971 | M r1 |
|
969 | M r1 | |
972 |
|
970 | |||
973 | Test that rollback by unexpected failure after transplanting the first |
|
971 | Test that rollback by unexpected failure after transplanting the first | |
974 | revision restores dirstate correctly. |
|
972 | revision restores dirstate correctly. | |
975 |
|
973 | |||
976 | $ hg rollback -q |
|
974 | $ hg rollback -q | |
977 | $ rm -f abort |
|
975 | $ rm -f abort | |
978 | $ hg update -q -C d11e3596cc1a |
|
976 | $ hg update -q -C d11e3596cc1a | |
979 | $ hg parents -T "{node|short}\n" |
|
977 | $ hg parents -T "{node|short}\n" | |
980 | d11e3596cc1a |
|
978 | d11e3596cc1a | |
981 | $ hg status -A |
|
979 | $ hg status -A | |
982 | C r1 |
|
980 | C r1 | |
983 | C r2 |
|
981 | C r2 | |
984 |
|
982 | |||
985 | $ cat >> .hg/hgrc <<EOF |
|
983 | $ cat >> .hg/hgrc <<EOF | |
986 | > [hooks] |
|
984 | > [hooks] | |
987 | > # emulate failure at transplanting the 2nd revision |
|
985 | > # emulate failure at transplanting the 2nd revision | |
988 | > pretxncommit.abort = test ! -f abort |
|
986 | > pretxncommit.abort = test ! -f abort | |
989 | > EOF |
|
987 | > EOF | |
990 | $ hg transplant "22c515968f13::" |
|
988 | $ hg transplant "22c515968f13::" | |
991 | applying 22c515968f13 |
|
989 | applying 22c515968f13 | |
992 | 22c515968f13 transplanted to * (glob) |
|
990 | 22c515968f13 transplanted to * (glob) | |
993 | applying e38700ba9dd3 |
|
991 | applying e38700ba9dd3 | |
994 | transaction abort! |
|
992 | transaction abort! | |
995 | rollback completed |
|
993 | rollback completed | |
996 | abort: pretxncommit.abort hook exited with status 1 |
|
994 | abort: pretxncommit.abort hook exited with status 1 | |
997 | [255] |
|
995 | [255] | |
998 | $ cat >> .hg/hgrc <<EOF |
|
996 | $ cat >> .hg/hgrc <<EOF | |
999 | > [hooks] |
|
997 | > [hooks] | |
1000 | > pretxncommit.abort = ! |
|
998 | > pretxncommit.abort = ! | |
1001 | > EOF |
|
999 | > EOF | |
1002 |
|
1000 | |||
1003 | $ hg parents -T "{node|short}\n" |
|
1001 | $ hg parents -T "{node|short}\n" | |
1004 | d11e3596cc1a |
|
1002 | d11e3596cc1a | |
1005 | $ hg status -A |
|
1003 | $ hg status -A | |
1006 | M r1 |
|
1004 | M r1 | |
1007 | ? abort |
|
1005 | ? abort | |
1008 | C r2 |
|
1006 | C r2 | |
1009 |
|
1007 | |||
1010 | $ cd .. |
|
1008 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now