Show More
@@ -1,1907 +1,1912 | |||||
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 | from node import hex, nullid, wdirrev, short |
|
7 | from node import hex, nullid, wdirrev, short | |
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | import urllib |
|
9 | import urllib | |
10 | import peer, changegroup, subrepo, pushkey, obsolete, repoview |
|
10 | import peer, changegroup, subrepo, pushkey, obsolete, repoview | |
11 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
|
11 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases | |
12 | import lock as lockmod |
|
12 | import lock as lockmod | |
13 | import transaction, store, encoding, exchange, bundle2 |
|
13 | import transaction, store, encoding, exchange, bundle2 | |
14 | import scmutil, util, extensions, hook, error, revset |
|
14 | import scmutil, util, extensions, hook, error, revset, cmdutil | |
15 | import match as matchmod |
|
15 | import match as matchmod | |
16 | import merge as mergemod |
|
16 | import merge as mergemod | |
17 | import tags as tagsmod |
|
17 | import tags as tagsmod | |
18 | from lock import release |
|
18 | from lock import release | |
19 | import weakref, errno, os, time, inspect, random |
|
19 | import weakref, errno, os, time, inspect, random | |
20 | import branchmap, pathutil |
|
20 | import branchmap, pathutil | |
21 | import namespaces |
|
21 | import namespaces | |
22 | propertycache = util.propertycache |
|
22 | propertycache = util.propertycache | |
23 | filecache = scmutil.filecache |
|
23 | filecache = scmutil.filecache | |
24 |
|
24 | |||
25 | class repofilecache(filecache): |
|
25 | class repofilecache(filecache): | |
26 | """All filecache usage on repo are done for logic that should be unfiltered |
|
26 | """All filecache usage on repo are done for logic that should be unfiltered | |
27 | """ |
|
27 | """ | |
28 |
|
28 | |||
29 | def __get__(self, repo, type=None): |
|
29 | def __get__(self, repo, type=None): | |
30 | return super(repofilecache, self).__get__(repo.unfiltered(), type) |
|
30 | return super(repofilecache, self).__get__(repo.unfiltered(), type) | |
31 | def __set__(self, repo, value): |
|
31 | def __set__(self, repo, value): | |
32 | return super(repofilecache, self).__set__(repo.unfiltered(), value) |
|
32 | return super(repofilecache, self).__set__(repo.unfiltered(), value) | |
33 | def __delete__(self, repo): |
|
33 | def __delete__(self, repo): | |
34 | return super(repofilecache, self).__delete__(repo.unfiltered()) |
|
34 | return super(repofilecache, self).__delete__(repo.unfiltered()) | |
35 |
|
35 | |||
36 | class storecache(repofilecache): |
|
36 | class storecache(repofilecache): | |
37 | """filecache for files in the store""" |
|
37 | """filecache for files in the store""" | |
38 | def join(self, obj, fname): |
|
38 | def join(self, obj, fname): | |
39 | return obj.sjoin(fname) |
|
39 | return obj.sjoin(fname) | |
40 |
|
40 | |||
41 | class unfilteredpropertycache(propertycache): |
|
41 | class unfilteredpropertycache(propertycache): | |
42 | """propertycache that apply to unfiltered repo only""" |
|
42 | """propertycache that apply to unfiltered repo only""" | |
43 |
|
43 | |||
44 | def __get__(self, repo, type=None): |
|
44 | def __get__(self, repo, type=None): | |
45 | unfi = repo.unfiltered() |
|
45 | unfi = repo.unfiltered() | |
46 | if unfi is repo: |
|
46 | if unfi is repo: | |
47 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
47 | return super(unfilteredpropertycache, self).__get__(unfi) | |
48 | return getattr(unfi, self.name) |
|
48 | return getattr(unfi, self.name) | |
49 |
|
49 | |||
50 | class filteredpropertycache(propertycache): |
|
50 | class filteredpropertycache(propertycache): | |
51 | """propertycache that must take filtering in account""" |
|
51 | """propertycache that must take filtering in account""" | |
52 |
|
52 | |||
53 | def cachevalue(self, obj, value): |
|
53 | def cachevalue(self, obj, value): | |
54 | object.__setattr__(obj, self.name, value) |
|
54 | object.__setattr__(obj, self.name, value) | |
55 |
|
55 | |||
56 |
|
56 | |||
57 | def hasunfilteredcache(repo, name): |
|
57 | def hasunfilteredcache(repo, name): | |
58 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
58 | """check if a repo has an unfilteredpropertycache value for <name>""" | |
59 | return name in vars(repo.unfiltered()) |
|
59 | return name in vars(repo.unfiltered()) | |
60 |
|
60 | |||
61 | def unfilteredmethod(orig): |
|
61 | def unfilteredmethod(orig): | |
62 | """decorate method that always need to be run on unfiltered version""" |
|
62 | """decorate method that always need to be run on unfiltered version""" | |
63 | def wrapper(repo, *args, **kwargs): |
|
63 | def wrapper(repo, *args, **kwargs): | |
64 | return orig(repo.unfiltered(), *args, **kwargs) |
|
64 | return orig(repo.unfiltered(), *args, **kwargs) | |
65 | return wrapper |
|
65 | return wrapper | |
66 |
|
66 | |||
67 | moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle', |
|
67 | moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle', | |
68 | 'unbundle')) |
|
68 | 'unbundle')) | |
69 | legacycaps = moderncaps.union(set(['changegroupsubset'])) |
|
69 | legacycaps = moderncaps.union(set(['changegroupsubset'])) | |
70 |
|
70 | |||
71 | class localpeer(peer.peerrepository): |
|
71 | class localpeer(peer.peerrepository): | |
72 | '''peer for a local repo; reflects only the most recent API''' |
|
72 | '''peer for a local repo; reflects only the most recent API''' | |
73 |
|
73 | |||
74 | def __init__(self, repo, caps=moderncaps): |
|
74 | def __init__(self, repo, caps=moderncaps): | |
75 | peer.peerrepository.__init__(self) |
|
75 | peer.peerrepository.__init__(self) | |
76 | self._repo = repo.filtered('served') |
|
76 | self._repo = repo.filtered('served') | |
77 | self.ui = repo.ui |
|
77 | self.ui = repo.ui | |
78 | self._caps = repo._restrictcapabilities(caps) |
|
78 | self._caps = repo._restrictcapabilities(caps) | |
79 | self.requirements = repo.requirements |
|
79 | self.requirements = repo.requirements | |
80 | self.supportedformats = repo.supportedformats |
|
80 | self.supportedformats = repo.supportedformats | |
81 |
|
81 | |||
82 | def close(self): |
|
82 | def close(self): | |
83 | self._repo.close() |
|
83 | self._repo.close() | |
84 |
|
84 | |||
85 | def _capabilities(self): |
|
85 | def _capabilities(self): | |
86 | return self._caps |
|
86 | return self._caps | |
87 |
|
87 | |||
88 | def local(self): |
|
88 | def local(self): | |
89 | return self._repo |
|
89 | return self._repo | |
90 |
|
90 | |||
91 | def canpush(self): |
|
91 | def canpush(self): | |
92 | return True |
|
92 | return True | |
93 |
|
93 | |||
94 | def url(self): |
|
94 | def url(self): | |
95 | return self._repo.url() |
|
95 | return self._repo.url() | |
96 |
|
96 | |||
97 | def lookup(self, key): |
|
97 | def lookup(self, key): | |
98 | return self._repo.lookup(key) |
|
98 | return self._repo.lookup(key) | |
99 |
|
99 | |||
100 | def branchmap(self): |
|
100 | def branchmap(self): | |
101 | return self._repo.branchmap() |
|
101 | return self._repo.branchmap() | |
102 |
|
102 | |||
103 | def heads(self): |
|
103 | def heads(self): | |
104 | return self._repo.heads() |
|
104 | return self._repo.heads() | |
105 |
|
105 | |||
106 | def known(self, nodes): |
|
106 | def known(self, nodes): | |
107 | return self._repo.known(nodes) |
|
107 | return self._repo.known(nodes) | |
108 |
|
108 | |||
109 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, |
|
109 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, | |
110 | **kwargs): |
|
110 | **kwargs): | |
111 | cg = exchange.getbundle(self._repo, source, heads=heads, |
|
111 | cg = exchange.getbundle(self._repo, source, heads=heads, | |
112 | common=common, bundlecaps=bundlecaps, **kwargs) |
|
112 | common=common, bundlecaps=bundlecaps, **kwargs) | |
113 | if bundlecaps is not None and 'HG20' in bundlecaps: |
|
113 | if bundlecaps is not None and 'HG20' in bundlecaps: | |
114 | # When requesting a bundle2, getbundle returns a stream to make the |
|
114 | # When requesting a bundle2, getbundle returns a stream to make the | |
115 | # wire level function happier. We need to build a proper object |
|
115 | # wire level function happier. We need to build a proper object | |
116 | # from it in local peer. |
|
116 | # from it in local peer. | |
117 | cg = bundle2.getunbundler(self.ui, cg) |
|
117 | cg = bundle2.getunbundler(self.ui, cg) | |
118 | return cg |
|
118 | return cg | |
119 |
|
119 | |||
120 | # TODO We might want to move the next two calls into legacypeer and add |
|
120 | # TODO We might want to move the next two calls into legacypeer and add | |
121 | # unbundle instead. |
|
121 | # unbundle instead. | |
122 |
|
122 | |||
123 | def unbundle(self, cg, heads, url): |
|
123 | def unbundle(self, cg, heads, url): | |
124 | """apply a bundle on a repo |
|
124 | """apply a bundle on a repo | |
125 |
|
125 | |||
126 | This function handles the repo locking itself.""" |
|
126 | This function handles the repo locking itself.""" | |
127 | try: |
|
127 | try: | |
128 | try: |
|
128 | try: | |
129 | cg = exchange.readbundle(self.ui, cg, None) |
|
129 | cg = exchange.readbundle(self.ui, cg, None) | |
130 | ret = exchange.unbundle(self._repo, cg, heads, 'push', url) |
|
130 | ret = exchange.unbundle(self._repo, cg, heads, 'push', url) | |
131 | if util.safehasattr(ret, 'getchunks'): |
|
131 | if util.safehasattr(ret, 'getchunks'): | |
132 | # This is a bundle20 object, turn it into an unbundler. |
|
132 | # This is a bundle20 object, turn it into an unbundler. | |
133 | # This little dance should be dropped eventually when the |
|
133 | # This little dance should be dropped eventually when the | |
134 | # API is finally improved. |
|
134 | # API is finally improved. | |
135 | stream = util.chunkbuffer(ret.getchunks()) |
|
135 | stream = util.chunkbuffer(ret.getchunks()) | |
136 | ret = bundle2.getunbundler(self.ui, stream) |
|
136 | ret = bundle2.getunbundler(self.ui, stream) | |
137 | return ret |
|
137 | return ret | |
138 | except Exception as exc: |
|
138 | except Exception as exc: | |
139 | # If the exception contains output salvaged from a bundle2 |
|
139 | # If the exception contains output salvaged from a bundle2 | |
140 | # reply, we need to make sure it is printed before continuing |
|
140 | # reply, we need to make sure it is printed before continuing | |
141 | # to fail. So we build a bundle2 with such output and consume |
|
141 | # to fail. So we build a bundle2 with such output and consume | |
142 | # it directly. |
|
142 | # it directly. | |
143 | # |
|
143 | # | |
144 | # This is not very elegant but allows a "simple" solution for |
|
144 | # This is not very elegant but allows a "simple" solution for | |
145 | # issue4594 |
|
145 | # issue4594 | |
146 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
146 | output = getattr(exc, '_bundle2salvagedoutput', ()) | |
147 | if output: |
|
147 | if output: | |
148 | bundler = bundle2.bundle20(self._repo.ui) |
|
148 | bundler = bundle2.bundle20(self._repo.ui) | |
149 | for out in output: |
|
149 | for out in output: | |
150 | bundler.addpart(out) |
|
150 | bundler.addpart(out) | |
151 | stream = util.chunkbuffer(bundler.getchunks()) |
|
151 | stream = util.chunkbuffer(bundler.getchunks()) | |
152 | b = bundle2.getunbundler(self.ui, stream) |
|
152 | b = bundle2.getunbundler(self.ui, stream) | |
153 | bundle2.processbundle(self._repo, b) |
|
153 | bundle2.processbundle(self._repo, b) | |
154 | raise |
|
154 | raise | |
155 | except error.PushRaced as exc: |
|
155 | except error.PushRaced as exc: | |
156 | raise error.ResponseError(_('push failed:'), str(exc)) |
|
156 | raise error.ResponseError(_('push failed:'), str(exc)) | |
157 |
|
157 | |||
158 | def lock(self): |
|
158 | def lock(self): | |
159 | return self._repo.lock() |
|
159 | return self._repo.lock() | |
160 |
|
160 | |||
161 | def addchangegroup(self, cg, source, url): |
|
161 | def addchangegroup(self, cg, source, url): | |
162 | return changegroup.addchangegroup(self._repo, cg, source, url) |
|
162 | return changegroup.addchangegroup(self._repo, cg, source, url) | |
163 |
|
163 | |||
164 | def pushkey(self, namespace, key, old, new): |
|
164 | def pushkey(self, namespace, key, old, new): | |
165 | return self._repo.pushkey(namespace, key, old, new) |
|
165 | return self._repo.pushkey(namespace, key, old, new) | |
166 |
|
166 | |||
167 | def listkeys(self, namespace): |
|
167 | def listkeys(self, namespace): | |
168 | return self._repo.listkeys(namespace) |
|
168 | return self._repo.listkeys(namespace) | |
169 |
|
169 | |||
170 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
170 | def debugwireargs(self, one, two, three=None, four=None, five=None): | |
171 | '''used to test argument passing over the wire''' |
|
171 | '''used to test argument passing over the wire''' | |
172 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
172 | return "%s %s %s %s %s" % (one, two, three, four, five) | |
173 |
|
173 | |||
174 | class locallegacypeer(localpeer): |
|
174 | class locallegacypeer(localpeer): | |
175 | '''peer extension which implements legacy methods too; used for tests with |
|
175 | '''peer extension which implements legacy methods too; used for tests with | |
176 | restricted capabilities''' |
|
176 | restricted capabilities''' | |
177 |
|
177 | |||
178 | def __init__(self, repo): |
|
178 | def __init__(self, repo): | |
179 | localpeer.__init__(self, repo, caps=legacycaps) |
|
179 | localpeer.__init__(self, repo, caps=legacycaps) | |
180 |
|
180 | |||
181 | def branches(self, nodes): |
|
181 | def branches(self, nodes): | |
182 | return self._repo.branches(nodes) |
|
182 | return self._repo.branches(nodes) | |
183 |
|
183 | |||
184 | def between(self, pairs): |
|
184 | def between(self, pairs): | |
185 | return self._repo.between(pairs) |
|
185 | return self._repo.between(pairs) | |
186 |
|
186 | |||
187 | def changegroup(self, basenodes, source): |
|
187 | def changegroup(self, basenodes, source): | |
188 | return changegroup.changegroup(self._repo, basenodes, source) |
|
188 | return changegroup.changegroup(self._repo, basenodes, source) | |
189 |
|
189 | |||
190 | def changegroupsubset(self, bases, heads, source): |
|
190 | def changegroupsubset(self, bases, heads, source): | |
191 | return changegroup.changegroupsubset(self._repo, bases, heads, source) |
|
191 | return changegroup.changegroupsubset(self._repo, bases, heads, source) | |
192 |
|
192 | |||
193 | class localrepository(object): |
|
193 | class localrepository(object): | |
194 |
|
194 | |||
195 | supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', |
|
195 | supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', | |
196 | 'manifestv2')) |
|
196 | 'manifestv2')) | |
197 | _basesupported = supportedformats | set(('store', 'fncache', 'shared', |
|
197 | _basesupported = supportedformats | set(('store', 'fncache', 'shared', | |
198 | 'dotencode')) |
|
198 | 'dotencode')) | |
199 | openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) |
|
199 | openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) | |
200 | filtername = None |
|
200 | filtername = None | |
201 |
|
201 | |||
202 | # a list of (ui, featureset) functions. |
|
202 | # a list of (ui, featureset) functions. | |
203 | # only functions defined in module of enabled extensions are invoked |
|
203 | # only functions defined in module of enabled extensions are invoked | |
204 | featuresetupfuncs = set() |
|
204 | featuresetupfuncs = set() | |
205 |
|
205 | |||
206 | def _baserequirements(self, create): |
|
206 | def _baserequirements(self, create): | |
207 | return ['revlogv1'] |
|
207 | return ['revlogv1'] | |
208 |
|
208 | |||
209 | def __init__(self, baseui, path=None, create=False): |
|
209 | def __init__(self, baseui, path=None, create=False): | |
210 | self.requirements = set() |
|
210 | self.requirements = set() | |
211 | self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True) |
|
211 | self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True) | |
212 | self.wopener = self.wvfs |
|
212 | self.wopener = self.wvfs | |
213 | self.root = self.wvfs.base |
|
213 | self.root = self.wvfs.base | |
214 | self.path = self.wvfs.join(".hg") |
|
214 | self.path = self.wvfs.join(".hg") | |
215 | self.origroot = path |
|
215 | self.origroot = path | |
216 | self.auditor = pathutil.pathauditor(self.root, self._checknested) |
|
216 | self.auditor = pathutil.pathauditor(self.root, self._checknested) | |
217 | self.vfs = scmutil.vfs(self.path) |
|
217 | self.vfs = scmutil.vfs(self.path) | |
218 | self.opener = self.vfs |
|
218 | self.opener = self.vfs | |
219 | self.baseui = baseui |
|
219 | self.baseui = baseui | |
220 | self.ui = baseui.copy() |
|
220 | self.ui = baseui.copy() | |
221 | self.ui.copy = baseui.copy # prevent copying repo configuration |
|
221 | self.ui.copy = baseui.copy # prevent copying repo configuration | |
222 | # A list of callback to shape the phase if no data were found. |
|
222 | # A list of callback to shape the phase if no data were found. | |
223 | # Callback are in the form: func(repo, roots) --> processed root. |
|
223 | # Callback are in the form: func(repo, roots) --> processed root. | |
224 | # This list it to be filled by extension during repo setup |
|
224 | # This list it to be filled by extension during repo setup | |
225 | self._phasedefaults = [] |
|
225 | self._phasedefaults = [] | |
226 | try: |
|
226 | try: | |
227 | self.ui.readconfig(self.join("hgrc"), self.root) |
|
227 | self.ui.readconfig(self.join("hgrc"), self.root) | |
228 | extensions.loadall(self.ui) |
|
228 | extensions.loadall(self.ui) | |
229 | except IOError: |
|
229 | except IOError: | |
230 | pass |
|
230 | pass | |
231 |
|
231 | |||
232 | if self.featuresetupfuncs: |
|
232 | if self.featuresetupfuncs: | |
233 | self.supported = set(self._basesupported) # use private copy |
|
233 | self.supported = set(self._basesupported) # use private copy | |
234 | extmods = set(m.__name__ for n, m |
|
234 | extmods = set(m.__name__ for n, m | |
235 | in extensions.extensions(self.ui)) |
|
235 | in extensions.extensions(self.ui)) | |
236 | for setupfunc in self.featuresetupfuncs: |
|
236 | for setupfunc in self.featuresetupfuncs: | |
237 | if setupfunc.__module__ in extmods: |
|
237 | if setupfunc.__module__ in extmods: | |
238 | setupfunc(self.ui, self.supported) |
|
238 | setupfunc(self.ui, self.supported) | |
239 | else: |
|
239 | else: | |
240 | self.supported = self._basesupported |
|
240 | self.supported = self._basesupported | |
241 |
|
241 | |||
242 | if not self.vfs.isdir(): |
|
242 | if not self.vfs.isdir(): | |
243 | if create: |
|
243 | if create: | |
244 | if not self.wvfs.exists(): |
|
244 | if not self.wvfs.exists(): | |
245 | self.wvfs.makedirs() |
|
245 | self.wvfs.makedirs() | |
246 | self.vfs.makedir(notindexed=True) |
|
246 | self.vfs.makedir(notindexed=True) | |
247 | self.requirements.update(self._baserequirements(create)) |
|
247 | self.requirements.update(self._baserequirements(create)) | |
248 | if self.ui.configbool('format', 'usestore', True): |
|
248 | if self.ui.configbool('format', 'usestore', True): | |
249 | self.vfs.mkdir("store") |
|
249 | self.vfs.mkdir("store") | |
250 | self.requirements.add("store") |
|
250 | self.requirements.add("store") | |
251 | if self.ui.configbool('format', 'usefncache', True): |
|
251 | if self.ui.configbool('format', 'usefncache', True): | |
252 | self.requirements.add("fncache") |
|
252 | self.requirements.add("fncache") | |
253 | if self.ui.configbool('format', 'dotencode', True): |
|
253 | if self.ui.configbool('format', 'dotencode', True): | |
254 | self.requirements.add('dotencode') |
|
254 | self.requirements.add('dotencode') | |
255 | # create an invalid changelog |
|
255 | # create an invalid changelog | |
256 | self.vfs.append( |
|
256 | self.vfs.append( | |
257 | "00changelog.i", |
|
257 | "00changelog.i", | |
258 | '\0\0\0\2' # represents revlogv2 |
|
258 | '\0\0\0\2' # represents revlogv2 | |
259 | ' dummy changelog to prevent using the old repo layout' |
|
259 | ' dummy changelog to prevent using the old repo layout' | |
260 | ) |
|
260 | ) | |
261 | # experimental config: format.generaldelta |
|
261 | # experimental config: format.generaldelta | |
262 | if self.ui.configbool('format', 'generaldelta', False): |
|
262 | if self.ui.configbool('format', 'generaldelta', False): | |
263 | self.requirements.add("generaldelta") |
|
263 | self.requirements.add("generaldelta") | |
264 | if self.ui.configbool('experimental', 'treemanifest', False): |
|
264 | if self.ui.configbool('experimental', 'treemanifest', False): | |
265 | self.requirements.add("treemanifest") |
|
265 | self.requirements.add("treemanifest") | |
266 | if self.ui.configbool('experimental', 'manifestv2', False): |
|
266 | if self.ui.configbool('experimental', 'manifestv2', False): | |
267 | self.requirements.add("manifestv2") |
|
267 | self.requirements.add("manifestv2") | |
268 | else: |
|
268 | else: | |
269 | raise error.RepoError(_("repository %s not found") % path) |
|
269 | raise error.RepoError(_("repository %s not found") % path) | |
270 | elif create: |
|
270 | elif create: | |
271 | raise error.RepoError(_("repository %s already exists") % path) |
|
271 | raise error.RepoError(_("repository %s already exists") % path) | |
272 | else: |
|
272 | else: | |
273 | try: |
|
273 | try: | |
274 | self.requirements = scmutil.readrequires( |
|
274 | self.requirements = scmutil.readrequires( | |
275 | self.vfs, self.supported) |
|
275 | self.vfs, self.supported) | |
276 | except IOError as inst: |
|
276 | except IOError as inst: | |
277 | if inst.errno != errno.ENOENT: |
|
277 | if inst.errno != errno.ENOENT: | |
278 | raise |
|
278 | raise | |
279 |
|
279 | |||
280 | self.sharedpath = self.path |
|
280 | self.sharedpath = self.path | |
281 | try: |
|
281 | try: | |
282 | vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'), |
|
282 | vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'), | |
283 | realpath=True) |
|
283 | realpath=True) | |
284 | s = vfs.base |
|
284 | s = vfs.base | |
285 | if not vfs.exists(): |
|
285 | if not vfs.exists(): | |
286 | raise error.RepoError( |
|
286 | raise error.RepoError( | |
287 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
287 | _('.hg/sharedpath points to nonexistent directory %s') % s) | |
288 | self.sharedpath = s |
|
288 | self.sharedpath = s | |
289 | except IOError as inst: |
|
289 | except IOError as inst: | |
290 | if inst.errno != errno.ENOENT: |
|
290 | if inst.errno != errno.ENOENT: | |
291 | raise |
|
291 | raise | |
292 |
|
292 | |||
293 | self.store = store.store( |
|
293 | self.store = store.store( | |
294 | self.requirements, self.sharedpath, scmutil.vfs) |
|
294 | self.requirements, self.sharedpath, scmutil.vfs) | |
295 | self.spath = self.store.path |
|
295 | self.spath = self.store.path | |
296 | self.svfs = self.store.vfs |
|
296 | self.svfs = self.store.vfs | |
297 | self.sjoin = self.store.join |
|
297 | self.sjoin = self.store.join | |
298 | self.vfs.createmode = self.store.createmode |
|
298 | self.vfs.createmode = self.store.createmode | |
299 | self._applyopenerreqs() |
|
299 | self._applyopenerreqs() | |
300 | if create: |
|
300 | if create: | |
301 | self._writerequirements() |
|
301 | self._writerequirements() | |
302 |
|
302 | |||
303 | self._dirstatevalidatewarned = False |
|
303 | self._dirstatevalidatewarned = False | |
304 |
|
304 | |||
305 | self._branchcaches = {} |
|
305 | self._branchcaches = {} | |
306 | self._revbranchcache = None |
|
306 | self._revbranchcache = None | |
307 | self.filterpats = {} |
|
307 | self.filterpats = {} | |
308 | self._datafilters = {} |
|
308 | self._datafilters = {} | |
309 | self._transref = self._lockref = self._wlockref = None |
|
309 | self._transref = self._lockref = self._wlockref = None | |
310 |
|
310 | |||
311 | # A cache for various files under .hg/ that tracks file changes, |
|
311 | # A cache for various files under .hg/ that tracks file changes, | |
312 | # (used by the filecache decorator) |
|
312 | # (used by the filecache decorator) | |
313 | # |
|
313 | # | |
314 | # Maps a property name to its util.filecacheentry |
|
314 | # Maps a property name to its util.filecacheentry | |
315 | self._filecache = {} |
|
315 | self._filecache = {} | |
316 |
|
316 | |||
317 | # hold sets of revision to be filtered |
|
317 | # hold sets of revision to be filtered | |
318 | # should be cleared when something might have changed the filter value: |
|
318 | # should be cleared when something might have changed the filter value: | |
319 | # - new changesets, |
|
319 | # - new changesets, | |
320 | # - phase change, |
|
320 | # - phase change, | |
321 | # - new obsolescence marker, |
|
321 | # - new obsolescence marker, | |
322 | # - working directory parent change, |
|
322 | # - working directory parent change, | |
323 | # - bookmark changes |
|
323 | # - bookmark changes | |
324 | self.filteredrevcache = {} |
|
324 | self.filteredrevcache = {} | |
325 |
|
325 | |||
326 | # generic mapping between names and nodes |
|
326 | # generic mapping between names and nodes | |
327 | self.names = namespaces.namespaces() |
|
327 | self.names = namespaces.namespaces() | |
328 |
|
328 | |||
329 | def close(self): |
|
329 | def close(self): | |
330 | self._writecaches() |
|
330 | self._writecaches() | |
331 |
|
331 | |||
332 | def _writecaches(self): |
|
332 | def _writecaches(self): | |
333 | if self._revbranchcache: |
|
333 | if self._revbranchcache: | |
334 | self._revbranchcache.write() |
|
334 | self._revbranchcache.write() | |
335 |
|
335 | |||
336 | def _restrictcapabilities(self, caps): |
|
336 | def _restrictcapabilities(self, caps): | |
337 | if self.ui.configbool('experimental', 'bundle2-advertise', True): |
|
337 | if self.ui.configbool('experimental', 'bundle2-advertise', True): | |
338 | caps = set(caps) |
|
338 | caps = set(caps) | |
339 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self)) |
|
339 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self)) | |
340 | caps.add('bundle2=' + urllib.quote(capsblob)) |
|
340 | caps.add('bundle2=' + urllib.quote(capsblob)) | |
341 | return caps |
|
341 | return caps | |
342 |
|
342 | |||
343 | def _applyopenerreqs(self): |
|
343 | def _applyopenerreqs(self): | |
344 | self.svfs.options = dict((r, 1) for r in self.requirements |
|
344 | self.svfs.options = dict((r, 1) for r in self.requirements | |
345 | if r in self.openerreqs) |
|
345 | if r in self.openerreqs) | |
346 | # experimental config: format.chunkcachesize |
|
346 | # experimental config: format.chunkcachesize | |
347 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') |
|
347 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') | |
348 | if chunkcachesize is not None: |
|
348 | if chunkcachesize is not None: | |
349 | self.svfs.options['chunkcachesize'] = chunkcachesize |
|
349 | self.svfs.options['chunkcachesize'] = chunkcachesize | |
350 | # experimental config: format.maxchainlen |
|
350 | # experimental config: format.maxchainlen | |
351 | maxchainlen = self.ui.configint('format', 'maxchainlen') |
|
351 | maxchainlen = self.ui.configint('format', 'maxchainlen') | |
352 | if maxchainlen is not None: |
|
352 | if maxchainlen is not None: | |
353 | self.svfs.options['maxchainlen'] = maxchainlen |
|
353 | self.svfs.options['maxchainlen'] = maxchainlen | |
354 | # experimental config: format.manifestcachesize |
|
354 | # experimental config: format.manifestcachesize | |
355 | manifestcachesize = self.ui.configint('format', 'manifestcachesize') |
|
355 | manifestcachesize = self.ui.configint('format', 'manifestcachesize') | |
356 | if manifestcachesize is not None: |
|
356 | if manifestcachesize is not None: | |
357 | self.svfs.options['manifestcachesize'] = manifestcachesize |
|
357 | self.svfs.options['manifestcachesize'] = manifestcachesize | |
358 | # experimental config: format.aggressivemergedeltas |
|
358 | # experimental config: format.aggressivemergedeltas | |
359 | aggressivemergedeltas = self.ui.configbool('format', |
|
359 | aggressivemergedeltas = self.ui.configbool('format', | |
360 | 'aggressivemergedeltas', False) |
|
360 | 'aggressivemergedeltas', False) | |
361 | self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas |
|
361 | self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas | |
362 |
|
362 | |||
363 | def _writerequirements(self): |
|
363 | def _writerequirements(self): | |
364 | scmutil.writerequires(self.vfs, self.requirements) |
|
364 | scmutil.writerequires(self.vfs, self.requirements) | |
365 |
|
365 | |||
366 | def _checknested(self, path): |
|
366 | def _checknested(self, path): | |
367 | """Determine if path is a legal nested repository.""" |
|
367 | """Determine if path is a legal nested repository.""" | |
368 | if not path.startswith(self.root): |
|
368 | if not path.startswith(self.root): | |
369 | return False |
|
369 | return False | |
370 | subpath = path[len(self.root) + 1:] |
|
370 | subpath = path[len(self.root) + 1:] | |
371 | normsubpath = util.pconvert(subpath) |
|
371 | normsubpath = util.pconvert(subpath) | |
372 |
|
372 | |||
373 | # XXX: Checking against the current working copy is wrong in |
|
373 | # XXX: Checking against the current working copy is wrong in | |
374 | # the sense that it can reject things like |
|
374 | # the sense that it can reject things like | |
375 | # |
|
375 | # | |
376 | # $ hg cat -r 10 sub/x.txt |
|
376 | # $ hg cat -r 10 sub/x.txt | |
377 | # |
|
377 | # | |
378 | # if sub/ is no longer a subrepository in the working copy |
|
378 | # if sub/ is no longer a subrepository in the working copy | |
379 | # parent revision. |
|
379 | # parent revision. | |
380 | # |
|
380 | # | |
381 | # However, it can of course also allow things that would have |
|
381 | # However, it can of course also allow things that would have | |
382 | # been rejected before, such as the above cat command if sub/ |
|
382 | # been rejected before, such as the above cat command if sub/ | |
383 | # is a subrepository now, but was a normal directory before. |
|
383 | # is a subrepository now, but was a normal directory before. | |
384 | # The old path auditor would have rejected by mistake since it |
|
384 | # The old path auditor would have rejected by mistake since it | |
385 | # panics when it sees sub/.hg/. |
|
385 | # panics when it sees sub/.hg/. | |
386 | # |
|
386 | # | |
387 | # All in all, checking against the working copy seems sensible |
|
387 | # All in all, checking against the working copy seems sensible | |
388 | # since we want to prevent access to nested repositories on |
|
388 | # since we want to prevent access to nested repositories on | |
389 | # the filesystem *now*. |
|
389 | # the filesystem *now*. | |
390 | ctx = self[None] |
|
390 | ctx = self[None] | |
391 | parts = util.splitpath(subpath) |
|
391 | parts = util.splitpath(subpath) | |
392 | while parts: |
|
392 | while parts: | |
393 | prefix = '/'.join(parts) |
|
393 | prefix = '/'.join(parts) | |
394 | if prefix in ctx.substate: |
|
394 | if prefix in ctx.substate: | |
395 | if prefix == normsubpath: |
|
395 | if prefix == normsubpath: | |
396 | return True |
|
396 | return True | |
397 | else: |
|
397 | else: | |
398 | sub = ctx.sub(prefix) |
|
398 | sub = ctx.sub(prefix) | |
399 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
399 | return sub.checknested(subpath[len(prefix) + 1:]) | |
400 | else: |
|
400 | else: | |
401 | parts.pop() |
|
401 | parts.pop() | |
402 | return False |
|
402 | return False | |
403 |
|
403 | |||
404 | def peer(self): |
|
404 | def peer(self): | |
405 | return localpeer(self) # not cached to avoid reference cycle |
|
405 | return localpeer(self) # not cached to avoid reference cycle | |
406 |
|
406 | |||
407 | def unfiltered(self): |
|
407 | def unfiltered(self): | |
408 | """Return unfiltered version of the repository |
|
408 | """Return unfiltered version of the repository | |
409 |
|
409 | |||
410 | Intended to be overwritten by filtered repo.""" |
|
410 | Intended to be overwritten by filtered repo.""" | |
411 | return self |
|
411 | return self | |
412 |
|
412 | |||
413 | def filtered(self, name): |
|
413 | def filtered(self, name): | |
414 | """Return a filtered version of a repository""" |
|
414 | """Return a filtered version of a repository""" | |
415 | # build a new class with the mixin and the current class |
|
415 | # build a new class with the mixin and the current class | |
416 | # (possibly subclass of the repo) |
|
416 | # (possibly subclass of the repo) | |
417 | class proxycls(repoview.repoview, self.unfiltered().__class__): |
|
417 | class proxycls(repoview.repoview, self.unfiltered().__class__): | |
418 | pass |
|
418 | pass | |
419 | return proxycls(self, name) |
|
419 | return proxycls(self, name) | |
420 |
|
420 | |||
421 | @repofilecache('bookmarks') |
|
421 | @repofilecache('bookmarks') | |
422 | def _bookmarks(self): |
|
422 | def _bookmarks(self): | |
423 | return bookmarks.bmstore(self) |
|
423 | return bookmarks.bmstore(self) | |
424 |
|
424 | |||
425 | @repofilecache('bookmarks.current') |
|
425 | @repofilecache('bookmarks.current') | |
426 | def _activebookmark(self): |
|
426 | def _activebookmark(self): | |
427 | return bookmarks.readactive(self) |
|
427 | return bookmarks.readactive(self) | |
428 |
|
428 | |||
429 | def bookmarkheads(self, bookmark): |
|
429 | def bookmarkheads(self, bookmark): | |
430 | name = bookmark.split('@', 1)[0] |
|
430 | name = bookmark.split('@', 1)[0] | |
431 | heads = [] |
|
431 | heads = [] | |
432 | for mark, n in self._bookmarks.iteritems(): |
|
432 | for mark, n in self._bookmarks.iteritems(): | |
433 | if mark.split('@', 1)[0] == name: |
|
433 | if mark.split('@', 1)[0] == name: | |
434 | heads.append(n) |
|
434 | heads.append(n) | |
435 | return heads |
|
435 | return heads | |
436 |
|
436 | |||
437 | # _phaserevs and _phasesets depend on changelog. what we need is to |
|
437 | # _phaserevs and _phasesets depend on changelog. what we need is to | |
438 | # call _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
438 | # call _phasecache.invalidate() if '00changelog.i' was changed, but it | |
439 | # can't be easily expressed in filecache mechanism. |
|
439 | # can't be easily expressed in filecache mechanism. | |
440 | @storecache('phaseroots', '00changelog.i') |
|
440 | @storecache('phaseroots', '00changelog.i') | |
441 | def _phasecache(self): |
|
441 | def _phasecache(self): | |
442 | return phases.phasecache(self, self._phasedefaults) |
|
442 | return phases.phasecache(self, self._phasedefaults) | |
443 |
|
443 | |||
444 | @storecache('obsstore') |
|
444 | @storecache('obsstore') | |
445 | def obsstore(self): |
|
445 | def obsstore(self): | |
446 | # read default format for new obsstore. |
|
446 | # read default format for new obsstore. | |
447 | # developer config: format.obsstore-version |
|
447 | # developer config: format.obsstore-version | |
448 | defaultformat = self.ui.configint('format', 'obsstore-version', None) |
|
448 | defaultformat = self.ui.configint('format', 'obsstore-version', None) | |
449 | # rely on obsstore class default when possible. |
|
449 | # rely on obsstore class default when possible. | |
450 | kwargs = {} |
|
450 | kwargs = {} | |
451 | if defaultformat is not None: |
|
451 | if defaultformat is not None: | |
452 | kwargs['defaultformat'] = defaultformat |
|
452 | kwargs['defaultformat'] = defaultformat | |
453 | readonly = not obsolete.isenabled(self, obsolete.createmarkersopt) |
|
453 | readonly = not obsolete.isenabled(self, obsolete.createmarkersopt) | |
454 | store = obsolete.obsstore(self.svfs, readonly=readonly, |
|
454 | store = obsolete.obsstore(self.svfs, readonly=readonly, | |
455 | **kwargs) |
|
455 | **kwargs) | |
456 | if store and readonly: |
|
456 | if store and readonly: | |
457 | self.ui.warn( |
|
457 | self.ui.warn( | |
458 | _('obsolete feature not enabled but %i markers found!\n') |
|
458 | _('obsolete feature not enabled but %i markers found!\n') | |
459 | % len(list(store))) |
|
459 | % len(list(store))) | |
460 | return store |
|
460 | return store | |
461 |
|
461 | |||
462 | @storecache('00changelog.i') |
|
462 | @storecache('00changelog.i') | |
463 | def changelog(self): |
|
463 | def changelog(self): | |
464 | c = changelog.changelog(self.svfs) |
|
464 | c = changelog.changelog(self.svfs) | |
465 | if 'HG_PENDING' in os.environ: |
|
465 | if 'HG_PENDING' in os.environ: | |
466 | p = os.environ['HG_PENDING'] |
|
466 | p = os.environ['HG_PENDING'] | |
467 | if p.startswith(self.root): |
|
467 | if p.startswith(self.root): | |
468 | c.readpending('00changelog.i.a') |
|
468 | c.readpending('00changelog.i.a') | |
469 | return c |
|
469 | return c | |
470 |
|
470 | |||
471 | @storecache('00manifest.i') |
|
471 | @storecache('00manifest.i') | |
472 | def manifest(self): |
|
472 | def manifest(self): | |
473 | return manifest.manifest(self.svfs) |
|
473 | return manifest.manifest(self.svfs) | |
474 |
|
474 | |||
475 | def dirlog(self, dir): |
|
475 | def dirlog(self, dir): | |
476 | return self.manifest.dirlog(dir) |
|
476 | return self.manifest.dirlog(dir) | |
477 |
|
477 | |||
478 | @repofilecache('dirstate') |
|
478 | @repofilecache('dirstate') | |
479 | def dirstate(self): |
|
479 | def dirstate(self): | |
480 | return dirstate.dirstate(self.vfs, self.ui, self.root, |
|
480 | return dirstate.dirstate(self.vfs, self.ui, self.root, | |
481 | self._dirstatevalidate) |
|
481 | self._dirstatevalidate) | |
482 |
|
482 | |||
483 | def _dirstatevalidate(self, node): |
|
483 | def _dirstatevalidate(self, node): | |
484 | try: |
|
484 | try: | |
485 | self.changelog.rev(node) |
|
485 | self.changelog.rev(node) | |
486 | return node |
|
486 | return node | |
487 | except error.LookupError: |
|
487 | except error.LookupError: | |
488 | if not self._dirstatevalidatewarned: |
|
488 | if not self._dirstatevalidatewarned: | |
489 | self._dirstatevalidatewarned = True |
|
489 | self._dirstatevalidatewarned = True | |
490 | self.ui.warn(_("warning: ignoring unknown" |
|
490 | self.ui.warn(_("warning: ignoring unknown" | |
491 | " working parent %s!\n") % short(node)) |
|
491 | " working parent %s!\n") % short(node)) | |
492 | return nullid |
|
492 | return nullid | |
493 |
|
493 | |||
494 | def __getitem__(self, changeid): |
|
494 | def __getitem__(self, changeid): | |
495 | if changeid is None or changeid == wdirrev: |
|
495 | if changeid is None or changeid == wdirrev: | |
496 | return context.workingctx(self) |
|
496 | return context.workingctx(self) | |
497 | if isinstance(changeid, slice): |
|
497 | if isinstance(changeid, slice): | |
498 | return [context.changectx(self, i) |
|
498 | return [context.changectx(self, i) | |
499 | for i in xrange(*changeid.indices(len(self))) |
|
499 | for i in xrange(*changeid.indices(len(self))) | |
500 | if i not in self.changelog.filteredrevs] |
|
500 | if i not in self.changelog.filteredrevs] | |
501 | return context.changectx(self, changeid) |
|
501 | return context.changectx(self, changeid) | |
502 |
|
502 | |||
503 | def __contains__(self, changeid): |
|
503 | def __contains__(self, changeid): | |
504 | try: |
|
504 | try: | |
505 | self[changeid] |
|
505 | self[changeid] | |
506 | return True |
|
506 | return True | |
507 | except error.RepoLookupError: |
|
507 | except error.RepoLookupError: | |
508 | return False |
|
508 | return False | |
509 |
|
509 | |||
510 | def __nonzero__(self): |
|
510 | def __nonzero__(self): | |
511 | return True |
|
511 | return True | |
512 |
|
512 | |||
513 | def __len__(self): |
|
513 | def __len__(self): | |
514 | return len(self.changelog) |
|
514 | return len(self.changelog) | |
515 |
|
515 | |||
516 | def __iter__(self): |
|
516 | def __iter__(self): | |
517 | return iter(self.changelog) |
|
517 | return iter(self.changelog) | |
518 |
|
518 | |||
519 | def revs(self, expr, *args): |
|
519 | def revs(self, expr, *args): | |
520 | '''Return a list of revisions matching the given revset''' |
|
520 | '''Return a list of revisions matching the given revset''' | |
521 | expr = revset.formatspec(expr, *args) |
|
521 | expr = revset.formatspec(expr, *args) | |
522 | m = revset.match(None, expr) |
|
522 | m = revset.match(None, expr) | |
523 | return m(self) |
|
523 | return m(self) | |
524 |
|
524 | |||
525 | def set(self, expr, *args): |
|
525 | def set(self, expr, *args): | |
526 | ''' |
|
526 | ''' | |
527 | Yield a context for each matching revision, after doing arg |
|
527 | Yield a context for each matching revision, after doing arg | |
528 | replacement via revset.formatspec |
|
528 | replacement via revset.formatspec | |
529 | ''' |
|
529 | ''' | |
530 | for r in self.revs(expr, *args): |
|
530 | for r in self.revs(expr, *args): | |
531 | yield self[r] |
|
531 | yield self[r] | |
532 |
|
532 | |||
533 | def url(self): |
|
533 | def url(self): | |
534 | return 'file:' + self.root |
|
534 | return 'file:' + self.root | |
535 |
|
535 | |||
536 | def hook(self, name, throw=False, **args): |
|
536 | def hook(self, name, throw=False, **args): | |
537 | """Call a hook, passing this repo instance. |
|
537 | """Call a hook, passing this repo instance. | |
538 |
|
538 | |||
539 | This a convenience method to aid invoking hooks. Extensions likely |
|
539 | This a convenience method to aid invoking hooks. Extensions likely | |
540 | won't call this unless they have registered a custom hook or are |
|
540 | won't call this unless they have registered a custom hook or are | |
541 | replacing code that is expected to call a hook. |
|
541 | replacing code that is expected to call a hook. | |
542 | """ |
|
542 | """ | |
543 | return hook.hook(self.ui, self, name, throw, **args) |
|
543 | return hook.hook(self.ui, self, name, throw, **args) | |
544 |
|
544 | |||
545 | @unfilteredmethod |
|
545 | @unfilteredmethod | |
546 | def _tag(self, names, node, message, local, user, date, extra=None, |
|
546 | def _tag(self, names, node, message, local, user, date, extra=None, | |
547 | editor=False): |
|
547 | editor=False): | |
548 | if isinstance(names, str): |
|
548 | if isinstance(names, str): | |
549 | names = (names,) |
|
549 | names = (names,) | |
550 |
|
550 | |||
551 | branches = self.branchmap() |
|
551 | branches = self.branchmap() | |
552 | for name in names: |
|
552 | for name in names: | |
553 | self.hook('pretag', throw=True, node=hex(node), tag=name, |
|
553 | self.hook('pretag', throw=True, node=hex(node), tag=name, | |
554 | local=local) |
|
554 | local=local) | |
555 | if name in branches: |
|
555 | if name in branches: | |
556 | self.ui.warn(_("warning: tag %s conflicts with existing" |
|
556 | self.ui.warn(_("warning: tag %s conflicts with existing" | |
557 | " branch name\n") % name) |
|
557 | " branch name\n") % name) | |
558 |
|
558 | |||
559 | def writetags(fp, names, munge, prevtags): |
|
559 | def writetags(fp, names, munge, prevtags): | |
560 | fp.seek(0, 2) |
|
560 | fp.seek(0, 2) | |
561 | if prevtags and prevtags[-1] != '\n': |
|
561 | if prevtags and prevtags[-1] != '\n': | |
562 | fp.write('\n') |
|
562 | fp.write('\n') | |
563 | for name in names: |
|
563 | for name in names: | |
564 | if munge: |
|
564 | if munge: | |
565 | m = munge(name) |
|
565 | m = munge(name) | |
566 | else: |
|
566 | else: | |
567 | m = name |
|
567 | m = name | |
568 |
|
568 | |||
569 | if (self._tagscache.tagtypes and |
|
569 | if (self._tagscache.tagtypes and | |
570 | name in self._tagscache.tagtypes): |
|
570 | name in self._tagscache.tagtypes): | |
571 | old = self.tags().get(name, nullid) |
|
571 | old = self.tags().get(name, nullid) | |
572 | fp.write('%s %s\n' % (hex(old), m)) |
|
572 | fp.write('%s %s\n' % (hex(old), m)) | |
573 | fp.write('%s %s\n' % (hex(node), m)) |
|
573 | fp.write('%s %s\n' % (hex(node), m)) | |
574 | fp.close() |
|
574 | fp.close() | |
575 |
|
575 | |||
576 | prevtags = '' |
|
576 | prevtags = '' | |
577 | if local: |
|
577 | if local: | |
578 | try: |
|
578 | try: | |
579 | fp = self.vfs('localtags', 'r+') |
|
579 | fp = self.vfs('localtags', 'r+') | |
580 | except IOError: |
|
580 | except IOError: | |
581 | fp = self.vfs('localtags', 'a') |
|
581 | fp = self.vfs('localtags', 'a') | |
582 | else: |
|
582 | else: | |
583 | prevtags = fp.read() |
|
583 | prevtags = fp.read() | |
584 |
|
584 | |||
585 | # local tags are stored in the current charset |
|
585 | # local tags are stored in the current charset | |
586 | writetags(fp, names, None, prevtags) |
|
586 | writetags(fp, names, None, prevtags) | |
587 | for name in names: |
|
587 | for name in names: | |
588 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
588 | self.hook('tag', node=hex(node), tag=name, local=local) | |
589 | return |
|
589 | return | |
590 |
|
590 | |||
591 | try: |
|
591 | try: | |
592 | fp = self.wfile('.hgtags', 'rb+') |
|
592 | fp = self.wfile('.hgtags', 'rb+') | |
593 | except IOError as e: |
|
593 | except IOError as e: | |
594 | if e.errno != errno.ENOENT: |
|
594 | if e.errno != errno.ENOENT: | |
595 | raise |
|
595 | raise | |
596 | fp = self.wfile('.hgtags', 'ab') |
|
596 | fp = self.wfile('.hgtags', 'ab') | |
597 | else: |
|
597 | else: | |
598 | prevtags = fp.read() |
|
598 | prevtags = fp.read() | |
599 |
|
599 | |||
600 | # committed tags are stored in UTF-8 |
|
600 | # committed tags are stored in UTF-8 | |
601 | writetags(fp, names, encoding.fromlocal, prevtags) |
|
601 | writetags(fp, names, encoding.fromlocal, prevtags) | |
602 |
|
602 | |||
603 | fp.close() |
|
603 | fp.close() | |
604 |
|
604 | |||
605 | self.invalidatecaches() |
|
605 | self.invalidatecaches() | |
606 |
|
606 | |||
607 | if '.hgtags' not in self.dirstate: |
|
607 | if '.hgtags' not in self.dirstate: | |
608 | self[None].add(['.hgtags']) |
|
608 | self[None].add(['.hgtags']) | |
609 |
|
609 | |||
610 | m = matchmod.exact(self.root, '', ['.hgtags']) |
|
610 | m = matchmod.exact(self.root, '', ['.hgtags']) | |
611 | tagnode = self.commit(message, user, date, extra=extra, match=m, |
|
611 | tagnode = self.commit(message, user, date, extra=extra, match=m, | |
612 | editor=editor) |
|
612 | editor=editor) | |
613 |
|
613 | |||
614 | for name in names: |
|
614 | for name in names: | |
615 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
615 | self.hook('tag', node=hex(node), tag=name, local=local) | |
616 |
|
616 | |||
617 | return tagnode |
|
617 | return tagnode | |
618 |
|
618 | |||
619 | def tag(self, names, node, message, local, user, date, editor=False): |
|
619 | def tag(self, names, node, message, local, user, date, editor=False): | |
620 | '''tag a revision with one or more symbolic names. |
|
620 | '''tag a revision with one or more symbolic names. | |
621 |
|
621 | |||
622 | names is a list of strings or, when adding a single tag, names may be a |
|
622 | names is a list of strings or, when adding a single tag, names may be a | |
623 | string. |
|
623 | string. | |
624 |
|
624 | |||
625 | if local is True, the tags are stored in a per-repository file. |
|
625 | if local is True, the tags are stored in a per-repository file. | |
626 | otherwise, they are stored in the .hgtags file, and a new |
|
626 | otherwise, they are stored in the .hgtags file, and a new | |
627 | changeset is committed with the change. |
|
627 | changeset is committed with the change. | |
628 |
|
628 | |||
629 | keyword arguments: |
|
629 | keyword arguments: | |
630 |
|
630 | |||
631 | local: whether to store tags in non-version-controlled file |
|
631 | local: whether to store tags in non-version-controlled file | |
632 | (default False) |
|
632 | (default False) | |
633 |
|
633 | |||
634 | message: commit message to use if committing |
|
634 | message: commit message to use if committing | |
635 |
|
635 | |||
636 | user: name of user to use if committing |
|
636 | user: name of user to use if committing | |
637 |
|
637 | |||
638 | date: date tuple to use if committing''' |
|
638 | date: date tuple to use if committing''' | |
639 |
|
639 | |||
640 | if not local: |
|
640 | if not local: | |
641 | m = matchmod.exact(self.root, '', ['.hgtags']) |
|
641 | m = matchmod.exact(self.root, '', ['.hgtags']) | |
642 | if any(self.status(match=m, unknown=True, ignored=True)): |
|
642 | if any(self.status(match=m, unknown=True, ignored=True)): | |
643 | raise error.Abort(_('working copy of .hgtags is changed'), |
|
643 | raise error.Abort(_('working copy of .hgtags is changed'), | |
644 | hint=_('please commit .hgtags manually')) |
|
644 | hint=_('please commit .hgtags manually')) | |
645 |
|
645 | |||
646 | self.tags() # instantiate the cache |
|
646 | self.tags() # instantiate the cache | |
647 | self._tag(names, node, message, local, user, date, editor=editor) |
|
647 | self._tag(names, node, message, local, user, date, editor=editor) | |
648 |
|
648 | |||
649 | @filteredpropertycache |
|
649 | @filteredpropertycache | |
650 | def _tagscache(self): |
|
650 | def _tagscache(self): | |
651 | '''Returns a tagscache object that contains various tags related |
|
651 | '''Returns a tagscache object that contains various tags related | |
652 | caches.''' |
|
652 | caches.''' | |
653 |
|
653 | |||
654 | # This simplifies its cache management by having one decorated |
|
654 | # This simplifies its cache management by having one decorated | |
655 | # function (this one) and the rest simply fetch things from it. |
|
655 | # function (this one) and the rest simply fetch things from it. | |
656 | class tagscache(object): |
|
656 | class tagscache(object): | |
657 | def __init__(self): |
|
657 | def __init__(self): | |
658 | # These two define the set of tags for this repository. tags |
|
658 | # These two define the set of tags for this repository. tags | |
659 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
659 | # maps tag name to node; tagtypes maps tag name to 'global' or | |
660 | # 'local'. (Global tags are defined by .hgtags across all |
|
660 | # 'local'. (Global tags are defined by .hgtags across all | |
661 | # heads, and local tags are defined in .hg/localtags.) |
|
661 | # heads, and local tags are defined in .hg/localtags.) | |
662 | # They constitute the in-memory cache of tags. |
|
662 | # They constitute the in-memory cache of tags. | |
663 | self.tags = self.tagtypes = None |
|
663 | self.tags = self.tagtypes = None | |
664 |
|
664 | |||
665 | self.nodetagscache = self.tagslist = None |
|
665 | self.nodetagscache = self.tagslist = None | |
666 |
|
666 | |||
667 | cache = tagscache() |
|
667 | cache = tagscache() | |
668 | cache.tags, cache.tagtypes = self._findtags() |
|
668 | cache.tags, cache.tagtypes = self._findtags() | |
669 |
|
669 | |||
670 | return cache |
|
670 | return cache | |
671 |
|
671 | |||
672 | def tags(self): |
|
672 | def tags(self): | |
673 | '''return a mapping of tag to node''' |
|
673 | '''return a mapping of tag to node''' | |
674 | t = {} |
|
674 | t = {} | |
675 | if self.changelog.filteredrevs: |
|
675 | if self.changelog.filteredrevs: | |
676 | tags, tt = self._findtags() |
|
676 | tags, tt = self._findtags() | |
677 | else: |
|
677 | else: | |
678 | tags = self._tagscache.tags |
|
678 | tags = self._tagscache.tags | |
679 | for k, v in tags.iteritems(): |
|
679 | for k, v in tags.iteritems(): | |
680 | try: |
|
680 | try: | |
681 | # ignore tags to unknown nodes |
|
681 | # ignore tags to unknown nodes | |
682 | self.changelog.rev(v) |
|
682 | self.changelog.rev(v) | |
683 | t[k] = v |
|
683 | t[k] = v | |
684 | except (error.LookupError, ValueError): |
|
684 | except (error.LookupError, ValueError): | |
685 | pass |
|
685 | pass | |
686 | return t |
|
686 | return t | |
687 |
|
687 | |||
688 | def _findtags(self): |
|
688 | def _findtags(self): | |
689 | '''Do the hard work of finding tags. Return a pair of dicts |
|
689 | '''Do the hard work of finding tags. Return a pair of dicts | |
690 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
690 | (tags, tagtypes) where tags maps tag name to node, and tagtypes | |
691 | maps tag name to a string like \'global\' or \'local\'. |
|
691 | maps tag name to a string like \'global\' or \'local\'. | |
692 | Subclasses or extensions are free to add their own tags, but |
|
692 | Subclasses or extensions are free to add their own tags, but | |
693 | should be aware that the returned dicts will be retained for the |
|
693 | should be aware that the returned dicts will be retained for the | |
694 | duration of the localrepo object.''' |
|
694 | duration of the localrepo object.''' | |
695 |
|
695 | |||
696 | # XXX what tagtype should subclasses/extensions use? Currently |
|
696 | # XXX what tagtype should subclasses/extensions use? Currently | |
697 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
697 | # mq and bookmarks add tags, but do not set the tagtype at all. | |
698 | # Should each extension invent its own tag type? Should there |
|
698 | # Should each extension invent its own tag type? Should there | |
699 | # be one tagtype for all such "virtual" tags? Or is the status |
|
699 | # be one tagtype for all such "virtual" tags? Or is the status | |
700 | # quo fine? |
|
700 | # quo fine? | |
701 |
|
701 | |||
702 | alltags = {} # map tag name to (node, hist) |
|
702 | alltags = {} # map tag name to (node, hist) | |
703 | tagtypes = {} |
|
703 | tagtypes = {} | |
704 |
|
704 | |||
705 | tagsmod.findglobaltags(self.ui, self, alltags, tagtypes) |
|
705 | tagsmod.findglobaltags(self.ui, self, alltags, tagtypes) | |
706 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
706 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) | |
707 |
|
707 | |||
708 | # Build the return dicts. Have to re-encode tag names because |
|
708 | # Build the return dicts. Have to re-encode tag names because | |
709 | # the tags module always uses UTF-8 (in order not to lose info |
|
709 | # the tags module always uses UTF-8 (in order not to lose info | |
710 | # writing to the cache), but the rest of Mercurial wants them in |
|
710 | # writing to the cache), but the rest of Mercurial wants them in | |
711 | # local encoding. |
|
711 | # local encoding. | |
712 | tags = {} |
|
712 | tags = {} | |
713 | for (name, (node, hist)) in alltags.iteritems(): |
|
713 | for (name, (node, hist)) in alltags.iteritems(): | |
714 | if node != nullid: |
|
714 | if node != nullid: | |
715 | tags[encoding.tolocal(name)] = node |
|
715 | tags[encoding.tolocal(name)] = node | |
716 | tags['tip'] = self.changelog.tip() |
|
716 | tags['tip'] = self.changelog.tip() | |
717 | tagtypes = dict([(encoding.tolocal(name), value) |
|
717 | tagtypes = dict([(encoding.tolocal(name), value) | |
718 | for (name, value) in tagtypes.iteritems()]) |
|
718 | for (name, value) in tagtypes.iteritems()]) | |
719 | return (tags, tagtypes) |
|
719 | return (tags, tagtypes) | |
720 |
|
720 | |||
721 | def tagtype(self, tagname): |
|
721 | def tagtype(self, tagname): | |
722 | ''' |
|
722 | ''' | |
723 | return the type of the given tag. result can be: |
|
723 | return the type of the given tag. result can be: | |
724 |
|
724 | |||
725 | 'local' : a local tag |
|
725 | 'local' : a local tag | |
726 | 'global' : a global tag |
|
726 | 'global' : a global tag | |
727 | None : tag does not exist |
|
727 | None : tag does not exist | |
728 | ''' |
|
728 | ''' | |
729 |
|
729 | |||
730 | return self._tagscache.tagtypes.get(tagname) |
|
730 | return self._tagscache.tagtypes.get(tagname) | |
731 |
|
731 | |||
732 | def tagslist(self): |
|
732 | def tagslist(self): | |
733 | '''return a list of tags ordered by revision''' |
|
733 | '''return a list of tags ordered by revision''' | |
734 | if not self._tagscache.tagslist: |
|
734 | if not self._tagscache.tagslist: | |
735 | l = [] |
|
735 | l = [] | |
736 | for t, n in self.tags().iteritems(): |
|
736 | for t, n in self.tags().iteritems(): | |
737 | l.append((self.changelog.rev(n), t, n)) |
|
737 | l.append((self.changelog.rev(n), t, n)) | |
738 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
738 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] | |
739 |
|
739 | |||
740 | return self._tagscache.tagslist |
|
740 | return self._tagscache.tagslist | |
741 |
|
741 | |||
742 | def nodetags(self, node): |
|
742 | def nodetags(self, node): | |
743 | '''return the tags associated with a node''' |
|
743 | '''return the tags associated with a node''' | |
744 | if not self._tagscache.nodetagscache: |
|
744 | if not self._tagscache.nodetagscache: | |
745 | nodetagscache = {} |
|
745 | nodetagscache = {} | |
746 | for t, n in self._tagscache.tags.iteritems(): |
|
746 | for t, n in self._tagscache.tags.iteritems(): | |
747 | nodetagscache.setdefault(n, []).append(t) |
|
747 | nodetagscache.setdefault(n, []).append(t) | |
748 | for tags in nodetagscache.itervalues(): |
|
748 | for tags in nodetagscache.itervalues(): | |
749 | tags.sort() |
|
749 | tags.sort() | |
750 | self._tagscache.nodetagscache = nodetagscache |
|
750 | self._tagscache.nodetagscache = nodetagscache | |
751 | return self._tagscache.nodetagscache.get(node, []) |
|
751 | return self._tagscache.nodetagscache.get(node, []) | |
752 |
|
752 | |||
753 | def nodebookmarks(self, node): |
|
753 | def nodebookmarks(self, node): | |
754 | marks = [] |
|
754 | marks = [] | |
755 | for bookmark, n in self._bookmarks.iteritems(): |
|
755 | for bookmark, n in self._bookmarks.iteritems(): | |
756 | if n == node: |
|
756 | if n == node: | |
757 | marks.append(bookmark) |
|
757 | marks.append(bookmark) | |
758 | return sorted(marks) |
|
758 | return sorted(marks) | |
759 |
|
759 | |||
760 | def branchmap(self): |
|
760 | def branchmap(self): | |
761 | '''returns a dictionary {branch: [branchheads]} with branchheads |
|
761 | '''returns a dictionary {branch: [branchheads]} with branchheads | |
762 | ordered by increasing revision number''' |
|
762 | ordered by increasing revision number''' | |
763 | branchmap.updatecache(self) |
|
763 | branchmap.updatecache(self) | |
764 | return self._branchcaches[self.filtername] |
|
764 | return self._branchcaches[self.filtername] | |
765 |
|
765 | |||
766 | @unfilteredmethod |
|
766 | @unfilteredmethod | |
767 | def revbranchcache(self): |
|
767 | def revbranchcache(self): | |
768 | if not self._revbranchcache: |
|
768 | if not self._revbranchcache: | |
769 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
769 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) | |
770 | return self._revbranchcache |
|
770 | return self._revbranchcache | |
771 |
|
771 | |||
772 | def branchtip(self, branch, ignoremissing=False): |
|
772 | def branchtip(self, branch, ignoremissing=False): | |
773 | '''return the tip node for a given branch |
|
773 | '''return the tip node for a given branch | |
774 |
|
774 | |||
775 | If ignoremissing is True, then this method will not raise an error. |
|
775 | If ignoremissing is True, then this method will not raise an error. | |
776 | This is helpful for callers that only expect None for a missing branch |
|
776 | This is helpful for callers that only expect None for a missing branch | |
777 | (e.g. namespace). |
|
777 | (e.g. namespace). | |
778 |
|
778 | |||
779 | ''' |
|
779 | ''' | |
780 | try: |
|
780 | try: | |
781 | return self.branchmap().branchtip(branch) |
|
781 | return self.branchmap().branchtip(branch) | |
782 | except KeyError: |
|
782 | except KeyError: | |
783 | if not ignoremissing: |
|
783 | if not ignoremissing: | |
784 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
784 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) | |
785 | else: |
|
785 | else: | |
786 | pass |
|
786 | pass | |
787 |
|
787 | |||
788 | def lookup(self, key): |
|
788 | def lookup(self, key): | |
789 | return self[key].node() |
|
789 | return self[key].node() | |
790 |
|
790 | |||
791 | def lookupbranch(self, key, remote=None): |
|
791 | def lookupbranch(self, key, remote=None): | |
792 | repo = remote or self |
|
792 | repo = remote or self | |
793 | if key in repo.branchmap(): |
|
793 | if key in repo.branchmap(): | |
794 | return key |
|
794 | return key | |
795 |
|
795 | |||
796 | repo = (remote and remote.local()) and remote or self |
|
796 | repo = (remote and remote.local()) and remote or self | |
797 | return repo[key].branch() |
|
797 | return repo[key].branch() | |
798 |
|
798 | |||
799 | def known(self, nodes): |
|
799 | def known(self, nodes): | |
800 | nm = self.changelog.nodemap |
|
800 | nm = self.changelog.nodemap | |
801 | pc = self._phasecache |
|
801 | pc = self._phasecache | |
802 | result = [] |
|
802 | result = [] | |
803 | for n in nodes: |
|
803 | for n in nodes: | |
804 | r = nm.get(n) |
|
804 | r = nm.get(n) | |
805 | resp = not (r is None or pc.phase(self, r) >= phases.secret) |
|
805 | resp = not (r is None or pc.phase(self, r) >= phases.secret) | |
806 | result.append(resp) |
|
806 | result.append(resp) | |
807 | return result |
|
807 | return result | |
808 |
|
808 | |||
809 | def local(self): |
|
809 | def local(self): | |
810 | return self |
|
810 | return self | |
811 |
|
811 | |||
812 | def publishing(self): |
|
812 | def publishing(self): | |
813 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
813 | # it's safe (and desirable) to trust the publish flag unconditionally | |
814 | # so that we don't finalize changes shared between users via ssh or nfs |
|
814 | # so that we don't finalize changes shared between users via ssh or nfs | |
815 | return self.ui.configbool('phases', 'publish', True, untrusted=True) |
|
815 | return self.ui.configbool('phases', 'publish', True, untrusted=True) | |
816 |
|
816 | |||
817 | def cancopy(self): |
|
817 | def cancopy(self): | |
818 | # so statichttprepo's override of local() works |
|
818 | # so statichttprepo's override of local() works | |
819 | if not self.local(): |
|
819 | if not self.local(): | |
820 | return False |
|
820 | return False | |
821 | if not self.publishing(): |
|
821 | if not self.publishing(): | |
822 | return True |
|
822 | return True | |
823 | # if publishing we can't copy if there is filtered content |
|
823 | # if publishing we can't copy if there is filtered content | |
824 | return not self.filtered('visible').changelog.filteredrevs |
|
824 | return not self.filtered('visible').changelog.filteredrevs | |
825 |
|
825 | |||
826 | def shared(self): |
|
826 | def shared(self): | |
827 | '''the type of shared repository (None if not shared)''' |
|
827 | '''the type of shared repository (None if not shared)''' | |
828 | if self.sharedpath != self.path: |
|
828 | if self.sharedpath != self.path: | |
829 | return 'store' |
|
829 | return 'store' | |
830 | return None |
|
830 | return None | |
831 |
|
831 | |||
832 | def join(self, f, *insidef): |
|
832 | def join(self, f, *insidef): | |
833 | return self.vfs.join(os.path.join(f, *insidef)) |
|
833 | return self.vfs.join(os.path.join(f, *insidef)) | |
834 |
|
834 | |||
835 | def wjoin(self, f, *insidef): |
|
835 | def wjoin(self, f, *insidef): | |
836 | return self.vfs.reljoin(self.root, f, *insidef) |
|
836 | return self.vfs.reljoin(self.root, f, *insidef) | |
837 |
|
837 | |||
838 | def file(self, f): |
|
838 | def file(self, f): | |
839 | if f[0] == '/': |
|
839 | if f[0] == '/': | |
840 | f = f[1:] |
|
840 | f = f[1:] | |
841 | return filelog.filelog(self.svfs, f) |
|
841 | return filelog.filelog(self.svfs, f) | |
842 |
|
842 | |||
843 | def changectx(self, changeid): |
|
843 | def changectx(self, changeid): | |
844 | return self[changeid] |
|
844 | return self[changeid] | |
845 |
|
845 | |||
846 | def parents(self, changeid=None): |
|
846 | def parents(self, changeid=None): | |
847 | '''get list of changectxs for parents of changeid''' |
|
847 | '''get list of changectxs for parents of changeid''' | |
848 | return self[changeid].parents() |
|
848 | return self[changeid].parents() | |
849 |
|
849 | |||
850 | def setparents(self, p1, p2=nullid): |
|
850 | def setparents(self, p1, p2=nullid): | |
851 | self.dirstate.beginparentchange() |
|
851 | self.dirstate.beginparentchange() | |
852 | copies = self.dirstate.setparents(p1, p2) |
|
852 | copies = self.dirstate.setparents(p1, p2) | |
853 | pctx = self[p1] |
|
853 | pctx = self[p1] | |
854 | if copies: |
|
854 | if copies: | |
855 | # Adjust copy records, the dirstate cannot do it, it |
|
855 | # Adjust copy records, the dirstate cannot do it, it | |
856 | # requires access to parents manifests. Preserve them |
|
856 | # requires access to parents manifests. Preserve them | |
857 | # only for entries added to first parent. |
|
857 | # only for entries added to first parent. | |
858 | for f in copies: |
|
858 | for f in copies: | |
859 | if f not in pctx and copies[f] in pctx: |
|
859 | if f not in pctx and copies[f] in pctx: | |
860 | self.dirstate.copy(copies[f], f) |
|
860 | self.dirstate.copy(copies[f], f) | |
861 | if p2 == nullid: |
|
861 | if p2 == nullid: | |
862 | for f, s in sorted(self.dirstate.copies().items()): |
|
862 | for f, s in sorted(self.dirstate.copies().items()): | |
863 | if f not in pctx and s not in pctx: |
|
863 | if f not in pctx and s not in pctx: | |
864 | self.dirstate.copy(None, f) |
|
864 | self.dirstate.copy(None, f) | |
865 | self.dirstate.endparentchange() |
|
865 | self.dirstate.endparentchange() | |
866 |
|
866 | |||
867 | def filectx(self, path, changeid=None, fileid=None): |
|
867 | def filectx(self, path, changeid=None, fileid=None): | |
868 | """changeid can be a changeset revision, node, or tag. |
|
868 | """changeid can be a changeset revision, node, or tag. | |
869 | fileid can be a file revision or node.""" |
|
869 | fileid can be a file revision or node.""" | |
870 | return context.filectx(self, path, changeid, fileid) |
|
870 | return context.filectx(self, path, changeid, fileid) | |
871 |
|
871 | |||
872 | def getcwd(self): |
|
872 | def getcwd(self): | |
873 | return self.dirstate.getcwd() |
|
873 | return self.dirstate.getcwd() | |
874 |
|
874 | |||
875 | def pathto(self, f, cwd=None): |
|
875 | def pathto(self, f, cwd=None): | |
876 | return self.dirstate.pathto(f, cwd) |
|
876 | return self.dirstate.pathto(f, cwd) | |
877 |
|
877 | |||
878 | def wfile(self, f, mode='r'): |
|
878 | def wfile(self, f, mode='r'): | |
879 | return self.wvfs(f, mode) |
|
879 | return self.wvfs(f, mode) | |
880 |
|
880 | |||
881 | def _link(self, f): |
|
881 | def _link(self, f): | |
882 | return self.wvfs.islink(f) |
|
882 | return self.wvfs.islink(f) | |
883 |
|
883 | |||
884 | def _loadfilter(self, filter): |
|
884 | def _loadfilter(self, filter): | |
885 | if filter not in self.filterpats: |
|
885 | if filter not in self.filterpats: | |
886 | l = [] |
|
886 | l = [] | |
887 | for pat, cmd in self.ui.configitems(filter): |
|
887 | for pat, cmd in self.ui.configitems(filter): | |
888 | if cmd == '!': |
|
888 | if cmd == '!': | |
889 | continue |
|
889 | continue | |
890 | mf = matchmod.match(self.root, '', [pat]) |
|
890 | mf = matchmod.match(self.root, '', [pat]) | |
891 | fn = None |
|
891 | fn = None | |
892 | params = cmd |
|
892 | params = cmd | |
893 | for name, filterfn in self._datafilters.iteritems(): |
|
893 | for name, filterfn in self._datafilters.iteritems(): | |
894 | if cmd.startswith(name): |
|
894 | if cmd.startswith(name): | |
895 | fn = filterfn |
|
895 | fn = filterfn | |
896 | params = cmd[len(name):].lstrip() |
|
896 | params = cmd[len(name):].lstrip() | |
897 | break |
|
897 | break | |
898 | if not fn: |
|
898 | if not fn: | |
899 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
899 | fn = lambda s, c, **kwargs: util.filter(s, c) | |
900 | # Wrap old filters not supporting keyword arguments |
|
900 | # Wrap old filters not supporting keyword arguments | |
901 | if not inspect.getargspec(fn)[2]: |
|
901 | if not inspect.getargspec(fn)[2]: | |
902 | oldfn = fn |
|
902 | oldfn = fn | |
903 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
903 | fn = lambda s, c, **kwargs: oldfn(s, c) | |
904 | l.append((mf, fn, params)) |
|
904 | l.append((mf, fn, params)) | |
905 | self.filterpats[filter] = l |
|
905 | self.filterpats[filter] = l | |
906 | return self.filterpats[filter] |
|
906 | return self.filterpats[filter] | |
907 |
|
907 | |||
908 | def _filter(self, filterpats, filename, data): |
|
908 | def _filter(self, filterpats, filename, data): | |
909 | for mf, fn, cmd in filterpats: |
|
909 | for mf, fn, cmd in filterpats: | |
910 | if mf(filename): |
|
910 | if mf(filename): | |
911 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
911 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) | |
912 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
912 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) | |
913 | break |
|
913 | break | |
914 |
|
914 | |||
915 | return data |
|
915 | return data | |
916 |
|
916 | |||
917 | @unfilteredpropertycache |
|
917 | @unfilteredpropertycache | |
918 | def _encodefilterpats(self): |
|
918 | def _encodefilterpats(self): | |
919 | return self._loadfilter('encode') |
|
919 | return self._loadfilter('encode') | |
920 |
|
920 | |||
921 | @unfilteredpropertycache |
|
921 | @unfilteredpropertycache | |
922 | def _decodefilterpats(self): |
|
922 | def _decodefilterpats(self): | |
923 | return self._loadfilter('decode') |
|
923 | return self._loadfilter('decode') | |
924 |
|
924 | |||
925 | def adddatafilter(self, name, filter): |
|
925 | def adddatafilter(self, name, filter): | |
926 | self._datafilters[name] = filter |
|
926 | self._datafilters[name] = filter | |
927 |
|
927 | |||
928 | def wread(self, filename): |
|
928 | def wread(self, filename): | |
929 | if self._link(filename): |
|
929 | if self._link(filename): | |
930 | data = self.wvfs.readlink(filename) |
|
930 | data = self.wvfs.readlink(filename) | |
931 | else: |
|
931 | else: | |
932 | data = self.wvfs.read(filename) |
|
932 | data = self.wvfs.read(filename) | |
933 | return self._filter(self._encodefilterpats, filename, data) |
|
933 | return self._filter(self._encodefilterpats, filename, data) | |
934 |
|
934 | |||
935 | def wwrite(self, filename, data, flags): |
|
935 | def wwrite(self, filename, data, flags): | |
936 | """write ``data`` into ``filename`` in the working directory |
|
936 | """write ``data`` into ``filename`` in the working directory | |
937 |
|
937 | |||
938 | This returns length of written (maybe decoded) data. |
|
938 | This returns length of written (maybe decoded) data. | |
939 | """ |
|
939 | """ | |
940 | data = self._filter(self._decodefilterpats, filename, data) |
|
940 | data = self._filter(self._decodefilterpats, filename, data) | |
941 | if 'l' in flags: |
|
941 | if 'l' in flags: | |
942 | self.wvfs.symlink(data, filename) |
|
942 | self.wvfs.symlink(data, filename) | |
943 | else: |
|
943 | else: | |
944 | self.wvfs.write(filename, data) |
|
944 | self.wvfs.write(filename, data) | |
945 | if 'x' in flags: |
|
945 | if 'x' in flags: | |
946 | self.wvfs.setflags(filename, False, True) |
|
946 | self.wvfs.setflags(filename, False, True) | |
947 | return len(data) |
|
947 | return len(data) | |
948 |
|
948 | |||
949 | def wwritedata(self, filename, data): |
|
949 | def wwritedata(self, filename, data): | |
950 | return self._filter(self._decodefilterpats, filename, data) |
|
950 | return self._filter(self._decodefilterpats, filename, data) | |
951 |
|
951 | |||
952 | def currenttransaction(self): |
|
952 | def currenttransaction(self): | |
953 | """return the current transaction or None if non exists""" |
|
953 | """return the current transaction or None if non exists""" | |
954 | if self._transref: |
|
954 | if self._transref: | |
955 | tr = self._transref() |
|
955 | tr = self._transref() | |
956 | else: |
|
956 | else: | |
957 | tr = None |
|
957 | tr = None | |
958 |
|
958 | |||
959 | if tr and tr.running(): |
|
959 | if tr and tr.running(): | |
960 | return tr |
|
960 | return tr | |
961 | return None |
|
961 | return None | |
962 |
|
962 | |||
963 | def transaction(self, desc, report=None): |
|
963 | def transaction(self, desc, report=None): | |
964 | if (self.ui.configbool('devel', 'all-warnings') |
|
964 | if (self.ui.configbool('devel', 'all-warnings') | |
965 | or self.ui.configbool('devel', 'check-locks')): |
|
965 | or self.ui.configbool('devel', 'check-locks')): | |
966 | l = self._lockref and self._lockref() |
|
966 | l = self._lockref and self._lockref() | |
967 | if l is None or not l.held: |
|
967 | if l is None or not l.held: | |
968 | self.ui.develwarn('transaction with no lock') |
|
968 | self.ui.develwarn('transaction with no lock') | |
969 | tr = self.currenttransaction() |
|
969 | tr = self.currenttransaction() | |
970 | if tr is not None: |
|
970 | if tr is not None: | |
971 | return tr.nest() |
|
971 | return tr.nest() | |
972 |
|
972 | |||
973 | # abort here if the journal already exists |
|
973 | # abort here if the journal already exists | |
974 | if self.svfs.exists("journal"): |
|
974 | if self.svfs.exists("journal"): | |
975 | raise error.RepoError( |
|
975 | raise error.RepoError( | |
976 | _("abandoned transaction found"), |
|
976 | _("abandoned transaction found"), | |
977 | hint=_("run 'hg recover' to clean up transaction")) |
|
977 | hint=_("run 'hg recover' to clean up transaction")) | |
978 |
|
978 | |||
979 | # make journal.dirstate contain in-memory changes at this point |
|
979 | # make journal.dirstate contain in-memory changes at this point | |
980 | self.dirstate.write() |
|
980 | self.dirstate.write() | |
981 |
|
981 | |||
982 | idbase = "%.40f#%f" % (random.random(), time.time()) |
|
982 | idbase = "%.40f#%f" % (random.random(), time.time()) | |
983 | txnid = 'TXN:' + util.sha1(idbase).hexdigest() |
|
983 | txnid = 'TXN:' + util.sha1(idbase).hexdigest() | |
984 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
984 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) | |
985 |
|
985 | |||
986 | self._writejournal(desc) |
|
986 | self._writejournal(desc) | |
987 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
987 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] | |
988 | if report: |
|
988 | if report: | |
989 | rp = report |
|
989 | rp = report | |
990 | else: |
|
990 | else: | |
991 | rp = self.ui.warn |
|
991 | rp = self.ui.warn | |
992 | vfsmap = {'plain': self.vfs} # root of .hg/ |
|
992 | vfsmap = {'plain': self.vfs} # root of .hg/ | |
993 | # we must avoid cyclic reference between repo and transaction. |
|
993 | # we must avoid cyclic reference between repo and transaction. | |
994 | reporef = weakref.ref(self) |
|
994 | reporef = weakref.ref(self) | |
995 | def validate(tr): |
|
995 | def validate(tr): | |
996 | """will run pre-closing hooks""" |
|
996 | """will run pre-closing hooks""" | |
997 | pending = lambda: tr.writepending() and self.root or "" |
|
997 | pending = lambda: tr.writepending() and self.root or "" | |
998 | reporef().hook('pretxnclose', throw=True, pending=pending, |
|
998 | reporef().hook('pretxnclose', throw=True, pending=pending, | |
999 | txnname=desc, **tr.hookargs) |
|
999 | txnname=desc, **tr.hookargs) | |
1000 | def releasefn(tr, success): |
|
1000 | def releasefn(tr, success): | |
1001 | repo = reporef() |
|
1001 | repo = reporef() | |
1002 | if success: |
|
1002 | if success: | |
1003 | repo.dirstate.write() |
|
1003 | repo.dirstate.write() | |
1004 | else: |
|
1004 | else: | |
1005 | # prevent in-memory changes from being written out at |
|
1005 | # prevent in-memory changes from being written out at | |
1006 | # the end of outer wlock scope or so |
|
1006 | # the end of outer wlock scope or so | |
1007 | repo.dirstate.invalidate() |
|
1007 | repo.dirstate.invalidate() | |
1008 |
|
1008 | |||
1009 | # discard all changes (including ones already written |
|
1009 | # discard all changes (including ones already written | |
1010 | # out) in this transaction |
|
1010 | # out) in this transaction | |
1011 | repo.vfs.rename('journal.dirstate', 'dirstate') |
|
1011 | repo.vfs.rename('journal.dirstate', 'dirstate') | |
1012 |
|
1012 | |||
1013 | tr = transaction.transaction(rp, self.svfs, vfsmap, |
|
1013 | tr = transaction.transaction(rp, self.svfs, vfsmap, | |
1014 | "journal", |
|
1014 | "journal", | |
1015 | "undo", |
|
1015 | "undo", | |
1016 | aftertrans(renames), |
|
1016 | aftertrans(renames), | |
1017 | self.store.createmode, |
|
1017 | self.store.createmode, | |
1018 | validator=validate, |
|
1018 | validator=validate, | |
1019 | releasefn=releasefn) |
|
1019 | releasefn=releasefn) | |
1020 |
|
1020 | |||
1021 | tr.hookargs['txnid'] = txnid |
|
1021 | tr.hookargs['txnid'] = txnid | |
1022 | # note: writing the fncache only during finalize mean that the file is |
|
1022 | # note: writing the fncache only during finalize mean that the file is | |
1023 | # outdated when running hooks. As fncache is used for streaming clone, |
|
1023 | # outdated when running hooks. As fncache is used for streaming clone, | |
1024 | # this is not expected to break anything that happen during the hooks. |
|
1024 | # this is not expected to break anything that happen during the hooks. | |
1025 | tr.addfinalize('flush-fncache', self.store.write) |
|
1025 | tr.addfinalize('flush-fncache', self.store.write) | |
1026 | def txnclosehook(tr2): |
|
1026 | def txnclosehook(tr2): | |
1027 | """To be run if transaction is successful, will schedule a hook run |
|
1027 | """To be run if transaction is successful, will schedule a hook run | |
1028 | """ |
|
1028 | """ | |
1029 | def hook(): |
|
1029 | def hook(): | |
1030 | reporef().hook('txnclose', throw=False, txnname=desc, |
|
1030 | reporef().hook('txnclose', throw=False, txnname=desc, | |
1031 | **tr2.hookargs) |
|
1031 | **tr2.hookargs) | |
1032 | reporef()._afterlock(hook) |
|
1032 | reporef()._afterlock(hook) | |
1033 | tr.addfinalize('txnclose-hook', txnclosehook) |
|
1033 | tr.addfinalize('txnclose-hook', txnclosehook) | |
1034 | def txnaborthook(tr2): |
|
1034 | def txnaborthook(tr2): | |
1035 | """To be run if transaction is aborted |
|
1035 | """To be run if transaction is aborted | |
1036 | """ |
|
1036 | """ | |
1037 | reporef().hook('txnabort', throw=False, txnname=desc, |
|
1037 | reporef().hook('txnabort', throw=False, txnname=desc, | |
1038 | **tr2.hookargs) |
|
1038 | **tr2.hookargs) | |
1039 | tr.addabort('txnabort-hook', txnaborthook) |
|
1039 | tr.addabort('txnabort-hook', txnaborthook) | |
1040 | # avoid eager cache invalidation. in-memory data should be identical |
|
1040 | # avoid eager cache invalidation. in-memory data should be identical | |
1041 | # to stored data if transaction has no error. |
|
1041 | # to stored data if transaction has no error. | |
1042 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) |
|
1042 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) | |
1043 | self._transref = weakref.ref(tr) |
|
1043 | self._transref = weakref.ref(tr) | |
1044 | return tr |
|
1044 | return tr | |
1045 |
|
1045 | |||
1046 | def _journalfiles(self): |
|
1046 | def _journalfiles(self): | |
1047 | return ((self.svfs, 'journal'), |
|
1047 | return ((self.svfs, 'journal'), | |
1048 | (self.vfs, 'journal.dirstate'), |
|
1048 | (self.vfs, 'journal.dirstate'), | |
1049 | (self.vfs, 'journal.branch'), |
|
1049 | (self.vfs, 'journal.branch'), | |
1050 | (self.vfs, 'journal.desc'), |
|
1050 | (self.vfs, 'journal.desc'), | |
1051 | (self.vfs, 'journal.bookmarks'), |
|
1051 | (self.vfs, 'journal.bookmarks'), | |
1052 | (self.svfs, 'journal.phaseroots')) |
|
1052 | (self.svfs, 'journal.phaseroots')) | |
1053 |
|
1053 | |||
1054 | def undofiles(self): |
|
1054 | def undofiles(self): | |
1055 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
1055 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] | |
1056 |
|
1056 | |||
1057 | def _writejournal(self, desc): |
|
1057 | def _writejournal(self, desc): | |
1058 | self.vfs.write("journal.dirstate", |
|
1058 | self.vfs.write("journal.dirstate", | |
1059 | self.vfs.tryread("dirstate")) |
|
1059 | self.vfs.tryread("dirstate")) | |
1060 | self.vfs.write("journal.branch", |
|
1060 | self.vfs.write("journal.branch", | |
1061 | encoding.fromlocal(self.dirstate.branch())) |
|
1061 | encoding.fromlocal(self.dirstate.branch())) | |
1062 | self.vfs.write("journal.desc", |
|
1062 | self.vfs.write("journal.desc", | |
1063 | "%d\n%s\n" % (len(self), desc)) |
|
1063 | "%d\n%s\n" % (len(self), desc)) | |
1064 | self.vfs.write("journal.bookmarks", |
|
1064 | self.vfs.write("journal.bookmarks", | |
1065 | self.vfs.tryread("bookmarks")) |
|
1065 | self.vfs.tryread("bookmarks")) | |
1066 | self.svfs.write("journal.phaseroots", |
|
1066 | self.svfs.write("journal.phaseroots", | |
1067 | self.svfs.tryread("phaseroots")) |
|
1067 | self.svfs.tryread("phaseroots")) | |
1068 |
|
1068 | |||
1069 | def recover(self): |
|
1069 | def recover(self): | |
1070 | lock = self.lock() |
|
1070 | lock = self.lock() | |
1071 | try: |
|
1071 | try: | |
1072 | if self.svfs.exists("journal"): |
|
1072 | if self.svfs.exists("journal"): | |
1073 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
1073 | self.ui.status(_("rolling back interrupted transaction\n")) | |
1074 | vfsmap = {'': self.svfs, |
|
1074 | vfsmap = {'': self.svfs, | |
1075 | 'plain': self.vfs,} |
|
1075 | 'plain': self.vfs,} | |
1076 | transaction.rollback(self.svfs, vfsmap, "journal", |
|
1076 | transaction.rollback(self.svfs, vfsmap, "journal", | |
1077 | self.ui.warn) |
|
1077 | self.ui.warn) | |
1078 | self.invalidate() |
|
1078 | self.invalidate() | |
1079 | return True |
|
1079 | return True | |
1080 | else: |
|
1080 | else: | |
1081 | self.ui.warn(_("no interrupted transaction available\n")) |
|
1081 | self.ui.warn(_("no interrupted transaction available\n")) | |
1082 | return False |
|
1082 | return False | |
1083 | finally: |
|
1083 | finally: | |
1084 | lock.release() |
|
1084 | lock.release() | |
1085 |
|
1085 | |||
1086 | def rollback(self, dryrun=False, force=False): |
|
1086 | def rollback(self, dryrun=False, force=False): | |
1087 | wlock = lock = None |
|
1087 | wlock = lock = dsguard = None | |
1088 | try: |
|
1088 | try: | |
1089 | wlock = self.wlock() |
|
1089 | wlock = self.wlock() | |
1090 | lock = self.lock() |
|
1090 | lock = self.lock() | |
1091 | if self.svfs.exists("undo"): |
|
1091 | if self.svfs.exists("undo"): | |
1092 | return self._rollback(dryrun, force) |
|
1092 | dsguard = cmdutil.dirstateguard(self, 'rollback') | |
|
1093 | ||||
|
1094 | return self._rollback(dryrun, force, dsguard) | |||
1093 | else: |
|
1095 | else: | |
1094 | self.ui.warn(_("no rollback information available\n")) |
|
1096 | self.ui.warn(_("no rollback information available\n")) | |
1095 | return 1 |
|
1097 | return 1 | |
1096 | finally: |
|
1098 | finally: | |
1097 | release(lock, wlock) |
|
1099 | release(dsguard, lock, wlock) | |
1098 |
|
1100 | |||
1099 | @unfilteredmethod # Until we get smarter cache management |
|
1101 | @unfilteredmethod # Until we get smarter cache management | |
1100 | def _rollback(self, dryrun, force): |
|
1102 | def _rollback(self, dryrun, force, dsguard): | |
1101 | ui = self.ui |
|
1103 | ui = self.ui | |
1102 | try: |
|
1104 | try: | |
1103 | args = self.vfs.read('undo.desc').splitlines() |
|
1105 | args = self.vfs.read('undo.desc').splitlines() | |
1104 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
1106 | (oldlen, desc, detail) = (int(args[0]), args[1], None) | |
1105 | if len(args) >= 3: |
|
1107 | if len(args) >= 3: | |
1106 | detail = args[2] |
|
1108 | detail = args[2] | |
1107 | oldtip = oldlen - 1 |
|
1109 | oldtip = oldlen - 1 | |
1108 |
|
1110 | |||
1109 | if detail and ui.verbose: |
|
1111 | if detail and ui.verbose: | |
1110 | msg = (_('repository tip rolled back to revision %s' |
|
1112 | msg = (_('repository tip rolled back to revision %s' | |
1111 | ' (undo %s: %s)\n') |
|
1113 | ' (undo %s: %s)\n') | |
1112 | % (oldtip, desc, detail)) |
|
1114 | % (oldtip, desc, detail)) | |
1113 | else: |
|
1115 | else: | |
1114 | msg = (_('repository tip rolled back to revision %s' |
|
1116 | msg = (_('repository tip rolled back to revision %s' | |
1115 | ' (undo %s)\n') |
|
1117 | ' (undo %s)\n') | |
1116 | % (oldtip, desc)) |
|
1118 | % (oldtip, desc)) | |
1117 | except IOError: |
|
1119 | except IOError: | |
1118 | msg = _('rolling back unknown transaction\n') |
|
1120 | msg = _('rolling back unknown transaction\n') | |
1119 | desc = None |
|
1121 | desc = None | |
1120 |
|
1122 | |||
1121 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
1123 | if not force and self['.'] != self['tip'] and desc == 'commit': | |
1122 | raise error.Abort( |
|
1124 | raise error.Abort( | |
1123 | _('rollback of last commit while not checked out ' |
|
1125 | _('rollback of last commit while not checked out ' | |
1124 | 'may lose data'), hint=_('use -f to force')) |
|
1126 | 'may lose data'), hint=_('use -f to force')) | |
1125 |
|
1127 | |||
1126 | ui.status(msg) |
|
1128 | ui.status(msg) | |
1127 | if dryrun: |
|
1129 | if dryrun: | |
1128 | return 0 |
|
1130 | return 0 | |
1129 |
|
1131 | |||
1130 | parents = self.dirstate.parents() |
|
1132 | parents = self.dirstate.parents() | |
1131 | self.destroying() |
|
1133 | self.destroying() | |
1132 | vfsmap = {'plain': self.vfs, '': self.svfs} |
|
1134 | vfsmap = {'plain': self.vfs, '': self.svfs} | |
1133 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn) |
|
1135 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn) | |
1134 | if self.vfs.exists('undo.bookmarks'): |
|
1136 | if self.vfs.exists('undo.bookmarks'): | |
1135 | self.vfs.rename('undo.bookmarks', 'bookmarks') |
|
1137 | self.vfs.rename('undo.bookmarks', 'bookmarks') | |
1136 | if self.svfs.exists('undo.phaseroots'): |
|
1138 | if self.svfs.exists('undo.phaseroots'): | |
1137 | self.svfs.rename('undo.phaseroots', 'phaseroots') |
|
1139 | self.svfs.rename('undo.phaseroots', 'phaseroots') | |
1138 | self.invalidate() |
|
1140 | self.invalidate() | |
1139 |
|
1141 | |||
1140 | parentgone = (parents[0] not in self.changelog.nodemap or |
|
1142 | parentgone = (parents[0] not in self.changelog.nodemap or | |
1141 | parents[1] not in self.changelog.nodemap) |
|
1143 | parents[1] not in self.changelog.nodemap) | |
1142 | if parentgone: |
|
1144 | if parentgone: | |
|
1145 | # prevent dirstateguard from overwriting already restored one | |||
|
1146 | dsguard.close() | |||
|
1147 | ||||
1143 | self.vfs.rename('undo.dirstate', 'dirstate') |
|
1148 | self.vfs.rename('undo.dirstate', 'dirstate') | |
1144 | try: |
|
1149 | try: | |
1145 | branch = self.vfs.read('undo.branch') |
|
1150 | branch = self.vfs.read('undo.branch') | |
1146 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
1151 | self.dirstate.setbranch(encoding.tolocal(branch)) | |
1147 | except IOError: |
|
1152 | except IOError: | |
1148 | ui.warn(_('named branch could not be reset: ' |
|
1153 | ui.warn(_('named branch could not be reset: ' | |
1149 | 'current branch is still \'%s\'\n') |
|
1154 | 'current branch is still \'%s\'\n') | |
1150 | % self.dirstate.branch()) |
|
1155 | % self.dirstate.branch()) | |
1151 |
|
1156 | |||
1152 | self.dirstate.invalidate() |
|
1157 | self.dirstate.invalidate() | |
1153 | parents = tuple([p.rev() for p in self.parents()]) |
|
1158 | parents = tuple([p.rev() for p in self.parents()]) | |
1154 | if len(parents) > 1: |
|
1159 | if len(parents) > 1: | |
1155 | ui.status(_('working directory now based on ' |
|
1160 | ui.status(_('working directory now based on ' | |
1156 | 'revisions %d and %d\n') % parents) |
|
1161 | 'revisions %d and %d\n') % parents) | |
1157 | else: |
|
1162 | else: | |
1158 | ui.status(_('working directory now based on ' |
|
1163 | ui.status(_('working directory now based on ' | |
1159 | 'revision %d\n') % parents) |
|
1164 | 'revision %d\n') % parents) | |
1160 | ms = mergemod.mergestate(self) |
|
1165 | ms = mergemod.mergestate(self) | |
1161 | ms.reset(self['.'].node()) |
|
1166 | ms.reset(self['.'].node()) | |
1162 |
|
1167 | |||
1163 | # TODO: if we know which new heads may result from this rollback, pass |
|
1168 | # TODO: if we know which new heads may result from this rollback, pass | |
1164 | # them to destroy(), which will prevent the branchhead cache from being |
|
1169 | # them to destroy(), which will prevent the branchhead cache from being | |
1165 | # invalidated. |
|
1170 | # invalidated. | |
1166 | self.destroyed() |
|
1171 | self.destroyed() | |
1167 | return 0 |
|
1172 | return 0 | |
1168 |
|
1173 | |||
1169 | def invalidatecaches(self): |
|
1174 | def invalidatecaches(self): | |
1170 |
|
1175 | |||
1171 | if '_tagscache' in vars(self): |
|
1176 | if '_tagscache' in vars(self): | |
1172 | # can't use delattr on proxy |
|
1177 | # can't use delattr on proxy | |
1173 | del self.__dict__['_tagscache'] |
|
1178 | del self.__dict__['_tagscache'] | |
1174 |
|
1179 | |||
1175 | self.unfiltered()._branchcaches.clear() |
|
1180 | self.unfiltered()._branchcaches.clear() | |
1176 | self.invalidatevolatilesets() |
|
1181 | self.invalidatevolatilesets() | |
1177 |
|
1182 | |||
1178 | def invalidatevolatilesets(self): |
|
1183 | def invalidatevolatilesets(self): | |
1179 | self.filteredrevcache.clear() |
|
1184 | self.filteredrevcache.clear() | |
1180 | obsolete.clearobscaches(self) |
|
1185 | obsolete.clearobscaches(self) | |
1181 |
|
1186 | |||
1182 | def invalidatedirstate(self): |
|
1187 | def invalidatedirstate(self): | |
1183 | '''Invalidates the dirstate, causing the next call to dirstate |
|
1188 | '''Invalidates the dirstate, causing the next call to dirstate | |
1184 | to check if it was modified since the last time it was read, |
|
1189 | to check if it was modified since the last time it was read, | |
1185 | rereading it if it has. |
|
1190 | rereading it if it has. | |
1186 |
|
1191 | |||
1187 | This is different to dirstate.invalidate() that it doesn't always |
|
1192 | This is different to dirstate.invalidate() that it doesn't always | |
1188 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
1193 | rereads the dirstate. Use dirstate.invalidate() if you want to | |
1189 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
1194 | explicitly read the dirstate again (i.e. restoring it to a previous | |
1190 | known good state).''' |
|
1195 | known good state).''' | |
1191 | if hasunfilteredcache(self, 'dirstate'): |
|
1196 | if hasunfilteredcache(self, 'dirstate'): | |
1192 | for k in self.dirstate._filecache: |
|
1197 | for k in self.dirstate._filecache: | |
1193 | try: |
|
1198 | try: | |
1194 | delattr(self.dirstate, k) |
|
1199 | delattr(self.dirstate, k) | |
1195 | except AttributeError: |
|
1200 | except AttributeError: | |
1196 | pass |
|
1201 | pass | |
1197 | delattr(self.unfiltered(), 'dirstate') |
|
1202 | delattr(self.unfiltered(), 'dirstate') | |
1198 |
|
1203 | |||
1199 | def invalidate(self): |
|
1204 | def invalidate(self): | |
1200 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
1205 | unfiltered = self.unfiltered() # all file caches are stored unfiltered | |
1201 | for k in self._filecache: |
|
1206 | for k in self._filecache: | |
1202 | # dirstate is invalidated separately in invalidatedirstate() |
|
1207 | # dirstate is invalidated separately in invalidatedirstate() | |
1203 | if k == 'dirstate': |
|
1208 | if k == 'dirstate': | |
1204 | continue |
|
1209 | continue | |
1205 |
|
1210 | |||
1206 | try: |
|
1211 | try: | |
1207 | delattr(unfiltered, k) |
|
1212 | delattr(unfiltered, k) | |
1208 | except AttributeError: |
|
1213 | except AttributeError: | |
1209 | pass |
|
1214 | pass | |
1210 | self.invalidatecaches() |
|
1215 | self.invalidatecaches() | |
1211 | self.store.invalidatecaches() |
|
1216 | self.store.invalidatecaches() | |
1212 |
|
1217 | |||
1213 | def invalidateall(self): |
|
1218 | def invalidateall(self): | |
1214 | '''Fully invalidates both store and non-store parts, causing the |
|
1219 | '''Fully invalidates both store and non-store parts, causing the | |
1215 | subsequent operation to reread any outside changes.''' |
|
1220 | subsequent operation to reread any outside changes.''' | |
1216 | # extension should hook this to invalidate its caches |
|
1221 | # extension should hook this to invalidate its caches | |
1217 | self.invalidate() |
|
1222 | self.invalidate() | |
1218 | self.invalidatedirstate() |
|
1223 | self.invalidatedirstate() | |
1219 |
|
1224 | |||
1220 | def _refreshfilecachestats(self, tr): |
|
1225 | def _refreshfilecachestats(self, tr): | |
1221 | """Reload stats of cached files so that they are flagged as valid""" |
|
1226 | """Reload stats of cached files so that they are flagged as valid""" | |
1222 | for k, ce in self._filecache.items(): |
|
1227 | for k, ce in self._filecache.items(): | |
1223 | if k == 'dirstate' or k not in self.__dict__: |
|
1228 | if k == 'dirstate' or k not in self.__dict__: | |
1224 | continue |
|
1229 | continue | |
1225 | ce.refresh() |
|
1230 | ce.refresh() | |
1226 |
|
1231 | |||
1227 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, |
|
1232 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, | |
1228 | inheritchecker=None, parentenvvar=None): |
|
1233 | inheritchecker=None, parentenvvar=None): | |
1229 | parentlock = None |
|
1234 | parentlock = None | |
1230 | # the contents of parentenvvar are used by the underlying lock to |
|
1235 | # the contents of parentenvvar are used by the underlying lock to | |
1231 | # determine whether it can be inherited |
|
1236 | # determine whether it can be inherited | |
1232 | if parentenvvar is not None: |
|
1237 | if parentenvvar is not None: | |
1233 | parentlock = os.environ.get(parentenvvar) |
|
1238 | parentlock = os.environ.get(parentenvvar) | |
1234 | try: |
|
1239 | try: | |
1235 | l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, |
|
1240 | l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, | |
1236 | acquirefn=acquirefn, desc=desc, |
|
1241 | acquirefn=acquirefn, desc=desc, | |
1237 | inheritchecker=inheritchecker, |
|
1242 | inheritchecker=inheritchecker, | |
1238 | parentlock=parentlock) |
|
1243 | parentlock=parentlock) | |
1239 | except error.LockHeld as inst: |
|
1244 | except error.LockHeld as inst: | |
1240 | if not wait: |
|
1245 | if not wait: | |
1241 | raise |
|
1246 | raise | |
1242 | self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
1247 | self.ui.warn(_("waiting for lock on %s held by %r\n") % | |
1243 | (desc, inst.locker)) |
|
1248 | (desc, inst.locker)) | |
1244 | # default to 600 seconds timeout |
|
1249 | # default to 600 seconds timeout | |
1245 | l = lockmod.lock(vfs, lockname, |
|
1250 | l = lockmod.lock(vfs, lockname, | |
1246 | int(self.ui.config("ui", "timeout", "600")), |
|
1251 | int(self.ui.config("ui", "timeout", "600")), | |
1247 | releasefn=releasefn, acquirefn=acquirefn, |
|
1252 | releasefn=releasefn, acquirefn=acquirefn, | |
1248 | desc=desc) |
|
1253 | desc=desc) | |
1249 | self.ui.warn(_("got lock after %s seconds\n") % l.delay) |
|
1254 | self.ui.warn(_("got lock after %s seconds\n") % l.delay) | |
1250 | return l |
|
1255 | return l | |
1251 |
|
1256 | |||
1252 | def _afterlock(self, callback): |
|
1257 | def _afterlock(self, callback): | |
1253 | """add a callback to be run when the repository is fully unlocked |
|
1258 | """add a callback to be run when the repository is fully unlocked | |
1254 |
|
1259 | |||
1255 | The callback will be executed when the outermost lock is released |
|
1260 | The callback will be executed when the outermost lock is released | |
1256 | (with wlock being higher level than 'lock').""" |
|
1261 | (with wlock being higher level than 'lock').""" | |
1257 | for ref in (self._wlockref, self._lockref): |
|
1262 | for ref in (self._wlockref, self._lockref): | |
1258 | l = ref and ref() |
|
1263 | l = ref and ref() | |
1259 | if l and l.held: |
|
1264 | if l and l.held: | |
1260 | l.postrelease.append(callback) |
|
1265 | l.postrelease.append(callback) | |
1261 | break |
|
1266 | break | |
1262 | else: # no lock have been found. |
|
1267 | else: # no lock have been found. | |
1263 | callback() |
|
1268 | callback() | |
1264 |
|
1269 | |||
1265 | def lock(self, wait=True): |
|
1270 | def lock(self, wait=True): | |
1266 | '''Lock the repository store (.hg/store) and return a weak reference |
|
1271 | '''Lock the repository store (.hg/store) and return a weak reference | |
1267 | to the lock. Use this before modifying the store (e.g. committing or |
|
1272 | to the lock. Use this before modifying the store (e.g. committing or | |
1268 | stripping). If you are opening a transaction, get a lock as well.) |
|
1273 | stripping). If you are opening a transaction, get a lock as well.) | |
1269 |
|
1274 | |||
1270 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1275 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires | |
1271 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1276 | 'wlock' first to avoid a dead-lock hazard.''' | |
1272 | l = self._lockref and self._lockref() |
|
1277 | l = self._lockref and self._lockref() | |
1273 | if l is not None and l.held: |
|
1278 | if l is not None and l.held: | |
1274 | l.lock() |
|
1279 | l.lock() | |
1275 | return l |
|
1280 | return l | |
1276 |
|
1281 | |||
1277 | l = self._lock(self.svfs, "lock", wait, None, |
|
1282 | l = self._lock(self.svfs, "lock", wait, None, | |
1278 | self.invalidate, _('repository %s') % self.origroot) |
|
1283 | self.invalidate, _('repository %s') % self.origroot) | |
1279 | self._lockref = weakref.ref(l) |
|
1284 | self._lockref = weakref.ref(l) | |
1280 | return l |
|
1285 | return l | |
1281 |
|
1286 | |||
1282 | def _wlockchecktransaction(self): |
|
1287 | def _wlockchecktransaction(self): | |
1283 | if self.currenttransaction() is not None: |
|
1288 | if self.currenttransaction() is not None: | |
1284 | raise error.LockInheritanceContractViolation( |
|
1289 | raise error.LockInheritanceContractViolation( | |
1285 | 'wlock cannot be inherited in the middle of a transaction') |
|
1290 | 'wlock cannot be inherited in the middle of a transaction') | |
1286 |
|
1291 | |||
1287 | def wlock(self, wait=True): |
|
1292 | def wlock(self, wait=True): | |
1288 | '''Lock the non-store parts of the repository (everything under |
|
1293 | '''Lock the non-store parts of the repository (everything under | |
1289 | .hg except .hg/store) and return a weak reference to the lock. |
|
1294 | .hg except .hg/store) and return a weak reference to the lock. | |
1290 |
|
1295 | |||
1291 | Use this before modifying files in .hg. |
|
1296 | Use this before modifying files in .hg. | |
1292 |
|
1297 | |||
1293 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1298 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires | |
1294 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1299 | 'wlock' first to avoid a dead-lock hazard.''' | |
1295 | l = self._wlockref and self._wlockref() |
|
1300 | l = self._wlockref and self._wlockref() | |
1296 | if l is not None and l.held: |
|
1301 | if l is not None and l.held: | |
1297 | l.lock() |
|
1302 | l.lock() | |
1298 | return l |
|
1303 | return l | |
1299 |
|
1304 | |||
1300 | # We do not need to check for non-waiting lock aquisition. Such |
|
1305 | # We do not need to check for non-waiting lock aquisition. Such | |
1301 | # acquisition would not cause dead-lock as they would just fail. |
|
1306 | # acquisition would not cause dead-lock as they would just fail. | |
1302 | if wait and (self.ui.configbool('devel', 'all-warnings') |
|
1307 | if wait and (self.ui.configbool('devel', 'all-warnings') | |
1303 | or self.ui.configbool('devel', 'check-locks')): |
|
1308 | or self.ui.configbool('devel', 'check-locks')): | |
1304 | l = self._lockref and self._lockref() |
|
1309 | l = self._lockref and self._lockref() | |
1305 | if l is not None and l.held: |
|
1310 | if l is not None and l.held: | |
1306 | self.ui.develwarn('"wlock" acquired after "lock"') |
|
1311 | self.ui.develwarn('"wlock" acquired after "lock"') | |
1307 |
|
1312 | |||
1308 | def unlock(): |
|
1313 | def unlock(): | |
1309 | if self.dirstate.pendingparentchange(): |
|
1314 | if self.dirstate.pendingparentchange(): | |
1310 | self.dirstate.invalidate() |
|
1315 | self.dirstate.invalidate() | |
1311 | else: |
|
1316 | else: | |
1312 | self.dirstate.write() |
|
1317 | self.dirstate.write() | |
1313 |
|
1318 | |||
1314 | self._filecache['dirstate'].refresh() |
|
1319 | self._filecache['dirstate'].refresh() | |
1315 |
|
1320 | |||
1316 | l = self._lock(self.vfs, "wlock", wait, unlock, |
|
1321 | l = self._lock(self.vfs, "wlock", wait, unlock, | |
1317 | self.invalidatedirstate, _('working directory of %s') % |
|
1322 | self.invalidatedirstate, _('working directory of %s') % | |
1318 | self.origroot, |
|
1323 | self.origroot, | |
1319 | inheritchecker=self._wlockchecktransaction, |
|
1324 | inheritchecker=self._wlockchecktransaction, | |
1320 | parentenvvar='HG_WLOCK_LOCKER') |
|
1325 | parentenvvar='HG_WLOCK_LOCKER') | |
1321 | self._wlockref = weakref.ref(l) |
|
1326 | self._wlockref = weakref.ref(l) | |
1322 | return l |
|
1327 | return l | |
1323 |
|
1328 | |||
1324 | def _currentlock(self, lockref): |
|
1329 | def _currentlock(self, lockref): | |
1325 | """Returns the lock if it's held, or None if it's not.""" |
|
1330 | """Returns the lock if it's held, or None if it's not.""" | |
1326 | if lockref is None: |
|
1331 | if lockref is None: | |
1327 | return None |
|
1332 | return None | |
1328 | l = lockref() |
|
1333 | l = lockref() | |
1329 | if l is None or not l.held: |
|
1334 | if l is None or not l.held: | |
1330 | return None |
|
1335 | return None | |
1331 | return l |
|
1336 | return l | |
1332 |
|
1337 | |||
1333 | def currentwlock(self): |
|
1338 | def currentwlock(self): | |
1334 | """Returns the wlock if it's held, or None if it's not.""" |
|
1339 | """Returns the wlock if it's held, or None if it's not.""" | |
1335 | return self._currentlock(self._wlockref) |
|
1340 | return self._currentlock(self._wlockref) | |
1336 |
|
1341 | |||
1337 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
|
1342 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | |
1338 | """ |
|
1343 | """ | |
1339 | commit an individual file as part of a larger transaction |
|
1344 | commit an individual file as part of a larger transaction | |
1340 | """ |
|
1345 | """ | |
1341 |
|
1346 | |||
1342 | fname = fctx.path() |
|
1347 | fname = fctx.path() | |
1343 | fparent1 = manifest1.get(fname, nullid) |
|
1348 | fparent1 = manifest1.get(fname, nullid) | |
1344 | fparent2 = manifest2.get(fname, nullid) |
|
1349 | fparent2 = manifest2.get(fname, nullid) | |
1345 | if isinstance(fctx, context.filectx): |
|
1350 | if isinstance(fctx, context.filectx): | |
1346 | node = fctx.filenode() |
|
1351 | node = fctx.filenode() | |
1347 | if node in [fparent1, fparent2]: |
|
1352 | if node in [fparent1, fparent2]: | |
1348 | self.ui.debug('reusing %s filelog entry\n' % fname) |
|
1353 | self.ui.debug('reusing %s filelog entry\n' % fname) | |
1349 | return node |
|
1354 | return node | |
1350 |
|
1355 | |||
1351 | flog = self.file(fname) |
|
1356 | flog = self.file(fname) | |
1352 | meta = {} |
|
1357 | meta = {} | |
1353 | copy = fctx.renamed() |
|
1358 | copy = fctx.renamed() | |
1354 | if copy and copy[0] != fname: |
|
1359 | if copy and copy[0] != fname: | |
1355 | # Mark the new revision of this file as a copy of another |
|
1360 | # Mark the new revision of this file as a copy of another | |
1356 | # file. This copy data will effectively act as a parent |
|
1361 | # file. This copy data will effectively act as a parent | |
1357 | # of this new revision. If this is a merge, the first |
|
1362 | # of this new revision. If this is a merge, the first | |
1358 | # parent will be the nullid (meaning "look up the copy data") |
|
1363 | # parent will be the nullid (meaning "look up the copy data") | |
1359 | # and the second one will be the other parent. For example: |
|
1364 | # and the second one will be the other parent. For example: | |
1360 | # |
|
1365 | # | |
1361 | # 0 --- 1 --- 3 rev1 changes file foo |
|
1366 | # 0 --- 1 --- 3 rev1 changes file foo | |
1362 | # \ / rev2 renames foo to bar and changes it |
|
1367 | # \ / rev2 renames foo to bar and changes it | |
1363 | # \- 2 -/ rev3 should have bar with all changes and |
|
1368 | # \- 2 -/ rev3 should have bar with all changes and | |
1364 | # should record that bar descends from |
|
1369 | # should record that bar descends from | |
1365 | # bar in rev2 and foo in rev1 |
|
1370 | # bar in rev2 and foo in rev1 | |
1366 | # |
|
1371 | # | |
1367 | # this allows this merge to succeed: |
|
1372 | # this allows this merge to succeed: | |
1368 | # |
|
1373 | # | |
1369 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
1374 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 | |
1370 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
1375 | # \ / merging rev3 and rev4 should use bar@rev2 | |
1371 | # \- 2 --- 4 as the merge base |
|
1376 | # \- 2 --- 4 as the merge base | |
1372 | # |
|
1377 | # | |
1373 |
|
1378 | |||
1374 | cfname = copy[0] |
|
1379 | cfname = copy[0] | |
1375 | crev = manifest1.get(cfname) |
|
1380 | crev = manifest1.get(cfname) | |
1376 | newfparent = fparent2 |
|
1381 | newfparent = fparent2 | |
1377 |
|
1382 | |||
1378 | if manifest2: # branch merge |
|
1383 | if manifest2: # branch merge | |
1379 | if fparent2 == nullid or crev is None: # copied on remote side |
|
1384 | if fparent2 == nullid or crev is None: # copied on remote side | |
1380 | if cfname in manifest2: |
|
1385 | if cfname in manifest2: | |
1381 | crev = manifest2[cfname] |
|
1386 | crev = manifest2[cfname] | |
1382 | newfparent = fparent1 |
|
1387 | newfparent = fparent1 | |
1383 |
|
1388 | |||
1384 | # Here, we used to search backwards through history to try to find |
|
1389 | # Here, we used to search backwards through history to try to find | |
1385 | # where the file copy came from if the source of a copy was not in |
|
1390 | # where the file copy came from if the source of a copy was not in | |
1386 | # the parent directory. However, this doesn't actually make sense to |
|
1391 | # the parent directory. However, this doesn't actually make sense to | |
1387 | # do (what does a copy from something not in your working copy even |
|
1392 | # do (what does a copy from something not in your working copy even | |
1388 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn |
|
1393 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn | |
1389 | # the user that copy information was dropped, so if they didn't |
|
1394 | # the user that copy information was dropped, so if they didn't | |
1390 | # expect this outcome it can be fixed, but this is the correct |
|
1395 | # expect this outcome it can be fixed, but this is the correct | |
1391 | # behavior in this circumstance. |
|
1396 | # behavior in this circumstance. | |
1392 |
|
1397 | |||
1393 | if crev: |
|
1398 | if crev: | |
1394 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) |
|
1399 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) | |
1395 | meta["copy"] = cfname |
|
1400 | meta["copy"] = cfname | |
1396 | meta["copyrev"] = hex(crev) |
|
1401 | meta["copyrev"] = hex(crev) | |
1397 | fparent1, fparent2 = nullid, newfparent |
|
1402 | fparent1, fparent2 = nullid, newfparent | |
1398 | else: |
|
1403 | else: | |
1399 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
1404 | self.ui.warn(_("warning: can't find ancestor for '%s' " | |
1400 | "copied from '%s'!\n") % (fname, cfname)) |
|
1405 | "copied from '%s'!\n") % (fname, cfname)) | |
1401 |
|
1406 | |||
1402 | elif fparent1 == nullid: |
|
1407 | elif fparent1 == nullid: | |
1403 | fparent1, fparent2 = fparent2, nullid |
|
1408 | fparent1, fparent2 = fparent2, nullid | |
1404 | elif fparent2 != nullid: |
|
1409 | elif fparent2 != nullid: | |
1405 | # is one parent an ancestor of the other? |
|
1410 | # is one parent an ancestor of the other? | |
1406 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) |
|
1411 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) | |
1407 | if fparent1 in fparentancestors: |
|
1412 | if fparent1 in fparentancestors: | |
1408 | fparent1, fparent2 = fparent2, nullid |
|
1413 | fparent1, fparent2 = fparent2, nullid | |
1409 | elif fparent2 in fparentancestors: |
|
1414 | elif fparent2 in fparentancestors: | |
1410 | fparent2 = nullid |
|
1415 | fparent2 = nullid | |
1411 |
|
1416 | |||
1412 | # is the file changed? |
|
1417 | # is the file changed? | |
1413 | text = fctx.data() |
|
1418 | text = fctx.data() | |
1414 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
1419 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: | |
1415 | changelist.append(fname) |
|
1420 | changelist.append(fname) | |
1416 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
1421 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) | |
1417 | # are just the flags changed during merge? |
|
1422 | # are just the flags changed during merge? | |
1418 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
|
1423 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): | |
1419 | changelist.append(fname) |
|
1424 | changelist.append(fname) | |
1420 |
|
1425 | |||
1421 | return fparent1 |
|
1426 | return fparent1 | |
1422 |
|
1427 | |||
1423 | @unfilteredmethod |
|
1428 | @unfilteredmethod | |
1424 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
1429 | def commit(self, text="", user=None, date=None, match=None, force=False, | |
1425 | editor=False, extra=None): |
|
1430 | editor=False, extra=None): | |
1426 | """Add a new revision to current repository. |
|
1431 | """Add a new revision to current repository. | |
1427 |
|
1432 | |||
1428 | Revision information is gathered from the working directory, |
|
1433 | Revision information is gathered from the working directory, | |
1429 | match can be used to filter the committed files. If editor is |
|
1434 | match can be used to filter the committed files. If editor is | |
1430 | supplied, it is called to get a commit message. |
|
1435 | supplied, it is called to get a commit message. | |
1431 | """ |
|
1436 | """ | |
1432 | if extra is None: |
|
1437 | if extra is None: | |
1433 | extra = {} |
|
1438 | extra = {} | |
1434 |
|
1439 | |||
1435 | def fail(f, msg): |
|
1440 | def fail(f, msg): | |
1436 | raise error.Abort('%s: %s' % (f, msg)) |
|
1441 | raise error.Abort('%s: %s' % (f, msg)) | |
1437 |
|
1442 | |||
1438 | if not match: |
|
1443 | if not match: | |
1439 | match = matchmod.always(self.root, '') |
|
1444 | match = matchmod.always(self.root, '') | |
1440 |
|
1445 | |||
1441 | if not force: |
|
1446 | if not force: | |
1442 | vdirs = [] |
|
1447 | vdirs = [] | |
1443 | match.explicitdir = vdirs.append |
|
1448 | match.explicitdir = vdirs.append | |
1444 | match.bad = fail |
|
1449 | match.bad = fail | |
1445 |
|
1450 | |||
1446 | wlock = self.wlock() |
|
1451 | wlock = self.wlock() | |
1447 | try: |
|
1452 | try: | |
1448 | wctx = self[None] |
|
1453 | wctx = self[None] | |
1449 | merge = len(wctx.parents()) > 1 |
|
1454 | merge = len(wctx.parents()) > 1 | |
1450 |
|
1455 | |||
1451 | if not force and merge and match.ispartial(): |
|
1456 | if not force and merge and match.ispartial(): | |
1452 | raise error.Abort(_('cannot partially commit a merge ' |
|
1457 | raise error.Abort(_('cannot partially commit a merge ' | |
1453 | '(do not specify files or patterns)')) |
|
1458 | '(do not specify files or patterns)')) | |
1454 |
|
1459 | |||
1455 | status = self.status(match=match, clean=force) |
|
1460 | status = self.status(match=match, clean=force) | |
1456 | if force: |
|
1461 | if force: | |
1457 | status.modified.extend(status.clean) # mq may commit clean files |
|
1462 | status.modified.extend(status.clean) # mq may commit clean files | |
1458 |
|
1463 | |||
1459 | # check subrepos |
|
1464 | # check subrepos | |
1460 | subs = [] |
|
1465 | subs = [] | |
1461 | commitsubs = set() |
|
1466 | commitsubs = set() | |
1462 | newstate = wctx.substate.copy() |
|
1467 | newstate = wctx.substate.copy() | |
1463 | # only manage subrepos and .hgsubstate if .hgsub is present |
|
1468 | # only manage subrepos and .hgsubstate if .hgsub is present | |
1464 | if '.hgsub' in wctx: |
|
1469 | if '.hgsub' in wctx: | |
1465 | # we'll decide whether to track this ourselves, thanks |
|
1470 | # we'll decide whether to track this ourselves, thanks | |
1466 | for c in status.modified, status.added, status.removed: |
|
1471 | for c in status.modified, status.added, status.removed: | |
1467 | if '.hgsubstate' in c: |
|
1472 | if '.hgsubstate' in c: | |
1468 | c.remove('.hgsubstate') |
|
1473 | c.remove('.hgsubstate') | |
1469 |
|
1474 | |||
1470 | # compare current state to last committed state |
|
1475 | # compare current state to last committed state | |
1471 | # build new substate based on last committed state |
|
1476 | # build new substate based on last committed state | |
1472 | oldstate = wctx.p1().substate |
|
1477 | oldstate = wctx.p1().substate | |
1473 | for s in sorted(newstate.keys()): |
|
1478 | for s in sorted(newstate.keys()): | |
1474 | if not match(s): |
|
1479 | if not match(s): | |
1475 | # ignore working copy, use old state if present |
|
1480 | # ignore working copy, use old state if present | |
1476 | if s in oldstate: |
|
1481 | if s in oldstate: | |
1477 | newstate[s] = oldstate[s] |
|
1482 | newstate[s] = oldstate[s] | |
1478 | continue |
|
1483 | continue | |
1479 | if not force: |
|
1484 | if not force: | |
1480 | raise error.Abort( |
|
1485 | raise error.Abort( | |
1481 | _("commit with new subrepo %s excluded") % s) |
|
1486 | _("commit with new subrepo %s excluded") % s) | |
1482 | dirtyreason = wctx.sub(s).dirtyreason(True) |
|
1487 | dirtyreason = wctx.sub(s).dirtyreason(True) | |
1483 | if dirtyreason: |
|
1488 | if dirtyreason: | |
1484 | if not self.ui.configbool('ui', 'commitsubrepos'): |
|
1489 | if not self.ui.configbool('ui', 'commitsubrepos'): | |
1485 | raise error.Abort(dirtyreason, |
|
1490 | raise error.Abort(dirtyreason, | |
1486 | hint=_("use --subrepos for recursive commit")) |
|
1491 | hint=_("use --subrepos for recursive commit")) | |
1487 | subs.append(s) |
|
1492 | subs.append(s) | |
1488 | commitsubs.add(s) |
|
1493 | commitsubs.add(s) | |
1489 | else: |
|
1494 | else: | |
1490 | bs = wctx.sub(s).basestate() |
|
1495 | bs = wctx.sub(s).basestate() | |
1491 | newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
|
1496 | newstate[s] = (newstate[s][0], bs, newstate[s][2]) | |
1492 | if oldstate.get(s, (None, None, None))[1] != bs: |
|
1497 | if oldstate.get(s, (None, None, None))[1] != bs: | |
1493 | subs.append(s) |
|
1498 | subs.append(s) | |
1494 |
|
1499 | |||
1495 | # check for removed subrepos |
|
1500 | # check for removed subrepos | |
1496 | for p in wctx.parents(): |
|
1501 | for p in wctx.parents(): | |
1497 | r = [s for s in p.substate if s not in newstate] |
|
1502 | r = [s for s in p.substate if s not in newstate] | |
1498 | subs += [s for s in r if match(s)] |
|
1503 | subs += [s for s in r if match(s)] | |
1499 | if subs: |
|
1504 | if subs: | |
1500 | if (not match('.hgsub') and |
|
1505 | if (not match('.hgsub') and | |
1501 | '.hgsub' in (wctx.modified() + wctx.added())): |
|
1506 | '.hgsub' in (wctx.modified() + wctx.added())): | |
1502 | raise error.Abort( |
|
1507 | raise error.Abort( | |
1503 | _("can't commit subrepos without .hgsub")) |
|
1508 | _("can't commit subrepos without .hgsub")) | |
1504 | status.modified.insert(0, '.hgsubstate') |
|
1509 | status.modified.insert(0, '.hgsubstate') | |
1505 |
|
1510 | |||
1506 | elif '.hgsub' in status.removed: |
|
1511 | elif '.hgsub' in status.removed: | |
1507 | # clean up .hgsubstate when .hgsub is removed |
|
1512 | # clean up .hgsubstate when .hgsub is removed | |
1508 | if ('.hgsubstate' in wctx and |
|
1513 | if ('.hgsubstate' in wctx and | |
1509 | '.hgsubstate' not in (status.modified + status.added + |
|
1514 | '.hgsubstate' not in (status.modified + status.added + | |
1510 | status.removed)): |
|
1515 | status.removed)): | |
1511 | status.removed.insert(0, '.hgsubstate') |
|
1516 | status.removed.insert(0, '.hgsubstate') | |
1512 |
|
1517 | |||
1513 | # make sure all explicit patterns are matched |
|
1518 | # make sure all explicit patterns are matched | |
1514 | if not force and (match.isexact() or match.prefix()): |
|
1519 | if not force and (match.isexact() or match.prefix()): | |
1515 | matched = set(status.modified + status.added + status.removed) |
|
1520 | matched = set(status.modified + status.added + status.removed) | |
1516 |
|
1521 | |||
1517 | for f in match.files(): |
|
1522 | for f in match.files(): | |
1518 | f = self.dirstate.normalize(f) |
|
1523 | f = self.dirstate.normalize(f) | |
1519 | if f == '.' or f in matched or f in wctx.substate: |
|
1524 | if f == '.' or f in matched or f in wctx.substate: | |
1520 | continue |
|
1525 | continue | |
1521 | if f in status.deleted: |
|
1526 | if f in status.deleted: | |
1522 | fail(f, _('file not found!')) |
|
1527 | fail(f, _('file not found!')) | |
1523 | if f in vdirs: # visited directory |
|
1528 | if f in vdirs: # visited directory | |
1524 | d = f + '/' |
|
1529 | d = f + '/' | |
1525 | for mf in matched: |
|
1530 | for mf in matched: | |
1526 | if mf.startswith(d): |
|
1531 | if mf.startswith(d): | |
1527 | break |
|
1532 | break | |
1528 | else: |
|
1533 | else: | |
1529 | fail(f, _("no match under directory!")) |
|
1534 | fail(f, _("no match under directory!")) | |
1530 | elif f not in self.dirstate: |
|
1535 | elif f not in self.dirstate: | |
1531 | fail(f, _("file not tracked!")) |
|
1536 | fail(f, _("file not tracked!")) | |
1532 |
|
1537 | |||
1533 | cctx = context.workingcommitctx(self, status, |
|
1538 | cctx = context.workingcommitctx(self, status, | |
1534 | text, user, date, extra) |
|
1539 | text, user, date, extra) | |
1535 |
|
1540 | |||
1536 | # internal config: ui.allowemptycommit |
|
1541 | # internal config: ui.allowemptycommit | |
1537 | allowemptycommit = (wctx.branch() != wctx.p1().branch() |
|
1542 | allowemptycommit = (wctx.branch() != wctx.p1().branch() | |
1538 | or extra.get('close') or merge or cctx.files() |
|
1543 | or extra.get('close') or merge or cctx.files() | |
1539 | or self.ui.configbool('ui', 'allowemptycommit')) |
|
1544 | or self.ui.configbool('ui', 'allowemptycommit')) | |
1540 | if not allowemptycommit: |
|
1545 | if not allowemptycommit: | |
1541 | return None |
|
1546 | return None | |
1542 |
|
1547 | |||
1543 | if merge and cctx.deleted(): |
|
1548 | if merge and cctx.deleted(): | |
1544 | raise error.Abort(_("cannot commit merge with missing files")) |
|
1549 | raise error.Abort(_("cannot commit merge with missing files")) | |
1545 |
|
1550 | |||
1546 | ms = mergemod.mergestate(self) |
|
1551 | ms = mergemod.mergestate(self) | |
1547 | for f in status.modified: |
|
1552 | for f in status.modified: | |
1548 | if f in ms and ms[f] == 'u': |
|
1553 | if f in ms and ms[f] == 'u': | |
1549 | raise error.Abort(_('unresolved merge conflicts ' |
|
1554 | raise error.Abort(_('unresolved merge conflicts ' | |
1550 | '(see "hg help resolve")')) |
|
1555 | '(see "hg help resolve")')) | |
1551 |
|
1556 | |||
1552 | if editor: |
|
1557 | if editor: | |
1553 | cctx._text = editor(self, cctx, subs) |
|
1558 | cctx._text = editor(self, cctx, subs) | |
1554 | edited = (text != cctx._text) |
|
1559 | edited = (text != cctx._text) | |
1555 |
|
1560 | |||
1556 | # Save commit message in case this transaction gets rolled back |
|
1561 | # Save commit message in case this transaction gets rolled back | |
1557 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
1562 | # (e.g. by a pretxncommit hook). Leave the content alone on | |
1558 | # the assumption that the user will use the same editor again. |
|
1563 | # the assumption that the user will use the same editor again. | |
1559 | msgfn = self.savecommitmessage(cctx._text) |
|
1564 | msgfn = self.savecommitmessage(cctx._text) | |
1560 |
|
1565 | |||
1561 | # commit subs and write new state |
|
1566 | # commit subs and write new state | |
1562 | if subs: |
|
1567 | if subs: | |
1563 | for s in sorted(commitsubs): |
|
1568 | for s in sorted(commitsubs): | |
1564 | sub = wctx.sub(s) |
|
1569 | sub = wctx.sub(s) | |
1565 | self.ui.status(_('committing subrepository %s\n') % |
|
1570 | self.ui.status(_('committing subrepository %s\n') % | |
1566 | subrepo.subrelpath(sub)) |
|
1571 | subrepo.subrelpath(sub)) | |
1567 | sr = sub.commit(cctx._text, user, date) |
|
1572 | sr = sub.commit(cctx._text, user, date) | |
1568 | newstate[s] = (newstate[s][0], sr) |
|
1573 | newstate[s] = (newstate[s][0], sr) | |
1569 | subrepo.writestate(self, newstate) |
|
1574 | subrepo.writestate(self, newstate) | |
1570 |
|
1575 | |||
1571 | p1, p2 = self.dirstate.parents() |
|
1576 | p1, p2 = self.dirstate.parents() | |
1572 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1577 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | |
1573 | try: |
|
1578 | try: | |
1574 | self.hook("precommit", throw=True, parent1=hookp1, |
|
1579 | self.hook("precommit", throw=True, parent1=hookp1, | |
1575 | parent2=hookp2) |
|
1580 | parent2=hookp2) | |
1576 | ret = self.commitctx(cctx, True) |
|
1581 | ret = self.commitctx(cctx, True) | |
1577 | except: # re-raises |
|
1582 | except: # re-raises | |
1578 | if edited: |
|
1583 | if edited: | |
1579 | self.ui.write( |
|
1584 | self.ui.write( | |
1580 | _('note: commit message saved in %s\n') % msgfn) |
|
1585 | _('note: commit message saved in %s\n') % msgfn) | |
1581 | raise |
|
1586 | raise | |
1582 |
|
1587 | |||
1583 | # update bookmarks, dirstate and mergestate |
|
1588 | # update bookmarks, dirstate and mergestate | |
1584 | bookmarks.update(self, [p1, p2], ret) |
|
1589 | bookmarks.update(self, [p1, p2], ret) | |
1585 | cctx.markcommitted(ret) |
|
1590 | cctx.markcommitted(ret) | |
1586 | ms.reset() |
|
1591 | ms.reset() | |
1587 | finally: |
|
1592 | finally: | |
1588 | wlock.release() |
|
1593 | wlock.release() | |
1589 |
|
1594 | |||
1590 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
|
1595 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): | |
1591 | # hack for command that use a temporary commit (eg: histedit) |
|
1596 | # hack for command that use a temporary commit (eg: histedit) | |
1592 | # temporary commit got stripped before hook release |
|
1597 | # temporary commit got stripped before hook release | |
1593 | if self.changelog.hasnode(ret): |
|
1598 | if self.changelog.hasnode(ret): | |
1594 | self.hook("commit", node=node, parent1=parent1, |
|
1599 | self.hook("commit", node=node, parent1=parent1, | |
1595 | parent2=parent2) |
|
1600 | parent2=parent2) | |
1596 | self._afterlock(commithook) |
|
1601 | self._afterlock(commithook) | |
1597 | return ret |
|
1602 | return ret | |
1598 |
|
1603 | |||
1599 | @unfilteredmethod |
|
1604 | @unfilteredmethod | |
1600 | def commitctx(self, ctx, error=False): |
|
1605 | def commitctx(self, ctx, error=False): | |
1601 | """Add a new revision to current repository. |
|
1606 | """Add a new revision to current repository. | |
1602 | Revision information is passed via the context argument. |
|
1607 | Revision information is passed via the context argument. | |
1603 | """ |
|
1608 | """ | |
1604 |
|
1609 | |||
1605 | tr = None |
|
1610 | tr = None | |
1606 | p1, p2 = ctx.p1(), ctx.p2() |
|
1611 | p1, p2 = ctx.p1(), ctx.p2() | |
1607 | user = ctx.user() |
|
1612 | user = ctx.user() | |
1608 |
|
1613 | |||
1609 | lock = self.lock() |
|
1614 | lock = self.lock() | |
1610 | try: |
|
1615 | try: | |
1611 | tr = self.transaction("commit") |
|
1616 | tr = self.transaction("commit") | |
1612 | trp = weakref.proxy(tr) |
|
1617 | trp = weakref.proxy(tr) | |
1613 |
|
1618 | |||
1614 | if ctx.files(): |
|
1619 | if ctx.files(): | |
1615 | m1 = p1.manifest() |
|
1620 | m1 = p1.manifest() | |
1616 | m2 = p2.manifest() |
|
1621 | m2 = p2.manifest() | |
1617 | m = m1.copy() |
|
1622 | m = m1.copy() | |
1618 |
|
1623 | |||
1619 | # check in files |
|
1624 | # check in files | |
1620 | added = [] |
|
1625 | added = [] | |
1621 | changed = [] |
|
1626 | changed = [] | |
1622 | removed = list(ctx.removed()) |
|
1627 | removed = list(ctx.removed()) | |
1623 | linkrev = len(self) |
|
1628 | linkrev = len(self) | |
1624 | self.ui.note(_("committing files:\n")) |
|
1629 | self.ui.note(_("committing files:\n")) | |
1625 | for f in sorted(ctx.modified() + ctx.added()): |
|
1630 | for f in sorted(ctx.modified() + ctx.added()): | |
1626 | self.ui.note(f + "\n") |
|
1631 | self.ui.note(f + "\n") | |
1627 | try: |
|
1632 | try: | |
1628 | fctx = ctx[f] |
|
1633 | fctx = ctx[f] | |
1629 | if fctx is None: |
|
1634 | if fctx is None: | |
1630 | removed.append(f) |
|
1635 | removed.append(f) | |
1631 | else: |
|
1636 | else: | |
1632 | added.append(f) |
|
1637 | added.append(f) | |
1633 | m[f] = self._filecommit(fctx, m1, m2, linkrev, |
|
1638 | m[f] = self._filecommit(fctx, m1, m2, linkrev, | |
1634 | trp, changed) |
|
1639 | trp, changed) | |
1635 | m.setflag(f, fctx.flags()) |
|
1640 | m.setflag(f, fctx.flags()) | |
1636 | except OSError as inst: |
|
1641 | except OSError as inst: | |
1637 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1642 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1638 | raise |
|
1643 | raise | |
1639 | except IOError as inst: |
|
1644 | except IOError as inst: | |
1640 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
1645 | errcode = getattr(inst, 'errno', errno.ENOENT) | |
1641 | if error or errcode and errcode != errno.ENOENT: |
|
1646 | if error or errcode and errcode != errno.ENOENT: | |
1642 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1647 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1643 | raise |
|
1648 | raise | |
1644 |
|
1649 | |||
1645 | # update manifest |
|
1650 | # update manifest | |
1646 | self.ui.note(_("committing manifest\n")) |
|
1651 | self.ui.note(_("committing manifest\n")) | |
1647 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
1652 | removed = [f for f in sorted(removed) if f in m1 or f in m2] | |
1648 | drop = [f for f in removed if f in m] |
|
1653 | drop = [f for f in removed if f in m] | |
1649 | for f in drop: |
|
1654 | for f in drop: | |
1650 | del m[f] |
|
1655 | del m[f] | |
1651 | mn = self.manifest.add(m, trp, linkrev, |
|
1656 | mn = self.manifest.add(m, trp, linkrev, | |
1652 | p1.manifestnode(), p2.manifestnode(), |
|
1657 | p1.manifestnode(), p2.manifestnode(), | |
1653 | added, drop) |
|
1658 | added, drop) | |
1654 | files = changed + removed |
|
1659 | files = changed + removed | |
1655 | else: |
|
1660 | else: | |
1656 | mn = p1.manifestnode() |
|
1661 | mn = p1.manifestnode() | |
1657 | files = [] |
|
1662 | files = [] | |
1658 |
|
1663 | |||
1659 | # update changelog |
|
1664 | # update changelog | |
1660 | self.ui.note(_("committing changelog\n")) |
|
1665 | self.ui.note(_("committing changelog\n")) | |
1661 | self.changelog.delayupdate(tr) |
|
1666 | self.changelog.delayupdate(tr) | |
1662 | n = self.changelog.add(mn, files, ctx.description(), |
|
1667 | n = self.changelog.add(mn, files, ctx.description(), | |
1663 | trp, p1.node(), p2.node(), |
|
1668 | trp, p1.node(), p2.node(), | |
1664 | user, ctx.date(), ctx.extra().copy()) |
|
1669 | user, ctx.date(), ctx.extra().copy()) | |
1665 | p = lambda: tr.writepending() and self.root or "" |
|
1670 | p = lambda: tr.writepending() and self.root or "" | |
1666 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
1671 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
1667 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
1672 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, | |
1668 | parent2=xp2, pending=p) |
|
1673 | parent2=xp2, pending=p) | |
1669 | # set the new commit is proper phase |
|
1674 | # set the new commit is proper phase | |
1670 | targetphase = subrepo.newcommitphase(self.ui, ctx) |
|
1675 | targetphase = subrepo.newcommitphase(self.ui, ctx) | |
1671 | if targetphase: |
|
1676 | if targetphase: | |
1672 | # retract boundary do not alter parent changeset. |
|
1677 | # retract boundary do not alter parent changeset. | |
1673 | # if a parent have higher the resulting phase will |
|
1678 | # if a parent have higher the resulting phase will | |
1674 | # be compliant anyway |
|
1679 | # be compliant anyway | |
1675 | # |
|
1680 | # | |
1676 | # if minimal phase was 0 we don't need to retract anything |
|
1681 | # if minimal phase was 0 we don't need to retract anything | |
1677 | phases.retractboundary(self, tr, targetphase, [n]) |
|
1682 | phases.retractboundary(self, tr, targetphase, [n]) | |
1678 | tr.close() |
|
1683 | tr.close() | |
1679 | branchmap.updatecache(self.filtered('served')) |
|
1684 | branchmap.updatecache(self.filtered('served')) | |
1680 | return n |
|
1685 | return n | |
1681 | finally: |
|
1686 | finally: | |
1682 | if tr: |
|
1687 | if tr: | |
1683 | tr.release() |
|
1688 | tr.release() | |
1684 | lock.release() |
|
1689 | lock.release() | |
1685 |
|
1690 | |||
1686 | @unfilteredmethod |
|
1691 | @unfilteredmethod | |
1687 | def destroying(self): |
|
1692 | def destroying(self): | |
1688 | '''Inform the repository that nodes are about to be destroyed. |
|
1693 | '''Inform the repository that nodes are about to be destroyed. | |
1689 | Intended for use by strip and rollback, so there's a common |
|
1694 | Intended for use by strip and rollback, so there's a common | |
1690 | place for anything that has to be done before destroying history. |
|
1695 | place for anything that has to be done before destroying history. | |
1691 |
|
1696 | |||
1692 | This is mostly useful for saving state that is in memory and waiting |
|
1697 | This is mostly useful for saving state that is in memory and waiting | |
1693 | to be flushed when the current lock is released. Because a call to |
|
1698 | to be flushed when the current lock is released. Because a call to | |
1694 | destroyed is imminent, the repo will be invalidated causing those |
|
1699 | destroyed is imminent, the repo will be invalidated causing those | |
1695 | changes to stay in memory (waiting for the next unlock), or vanish |
|
1700 | changes to stay in memory (waiting for the next unlock), or vanish | |
1696 | completely. |
|
1701 | completely. | |
1697 | ''' |
|
1702 | ''' | |
1698 | # When using the same lock to commit and strip, the phasecache is left |
|
1703 | # When using the same lock to commit and strip, the phasecache is left | |
1699 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
1704 | # dirty after committing. Then when we strip, the repo is invalidated, | |
1700 | # causing those changes to disappear. |
|
1705 | # causing those changes to disappear. | |
1701 | if '_phasecache' in vars(self): |
|
1706 | if '_phasecache' in vars(self): | |
1702 | self._phasecache.write() |
|
1707 | self._phasecache.write() | |
1703 |
|
1708 | |||
1704 | @unfilteredmethod |
|
1709 | @unfilteredmethod | |
1705 | def destroyed(self): |
|
1710 | def destroyed(self): | |
1706 | '''Inform the repository that nodes have been destroyed. |
|
1711 | '''Inform the repository that nodes have been destroyed. | |
1707 | Intended for use by strip and rollback, so there's a common |
|
1712 | Intended for use by strip and rollback, so there's a common | |
1708 | place for anything that has to be done after destroying history. |
|
1713 | place for anything that has to be done after destroying history. | |
1709 | ''' |
|
1714 | ''' | |
1710 | # When one tries to: |
|
1715 | # When one tries to: | |
1711 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
1716 | # 1) destroy nodes thus calling this method (e.g. strip) | |
1712 | # 2) use phasecache somewhere (e.g. commit) |
|
1717 | # 2) use phasecache somewhere (e.g. commit) | |
1713 | # |
|
1718 | # | |
1714 | # then 2) will fail because the phasecache contains nodes that were |
|
1719 | # then 2) will fail because the phasecache contains nodes that were | |
1715 | # removed. We can either remove phasecache from the filecache, |
|
1720 | # removed. We can either remove phasecache from the filecache, | |
1716 | # causing it to reload next time it is accessed, or simply filter |
|
1721 | # causing it to reload next time it is accessed, or simply filter | |
1717 | # the removed nodes now and write the updated cache. |
|
1722 | # the removed nodes now and write the updated cache. | |
1718 | self._phasecache.filterunknown(self) |
|
1723 | self._phasecache.filterunknown(self) | |
1719 | self._phasecache.write() |
|
1724 | self._phasecache.write() | |
1720 |
|
1725 | |||
1721 | # update the 'served' branch cache to help read only server process |
|
1726 | # update the 'served' branch cache to help read only server process | |
1722 | # Thanks to branchcache collaboration this is done from the nearest |
|
1727 | # Thanks to branchcache collaboration this is done from the nearest | |
1723 | # filtered subset and it is expected to be fast. |
|
1728 | # filtered subset and it is expected to be fast. | |
1724 | branchmap.updatecache(self.filtered('served')) |
|
1729 | branchmap.updatecache(self.filtered('served')) | |
1725 |
|
1730 | |||
1726 | # Ensure the persistent tag cache is updated. Doing it now |
|
1731 | # Ensure the persistent tag cache is updated. Doing it now | |
1727 | # means that the tag cache only has to worry about destroyed |
|
1732 | # means that the tag cache only has to worry about destroyed | |
1728 | # heads immediately after a strip/rollback. That in turn |
|
1733 | # heads immediately after a strip/rollback. That in turn | |
1729 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
1734 | # guarantees that "cachetip == currenttip" (comparing both rev | |
1730 | # and node) always means no nodes have been added or destroyed. |
|
1735 | # and node) always means no nodes have been added or destroyed. | |
1731 |
|
1736 | |||
1732 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
1737 | # XXX this is suboptimal when qrefresh'ing: we strip the current | |
1733 | # head, refresh the tag cache, then immediately add a new head. |
|
1738 | # head, refresh the tag cache, then immediately add a new head. | |
1734 | # But I think doing it this way is necessary for the "instant |
|
1739 | # But I think doing it this way is necessary for the "instant | |
1735 | # tag cache retrieval" case to work. |
|
1740 | # tag cache retrieval" case to work. | |
1736 | self.invalidate() |
|
1741 | self.invalidate() | |
1737 |
|
1742 | |||
1738 | def walk(self, match, node=None): |
|
1743 | def walk(self, match, node=None): | |
1739 | ''' |
|
1744 | ''' | |
1740 | walk recursively through the directory tree or a given |
|
1745 | walk recursively through the directory tree or a given | |
1741 | changeset, finding all files matched by the match |
|
1746 | changeset, finding all files matched by the match | |
1742 | function |
|
1747 | function | |
1743 | ''' |
|
1748 | ''' | |
1744 | return self[node].walk(match) |
|
1749 | return self[node].walk(match) | |
1745 |
|
1750 | |||
1746 | def status(self, node1='.', node2=None, match=None, |
|
1751 | def status(self, node1='.', node2=None, match=None, | |
1747 | ignored=False, clean=False, unknown=False, |
|
1752 | ignored=False, clean=False, unknown=False, | |
1748 | listsubrepos=False): |
|
1753 | listsubrepos=False): | |
1749 | '''a convenience method that calls node1.status(node2)''' |
|
1754 | '''a convenience method that calls node1.status(node2)''' | |
1750 | return self[node1].status(node2, match, ignored, clean, unknown, |
|
1755 | return self[node1].status(node2, match, ignored, clean, unknown, | |
1751 | listsubrepos) |
|
1756 | listsubrepos) | |
1752 |
|
1757 | |||
1753 | def heads(self, start=None): |
|
1758 | def heads(self, start=None): | |
1754 | heads = self.changelog.heads(start) |
|
1759 | heads = self.changelog.heads(start) | |
1755 | # sort the output in rev descending order |
|
1760 | # sort the output in rev descending order | |
1756 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
1761 | return sorted(heads, key=self.changelog.rev, reverse=True) | |
1757 |
|
1762 | |||
1758 | def branchheads(self, branch=None, start=None, closed=False): |
|
1763 | def branchheads(self, branch=None, start=None, closed=False): | |
1759 | '''return a (possibly filtered) list of heads for the given branch |
|
1764 | '''return a (possibly filtered) list of heads for the given branch | |
1760 |
|
1765 | |||
1761 | Heads are returned in topological order, from newest to oldest. |
|
1766 | Heads are returned in topological order, from newest to oldest. | |
1762 | If branch is None, use the dirstate branch. |
|
1767 | If branch is None, use the dirstate branch. | |
1763 | If start is not None, return only heads reachable from start. |
|
1768 | If start is not None, return only heads reachable from start. | |
1764 | If closed is True, return heads that are marked as closed as well. |
|
1769 | If closed is True, return heads that are marked as closed as well. | |
1765 | ''' |
|
1770 | ''' | |
1766 | if branch is None: |
|
1771 | if branch is None: | |
1767 | branch = self[None].branch() |
|
1772 | branch = self[None].branch() | |
1768 | branches = self.branchmap() |
|
1773 | branches = self.branchmap() | |
1769 | if branch not in branches: |
|
1774 | if branch not in branches: | |
1770 | return [] |
|
1775 | return [] | |
1771 | # the cache returns heads ordered lowest to highest |
|
1776 | # the cache returns heads ordered lowest to highest | |
1772 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
1777 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) | |
1773 | if start is not None: |
|
1778 | if start is not None: | |
1774 | # filter out the heads that cannot be reached from startrev |
|
1779 | # filter out the heads that cannot be reached from startrev | |
1775 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
1780 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) | |
1776 | bheads = [h for h in bheads if h in fbheads] |
|
1781 | bheads = [h for h in bheads if h in fbheads] | |
1777 | return bheads |
|
1782 | return bheads | |
1778 |
|
1783 | |||
1779 | def branches(self, nodes): |
|
1784 | def branches(self, nodes): | |
1780 | if not nodes: |
|
1785 | if not nodes: | |
1781 | nodes = [self.changelog.tip()] |
|
1786 | nodes = [self.changelog.tip()] | |
1782 | b = [] |
|
1787 | b = [] | |
1783 | for n in nodes: |
|
1788 | for n in nodes: | |
1784 | t = n |
|
1789 | t = n | |
1785 | while True: |
|
1790 | while True: | |
1786 | p = self.changelog.parents(n) |
|
1791 | p = self.changelog.parents(n) | |
1787 | if p[1] != nullid or p[0] == nullid: |
|
1792 | if p[1] != nullid or p[0] == nullid: | |
1788 | b.append((t, n, p[0], p[1])) |
|
1793 | b.append((t, n, p[0], p[1])) | |
1789 | break |
|
1794 | break | |
1790 | n = p[0] |
|
1795 | n = p[0] | |
1791 | return b |
|
1796 | return b | |
1792 |
|
1797 | |||
1793 | def between(self, pairs): |
|
1798 | def between(self, pairs): | |
1794 | r = [] |
|
1799 | r = [] | |
1795 |
|
1800 | |||
1796 | for top, bottom in pairs: |
|
1801 | for top, bottom in pairs: | |
1797 | n, l, i = top, [], 0 |
|
1802 | n, l, i = top, [], 0 | |
1798 | f = 1 |
|
1803 | f = 1 | |
1799 |
|
1804 | |||
1800 | while n != bottom and n != nullid: |
|
1805 | while n != bottom and n != nullid: | |
1801 | p = self.changelog.parents(n)[0] |
|
1806 | p = self.changelog.parents(n)[0] | |
1802 | if i == f: |
|
1807 | if i == f: | |
1803 | l.append(n) |
|
1808 | l.append(n) | |
1804 | f = f * 2 |
|
1809 | f = f * 2 | |
1805 | n = p |
|
1810 | n = p | |
1806 | i += 1 |
|
1811 | i += 1 | |
1807 |
|
1812 | |||
1808 | r.append(l) |
|
1813 | r.append(l) | |
1809 |
|
1814 | |||
1810 | return r |
|
1815 | return r | |
1811 |
|
1816 | |||
1812 | def checkpush(self, pushop): |
|
1817 | def checkpush(self, pushop): | |
1813 | """Extensions can override this function if additional checks have |
|
1818 | """Extensions can override this function if additional checks have | |
1814 | to be performed before pushing, or call it if they override push |
|
1819 | to be performed before pushing, or call it if they override push | |
1815 | command. |
|
1820 | command. | |
1816 | """ |
|
1821 | """ | |
1817 | pass |
|
1822 | pass | |
1818 |
|
1823 | |||
1819 | @unfilteredpropertycache |
|
1824 | @unfilteredpropertycache | |
1820 | def prepushoutgoinghooks(self): |
|
1825 | def prepushoutgoinghooks(self): | |
1821 | """Return util.hooks consists of "(repo, remote, outgoing)" |
|
1826 | """Return util.hooks consists of "(repo, remote, outgoing)" | |
1822 | functions, which are called before pushing changesets. |
|
1827 | functions, which are called before pushing changesets. | |
1823 | """ |
|
1828 | """ | |
1824 | return util.hooks() |
|
1829 | return util.hooks() | |
1825 |
|
1830 | |||
1826 | def clone(self, remote, heads=[], stream=None): |
|
1831 | def clone(self, remote, heads=[], stream=None): | |
1827 | '''clone remote repository. |
|
1832 | '''clone remote repository. | |
1828 |
|
1833 | |||
1829 | keyword arguments: |
|
1834 | keyword arguments: | |
1830 | heads: list of revs to clone (forces use of pull) |
|
1835 | heads: list of revs to clone (forces use of pull) | |
1831 | stream: use streaming clone if possible''' |
|
1836 | stream: use streaming clone if possible''' | |
1832 | # internal config: ui.quietbookmarkmove |
|
1837 | # internal config: ui.quietbookmarkmove | |
1833 | quiet = self.ui.backupconfig('ui', 'quietbookmarkmove') |
|
1838 | quiet = self.ui.backupconfig('ui', 'quietbookmarkmove') | |
1834 | try: |
|
1839 | try: | |
1835 | self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone') |
|
1840 | self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone') | |
1836 | pullop = exchange.pull(self, remote, heads, |
|
1841 | pullop = exchange.pull(self, remote, heads, | |
1837 | streamclonerequested=stream) |
|
1842 | streamclonerequested=stream) | |
1838 | return pullop.cgresult |
|
1843 | return pullop.cgresult | |
1839 | finally: |
|
1844 | finally: | |
1840 | self.ui.restoreconfig(quiet) |
|
1845 | self.ui.restoreconfig(quiet) | |
1841 |
|
1846 | |||
1842 | def pushkey(self, namespace, key, old, new): |
|
1847 | def pushkey(self, namespace, key, old, new): | |
1843 | try: |
|
1848 | try: | |
1844 | tr = self.currenttransaction() |
|
1849 | tr = self.currenttransaction() | |
1845 | hookargs = {} |
|
1850 | hookargs = {} | |
1846 | if tr is not None: |
|
1851 | if tr is not None: | |
1847 | hookargs.update(tr.hookargs) |
|
1852 | hookargs.update(tr.hookargs) | |
1848 | pending = lambda: tr.writepending() and self.root or "" |
|
1853 | pending = lambda: tr.writepending() and self.root or "" | |
1849 | hookargs['pending'] = pending |
|
1854 | hookargs['pending'] = pending | |
1850 | hookargs['namespace'] = namespace |
|
1855 | hookargs['namespace'] = namespace | |
1851 | hookargs['key'] = key |
|
1856 | hookargs['key'] = key | |
1852 | hookargs['old'] = old |
|
1857 | hookargs['old'] = old | |
1853 | hookargs['new'] = new |
|
1858 | hookargs['new'] = new | |
1854 | self.hook('prepushkey', throw=True, **hookargs) |
|
1859 | self.hook('prepushkey', throw=True, **hookargs) | |
1855 | except error.HookAbort as exc: |
|
1860 | except error.HookAbort as exc: | |
1856 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) |
|
1861 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) | |
1857 | if exc.hint: |
|
1862 | if exc.hint: | |
1858 | self.ui.write_err(_("(%s)\n") % exc.hint) |
|
1863 | self.ui.write_err(_("(%s)\n") % exc.hint) | |
1859 | return False |
|
1864 | return False | |
1860 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) |
|
1865 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) | |
1861 | ret = pushkey.push(self, namespace, key, old, new) |
|
1866 | ret = pushkey.push(self, namespace, key, old, new) | |
1862 | def runhook(): |
|
1867 | def runhook(): | |
1863 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
1868 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, | |
1864 | ret=ret) |
|
1869 | ret=ret) | |
1865 | self._afterlock(runhook) |
|
1870 | self._afterlock(runhook) | |
1866 | return ret |
|
1871 | return ret | |
1867 |
|
1872 | |||
1868 | def listkeys(self, namespace): |
|
1873 | def listkeys(self, namespace): | |
1869 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
1874 | self.hook('prelistkeys', throw=True, namespace=namespace) | |
1870 | self.ui.debug('listing keys for "%s"\n' % namespace) |
|
1875 | self.ui.debug('listing keys for "%s"\n' % namespace) | |
1871 | values = pushkey.list(self, namespace) |
|
1876 | values = pushkey.list(self, namespace) | |
1872 | self.hook('listkeys', namespace=namespace, values=values) |
|
1877 | self.hook('listkeys', namespace=namespace, values=values) | |
1873 | return values |
|
1878 | return values | |
1874 |
|
1879 | |||
1875 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
1880 | def debugwireargs(self, one, two, three=None, four=None, five=None): | |
1876 | '''used to test argument passing over the wire''' |
|
1881 | '''used to test argument passing over the wire''' | |
1877 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
1882 | return "%s %s %s %s %s" % (one, two, three, four, five) | |
1878 |
|
1883 | |||
1879 | def savecommitmessage(self, text): |
|
1884 | def savecommitmessage(self, text): | |
1880 | fp = self.vfs('last-message.txt', 'wb') |
|
1885 | fp = self.vfs('last-message.txt', 'wb') | |
1881 | try: |
|
1886 | try: | |
1882 | fp.write(text) |
|
1887 | fp.write(text) | |
1883 | finally: |
|
1888 | finally: | |
1884 | fp.close() |
|
1889 | fp.close() | |
1885 | return self.pathto(fp.name[len(self.root) + 1:]) |
|
1890 | return self.pathto(fp.name[len(self.root) + 1:]) | |
1886 |
|
1891 | |||
1887 | # used to avoid circular references so destructors work |
|
1892 | # used to avoid circular references so destructors work | |
1888 | def aftertrans(files): |
|
1893 | def aftertrans(files): | |
1889 | renamefiles = [tuple(t) for t in files] |
|
1894 | renamefiles = [tuple(t) for t in files] | |
1890 | def a(): |
|
1895 | def a(): | |
1891 | for vfs, src, dest in renamefiles: |
|
1896 | for vfs, src, dest in renamefiles: | |
1892 | try: |
|
1897 | try: | |
1893 | vfs.rename(src, dest) |
|
1898 | vfs.rename(src, dest) | |
1894 | except OSError: # journal file does not yet exist |
|
1899 | except OSError: # journal file does not yet exist | |
1895 | pass |
|
1900 | pass | |
1896 | return a |
|
1901 | return a | |
1897 |
|
1902 | |||
1898 | def undoname(fn): |
|
1903 | def undoname(fn): | |
1899 | base, name = os.path.split(fn) |
|
1904 | base, name = os.path.split(fn) | |
1900 | assert name.startswith('journal') |
|
1905 | assert name.startswith('journal') | |
1901 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
1906 | return os.path.join(base, name.replace('journal', 'undo', 1)) | |
1902 |
|
1907 | |||
1903 | def instance(ui, path, create): |
|
1908 | def instance(ui, path, create): | |
1904 | return localrepository(ui, util.urllocalpath(path), create) |
|
1909 | return localrepository(ui, util.urllocalpath(path), create) | |
1905 |
|
1910 | |||
1906 | def islocal(path): |
|
1911 | def islocal(path): | |
1907 | return True |
|
1912 | return True |
@@ -1,1553 +1,1572 | |||||
1 | $ hg init a |
|
1 | $ hg init a | |
2 | $ mkdir a/d1 |
|
2 | $ mkdir a/d1 | |
3 | $ mkdir a/d1/d2 |
|
3 | $ mkdir a/d1/d2 | |
4 | $ echo line 1 > a/a |
|
4 | $ echo line 1 > a/a | |
5 | $ echo line 1 > a/d1/d2/a |
|
5 | $ echo line 1 > a/d1/d2/a | |
6 | $ hg --cwd a ci -Ama |
|
6 | $ hg --cwd a ci -Ama | |
7 | adding a |
|
7 | adding a | |
8 | adding d1/d2/a |
|
8 | adding d1/d2/a | |
9 |
|
9 | |||
10 | $ echo line 2 >> a/a |
|
10 | $ echo line 2 >> a/a | |
11 | $ hg --cwd a ci -u someone -d '1 0' -m'second change' |
|
11 | $ hg --cwd a ci -u someone -d '1 0' -m'second change' | |
12 |
|
12 | |||
13 | import with no args: |
|
13 | import with no args: | |
14 |
|
14 | |||
15 | $ hg --cwd a import |
|
15 | $ hg --cwd a import | |
16 | abort: need at least one patch to import |
|
16 | abort: need at least one patch to import | |
17 | [255] |
|
17 | [255] | |
18 |
|
18 | |||
19 | generate patches for the test |
|
19 | generate patches for the test | |
20 |
|
20 | |||
21 | $ hg --cwd a export tip > exported-tip.patch |
|
21 | $ hg --cwd a export tip > exported-tip.patch | |
22 | $ hg --cwd a diff -r0:1 > diffed-tip.patch |
|
22 | $ hg --cwd a diff -r0:1 > diffed-tip.patch | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | import exported patch |
|
25 | import exported patch | |
26 | (this also tests that editor is not invoked, if the patch contains the |
|
26 | (this also tests that editor is not invoked, if the patch contains the | |
27 | commit message and '--edit' is not specified) |
|
27 | commit message and '--edit' is not specified) | |
28 |
|
28 | |||
29 | $ hg clone -r0 a b |
|
29 | $ hg clone -r0 a b | |
30 | adding changesets |
|
30 | adding changesets | |
31 | adding manifests |
|
31 | adding manifests | |
32 | adding file changes |
|
32 | adding file changes | |
33 | added 1 changesets with 2 changes to 2 files |
|
33 | added 1 changesets with 2 changes to 2 files | |
34 | updating to branch default |
|
34 | updating to branch default | |
35 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
35 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
36 | $ HGEDITOR=cat hg --cwd b import ../exported-tip.patch |
|
36 | $ HGEDITOR=cat hg --cwd b import ../exported-tip.patch | |
37 | applying ../exported-tip.patch |
|
37 | applying ../exported-tip.patch | |
38 |
|
38 | |||
39 | message and committer and date should be same |
|
39 | message and committer and date should be same | |
40 |
|
40 | |||
41 | $ hg --cwd b tip |
|
41 | $ hg --cwd b tip | |
42 | changeset: 1:1d4bd90af0e4 |
|
42 | changeset: 1:1d4bd90af0e4 | |
43 | tag: tip |
|
43 | tag: tip | |
44 | user: someone |
|
44 | user: someone | |
45 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
45 | date: Thu Jan 01 00:00:01 1970 +0000 | |
46 | summary: second change |
|
46 | summary: second change | |
47 |
|
47 | |||
48 | $ rm -r b |
|
48 | $ rm -r b | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | import exported patch with external patcher |
|
51 | import exported patch with external patcher | |
52 | (this also tests that editor is invoked, if the '--edit' is specified, |
|
52 | (this also tests that editor is invoked, if the '--edit' is specified, | |
53 | regardless of the commit message in the patch) |
|
53 | regardless of the commit message in the patch) | |
54 |
|
54 | |||
55 | $ cat > dummypatch.py <<EOF |
|
55 | $ cat > dummypatch.py <<EOF | |
56 | > print 'patching file a' |
|
56 | > print 'patching file a' | |
57 | > file('a', 'wb').write('line2\n') |
|
57 | > file('a', 'wb').write('line2\n') | |
58 | > EOF |
|
58 | > EOF | |
59 | $ hg clone -r0 a b |
|
59 | $ hg clone -r0 a b | |
60 | adding changesets |
|
60 | adding changesets | |
61 | adding manifests |
|
61 | adding manifests | |
62 | adding file changes |
|
62 | adding file changes | |
63 | added 1 changesets with 2 changes to 2 files |
|
63 | added 1 changesets with 2 changes to 2 files | |
64 | updating to branch default |
|
64 | updating to branch default | |
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
66 | $ HGEDITOR=cat hg --config ui.patch='python ../dummypatch.py' --cwd b import --edit ../exported-tip.patch |
|
66 | $ HGEDITOR=cat hg --config ui.patch='python ../dummypatch.py' --cwd b import --edit ../exported-tip.patch | |
67 | applying ../exported-tip.patch |
|
67 | applying ../exported-tip.patch | |
68 | second change |
|
68 | second change | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
71 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
72 | HG: Leave message empty to abort commit. |
|
72 | HG: Leave message empty to abort commit. | |
73 | HG: -- |
|
73 | HG: -- | |
74 | HG: user: someone |
|
74 | HG: user: someone | |
75 | HG: branch 'default' |
|
75 | HG: branch 'default' | |
76 | HG: changed a |
|
76 | HG: changed a | |
77 | $ cat b/a |
|
77 | $ cat b/a | |
78 | line2 |
|
78 | line2 | |
79 | $ rm -r b |
|
79 | $ rm -r b | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | import of plain diff should fail without message |
|
82 | import of plain diff should fail without message | |
83 | (this also tests that editor is invoked, if the patch doesn't contain |
|
83 | (this also tests that editor is invoked, if the patch doesn't contain | |
84 | the commit message, regardless of '--edit') |
|
84 | the commit message, regardless of '--edit') | |
85 |
|
85 | |||
86 | $ hg clone -r0 a b |
|
86 | $ hg clone -r0 a b | |
87 | adding changesets |
|
87 | adding changesets | |
88 | adding manifests |
|
88 | adding manifests | |
89 | adding file changes |
|
89 | adding file changes | |
90 | added 1 changesets with 2 changes to 2 files |
|
90 | added 1 changesets with 2 changes to 2 files | |
91 | updating to branch default |
|
91 | updating to branch default | |
92 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
92 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
93 | $ cat > $TESTTMP/editor.sh <<EOF |
|
93 | $ cat > $TESTTMP/editor.sh <<EOF | |
94 | > env | grep HGEDITFORM |
|
94 | > env | grep HGEDITFORM | |
95 | > cat \$1 |
|
95 | > cat \$1 | |
96 | > EOF |
|
96 | > EOF | |
97 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg --cwd b import ../diffed-tip.patch |
|
97 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg --cwd b import ../diffed-tip.patch | |
98 | applying ../diffed-tip.patch |
|
98 | applying ../diffed-tip.patch | |
99 | HGEDITFORM=import.normal.normal |
|
99 | HGEDITFORM=import.normal.normal | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
102 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
103 | HG: Leave message empty to abort commit. |
|
103 | HG: Leave message empty to abort commit. | |
104 | HG: -- |
|
104 | HG: -- | |
105 | HG: user: test |
|
105 | HG: user: test | |
106 | HG: branch 'default' |
|
106 | HG: branch 'default' | |
107 | HG: changed a |
|
107 | HG: changed a | |
108 | abort: empty commit message |
|
108 | abort: empty commit message | |
109 | [255] |
|
109 | [255] | |
110 |
|
110 | |||
111 | Test avoiding editor invocation at applying the patch with --exact, |
|
111 | Test avoiding editor invocation at applying the patch with --exact, | |
112 | even if commit message is empty |
|
112 | even if commit message is empty | |
113 |
|
113 | |||
114 | $ echo a >> b/a |
|
114 | $ echo a >> b/a | |
115 | $ hg --cwd b commit -m ' ' |
|
115 | $ hg --cwd b commit -m ' ' | |
116 | $ hg --cwd b tip -T "{node}\n" |
|
116 | $ hg --cwd b tip -T "{node}\n" | |
117 | d8804f3f5396d800812f579c8452796a5993bdb2 |
|
117 | d8804f3f5396d800812f579c8452796a5993bdb2 | |
118 | $ hg --cwd b export -o ../empty-log.diff . |
|
118 | $ hg --cwd b export -o ../empty-log.diff . | |
119 | $ hg --cwd b update -q -C ".^1" |
|
119 | $ hg --cwd b update -q -C ".^1" | |
120 | $ hg --cwd b --config extensions.strip= strip -q tip |
|
120 | $ hg --cwd b --config extensions.strip= strip -q tip | |
121 | $ HGEDITOR=cat hg --cwd b import --exact ../empty-log.diff |
|
121 | $ HGEDITOR=cat hg --cwd b import --exact ../empty-log.diff | |
122 | applying ../empty-log.diff |
|
122 | applying ../empty-log.diff | |
123 | $ hg --cwd b tip -T "{node}\n" |
|
123 | $ hg --cwd b tip -T "{node}\n" | |
124 | d8804f3f5396d800812f579c8452796a5993bdb2 |
|
124 | d8804f3f5396d800812f579c8452796a5993bdb2 | |
125 |
|
125 | |||
126 | $ rm -r b |
|
126 | $ rm -r b | |
127 |
|
127 | |||
128 |
|
128 | |||
129 | import of plain diff should be ok with message |
|
129 | import of plain diff should be ok with message | |
130 |
|
130 | |||
131 | $ hg clone -r0 a b |
|
131 | $ hg clone -r0 a b | |
132 | adding changesets |
|
132 | adding changesets | |
133 | adding manifests |
|
133 | adding manifests | |
134 | adding file changes |
|
134 | adding file changes | |
135 | added 1 changesets with 2 changes to 2 files |
|
135 | added 1 changesets with 2 changes to 2 files | |
136 | updating to branch default |
|
136 | updating to branch default | |
137 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
137 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
138 | $ hg --cwd b import -mpatch ../diffed-tip.patch |
|
138 | $ hg --cwd b import -mpatch ../diffed-tip.patch | |
139 | applying ../diffed-tip.patch |
|
139 | applying ../diffed-tip.patch | |
140 | $ rm -r b |
|
140 | $ rm -r b | |
141 |
|
141 | |||
142 |
|
142 | |||
143 | import of plain diff with specific date and user |
|
143 | import of plain diff with specific date and user | |
144 | (this also tests that editor is not invoked, if |
|
144 | (this also tests that editor is not invoked, if | |
145 | '--message'/'--logfile' is specified and '--edit' is not) |
|
145 | '--message'/'--logfile' is specified and '--edit' is not) | |
146 |
|
146 | |||
147 | $ hg clone -r0 a b |
|
147 | $ hg clone -r0 a b | |
148 | adding changesets |
|
148 | adding changesets | |
149 | adding manifests |
|
149 | adding manifests | |
150 | adding file changes |
|
150 | adding file changes | |
151 | added 1 changesets with 2 changes to 2 files |
|
151 | added 1 changesets with 2 changes to 2 files | |
152 | updating to branch default |
|
152 | updating to branch default | |
153 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
153 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
154 | $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../diffed-tip.patch |
|
154 | $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../diffed-tip.patch | |
155 | applying ../diffed-tip.patch |
|
155 | applying ../diffed-tip.patch | |
156 | $ hg -R b tip -pv |
|
156 | $ hg -R b tip -pv | |
157 | changeset: 1:ca68f19f3a40 |
|
157 | changeset: 1:ca68f19f3a40 | |
158 | tag: tip |
|
158 | tag: tip | |
159 | user: user@nowhere.net |
|
159 | user: user@nowhere.net | |
160 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
160 | date: Thu Jan 01 00:00:01 1970 +0000 | |
161 | files: a |
|
161 | files: a | |
162 | description: |
|
162 | description: | |
163 | patch |
|
163 | patch | |
164 |
|
164 | |||
165 |
|
165 | |||
166 | diff -r 80971e65b431 -r ca68f19f3a40 a |
|
166 | diff -r 80971e65b431 -r ca68f19f3a40 a | |
167 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
167 | --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
168 | +++ b/a Thu Jan 01 00:00:01 1970 +0000 |
|
168 | +++ b/a Thu Jan 01 00:00:01 1970 +0000 | |
169 | @@ -1,1 +1,2 @@ |
|
169 | @@ -1,1 +1,2 @@ | |
170 | line 1 |
|
170 | line 1 | |
171 | +line 2 |
|
171 | +line 2 | |
172 |
|
172 | |||
173 | $ rm -r b |
|
173 | $ rm -r b | |
174 |
|
174 | |||
175 |
|
175 | |||
176 | import of plain diff should be ok with --no-commit |
|
176 | import of plain diff should be ok with --no-commit | |
177 | (this also tests that editor is not invoked, if '--no-commit' is |
|
177 | (this also tests that editor is not invoked, if '--no-commit' is | |
178 | specified, regardless of '--edit') |
|
178 | specified, regardless of '--edit') | |
179 |
|
179 | |||
180 | $ hg clone -r0 a b |
|
180 | $ hg clone -r0 a b | |
181 | adding changesets |
|
181 | adding changesets | |
182 | adding manifests |
|
182 | adding manifests | |
183 | adding file changes |
|
183 | adding file changes | |
184 | added 1 changesets with 2 changes to 2 files |
|
184 | added 1 changesets with 2 changes to 2 files | |
185 | updating to branch default |
|
185 | updating to branch default | |
186 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
186 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
187 | $ HGEDITOR=cat hg --cwd b import --no-commit --edit ../diffed-tip.patch |
|
187 | $ HGEDITOR=cat hg --cwd b import --no-commit --edit ../diffed-tip.patch | |
188 | applying ../diffed-tip.patch |
|
188 | applying ../diffed-tip.patch | |
189 | $ hg --cwd b diff --nodates |
|
189 | $ hg --cwd b diff --nodates | |
190 | diff -r 80971e65b431 a |
|
190 | diff -r 80971e65b431 a | |
191 | --- a/a |
|
191 | --- a/a | |
192 | +++ b/a |
|
192 | +++ b/a | |
193 | @@ -1,1 +1,2 @@ |
|
193 | @@ -1,1 +1,2 @@ | |
194 | line 1 |
|
194 | line 1 | |
195 | +line 2 |
|
195 | +line 2 | |
196 | $ rm -r b |
|
196 | $ rm -r b | |
197 |
|
197 | |||
198 |
|
198 | |||
199 | import of malformed plain diff should fail |
|
199 | import of malformed plain diff should fail | |
200 |
|
200 | |||
201 | $ hg clone -r0 a b |
|
201 | $ hg clone -r0 a b | |
202 | adding changesets |
|
202 | adding changesets | |
203 | adding manifests |
|
203 | adding manifests | |
204 | adding file changes |
|
204 | adding file changes | |
205 | added 1 changesets with 2 changes to 2 files |
|
205 | added 1 changesets with 2 changes to 2 files | |
206 | updating to branch default |
|
206 | updating to branch default | |
207 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
207 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
208 | $ sed 's/1,1/foo/' < diffed-tip.patch > broken.patch |
|
208 | $ sed 's/1,1/foo/' < diffed-tip.patch > broken.patch | |
209 | $ hg --cwd b import -mpatch ../broken.patch |
|
209 | $ hg --cwd b import -mpatch ../broken.patch | |
210 | applying ../broken.patch |
|
210 | applying ../broken.patch | |
211 | abort: bad hunk #1 |
|
211 | abort: bad hunk #1 | |
212 | [255] |
|
212 | [255] | |
213 | $ rm -r b |
|
213 | $ rm -r b | |
214 |
|
214 | |||
215 |
|
215 | |||
216 | hg -R repo import |
|
216 | hg -R repo import | |
217 | put the clone in a subdir - having a directory named "a" |
|
217 | put the clone in a subdir - having a directory named "a" | |
218 | used to hide a bug. |
|
218 | used to hide a bug. | |
219 |
|
219 | |||
220 | $ mkdir dir |
|
220 | $ mkdir dir | |
221 | $ hg clone -r0 a dir/b |
|
221 | $ hg clone -r0 a dir/b | |
222 | adding changesets |
|
222 | adding changesets | |
223 | adding manifests |
|
223 | adding manifests | |
224 | adding file changes |
|
224 | adding file changes | |
225 | added 1 changesets with 2 changes to 2 files |
|
225 | added 1 changesets with 2 changes to 2 files | |
226 | updating to branch default |
|
226 | updating to branch default | |
227 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
227 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
228 | $ cd dir |
|
228 | $ cd dir | |
229 | $ hg -R b import ../exported-tip.patch |
|
229 | $ hg -R b import ../exported-tip.patch | |
230 | applying ../exported-tip.patch |
|
230 | applying ../exported-tip.patch | |
231 | $ cd .. |
|
231 | $ cd .. | |
232 | $ rm -r dir |
|
232 | $ rm -r dir | |
233 |
|
233 | |||
234 |
|
234 | |||
235 | import from stdin |
|
235 | import from stdin | |
236 |
|
236 | |||
237 | $ hg clone -r0 a b |
|
237 | $ hg clone -r0 a b | |
238 | adding changesets |
|
238 | adding changesets | |
239 | adding manifests |
|
239 | adding manifests | |
240 | adding file changes |
|
240 | adding file changes | |
241 | added 1 changesets with 2 changes to 2 files |
|
241 | added 1 changesets with 2 changes to 2 files | |
242 | updating to branch default |
|
242 | updating to branch default | |
243 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
243 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
244 | $ hg --cwd b import - < exported-tip.patch |
|
244 | $ hg --cwd b import - < exported-tip.patch | |
245 | applying patch from stdin |
|
245 | applying patch from stdin | |
246 | $ rm -r b |
|
246 | $ rm -r b | |
247 |
|
247 | |||
248 |
|
248 | |||
249 | import two patches in one stream |
|
249 | import two patches in one stream | |
250 |
|
250 | |||
251 | $ hg init b |
|
251 | $ hg init b | |
252 | $ hg --cwd a export 0:tip | hg --cwd b import - |
|
252 | $ hg --cwd a export 0:tip | hg --cwd b import - | |
253 | applying patch from stdin |
|
253 | applying patch from stdin | |
254 | $ hg --cwd a id |
|
254 | $ hg --cwd a id | |
255 | 1d4bd90af0e4 tip |
|
255 | 1d4bd90af0e4 tip | |
256 | $ hg --cwd b id |
|
256 | $ hg --cwd b id | |
257 | 1d4bd90af0e4 tip |
|
257 | 1d4bd90af0e4 tip | |
258 | $ rm -r b |
|
258 | $ rm -r b | |
259 |
|
259 | |||
260 |
|
260 | |||
261 | override commit message |
|
261 | override commit message | |
262 |
|
262 | |||
263 | $ hg clone -r0 a b |
|
263 | $ hg clone -r0 a b | |
264 | adding changesets |
|
264 | adding changesets | |
265 | adding manifests |
|
265 | adding manifests | |
266 | adding file changes |
|
266 | adding file changes | |
267 | added 1 changesets with 2 changes to 2 files |
|
267 | added 1 changesets with 2 changes to 2 files | |
268 | updating to branch default |
|
268 | updating to branch default | |
269 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
269 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
270 | $ hg --cwd b import -m 'override' - < exported-tip.patch |
|
270 | $ hg --cwd b import -m 'override' - < exported-tip.patch | |
271 | applying patch from stdin |
|
271 | applying patch from stdin | |
272 | $ hg --cwd b tip | grep override |
|
272 | $ hg --cwd b tip | grep override | |
273 | summary: override |
|
273 | summary: override | |
274 | $ rm -r b |
|
274 | $ rm -r b | |
275 |
|
275 | |||
276 | $ cat > mkmsg.py <<EOF |
|
276 | $ cat > mkmsg.py <<EOF | |
277 | > import email.Message, sys |
|
277 | > import email.Message, sys | |
278 | > msg = email.Message.Message() |
|
278 | > msg = email.Message.Message() | |
279 | > patch = open(sys.argv[1], 'rb').read() |
|
279 | > patch = open(sys.argv[1], 'rb').read() | |
280 | > msg.set_payload('email commit message\n' + patch) |
|
280 | > msg.set_payload('email commit message\n' + patch) | |
281 | > msg['Subject'] = 'email patch' |
|
281 | > msg['Subject'] = 'email patch' | |
282 | > msg['From'] = 'email patcher' |
|
282 | > msg['From'] = 'email patcher' | |
283 | > file(sys.argv[2], 'wb').write(msg.as_string()) |
|
283 | > file(sys.argv[2], 'wb').write(msg.as_string()) | |
284 | > EOF |
|
284 | > EOF | |
285 |
|
285 | |||
286 |
|
286 | |||
287 | plain diff in email, subject, message body |
|
287 | plain diff in email, subject, message body | |
288 |
|
288 | |||
289 | $ hg clone -r0 a b |
|
289 | $ hg clone -r0 a b | |
290 | adding changesets |
|
290 | adding changesets | |
291 | adding manifests |
|
291 | adding manifests | |
292 | adding file changes |
|
292 | adding file changes | |
293 | added 1 changesets with 2 changes to 2 files |
|
293 | added 1 changesets with 2 changes to 2 files | |
294 | updating to branch default |
|
294 | updating to branch default | |
295 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
295 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
296 | $ python mkmsg.py diffed-tip.patch msg.patch |
|
296 | $ python mkmsg.py diffed-tip.patch msg.patch | |
297 | $ hg --cwd b import ../msg.patch |
|
297 | $ hg --cwd b import ../msg.patch | |
298 | applying ../msg.patch |
|
298 | applying ../msg.patch | |
299 | $ hg --cwd b tip | grep email |
|
299 | $ hg --cwd b tip | grep email | |
300 | user: email patcher |
|
300 | user: email patcher | |
301 | summary: email patch |
|
301 | summary: email patch | |
302 | $ rm -r b |
|
302 | $ rm -r b | |
303 |
|
303 | |||
304 |
|
304 | |||
305 | plain diff in email, no subject, message body |
|
305 | plain diff in email, no subject, message body | |
306 |
|
306 | |||
307 | $ hg clone -r0 a b |
|
307 | $ hg clone -r0 a b | |
308 | adding changesets |
|
308 | adding changesets | |
309 | adding manifests |
|
309 | adding manifests | |
310 | adding file changes |
|
310 | adding file changes | |
311 | added 1 changesets with 2 changes to 2 files |
|
311 | added 1 changesets with 2 changes to 2 files | |
312 | updating to branch default |
|
312 | updating to branch default | |
313 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
313 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
314 | $ grep -v '^Subject:' msg.patch | hg --cwd b import - |
|
314 | $ grep -v '^Subject:' msg.patch | hg --cwd b import - | |
315 | applying patch from stdin |
|
315 | applying patch from stdin | |
316 | $ rm -r b |
|
316 | $ rm -r b | |
317 |
|
317 | |||
318 |
|
318 | |||
319 | plain diff in email, subject, no message body |
|
319 | plain diff in email, subject, no message body | |
320 |
|
320 | |||
321 | $ hg clone -r0 a b |
|
321 | $ hg clone -r0 a b | |
322 | adding changesets |
|
322 | adding changesets | |
323 | adding manifests |
|
323 | adding manifests | |
324 | adding file changes |
|
324 | adding file changes | |
325 | added 1 changesets with 2 changes to 2 files |
|
325 | added 1 changesets with 2 changes to 2 files | |
326 | updating to branch default |
|
326 | updating to branch default | |
327 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
327 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
328 | $ grep -v '^email ' msg.patch | hg --cwd b import - |
|
328 | $ grep -v '^email ' msg.patch | hg --cwd b import - | |
329 | applying patch from stdin |
|
329 | applying patch from stdin | |
330 | $ rm -r b |
|
330 | $ rm -r b | |
331 |
|
331 | |||
332 |
|
332 | |||
333 | plain diff in email, no subject, no message body, should fail |
|
333 | plain diff in email, no subject, no message body, should fail | |
334 |
|
334 | |||
335 | $ hg clone -r0 a b |
|
335 | $ hg clone -r0 a b | |
336 | adding changesets |
|
336 | adding changesets | |
337 | adding manifests |
|
337 | adding manifests | |
338 | adding file changes |
|
338 | adding file changes | |
339 | added 1 changesets with 2 changes to 2 files |
|
339 | added 1 changesets with 2 changes to 2 files | |
340 | updating to branch default |
|
340 | updating to branch default | |
341 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
341 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
342 | $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - |
|
342 | $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - | |
343 | applying patch from stdin |
|
343 | applying patch from stdin | |
344 | abort: empty commit message |
|
344 | abort: empty commit message | |
345 | [255] |
|
345 | [255] | |
346 | $ rm -r b |
|
346 | $ rm -r b | |
347 |
|
347 | |||
348 |
|
348 | |||
349 | hg export in email, should use patch header |
|
349 | hg export in email, should use patch header | |
350 |
|
350 | |||
351 | $ hg clone -r0 a b |
|
351 | $ hg clone -r0 a b | |
352 | adding changesets |
|
352 | adding changesets | |
353 | adding manifests |
|
353 | adding manifests | |
354 | adding file changes |
|
354 | adding file changes | |
355 | added 1 changesets with 2 changes to 2 files |
|
355 | added 1 changesets with 2 changes to 2 files | |
356 | updating to branch default |
|
356 | updating to branch default | |
357 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
357 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
358 | $ python mkmsg.py exported-tip.patch msg.patch |
|
358 | $ python mkmsg.py exported-tip.patch msg.patch | |
359 | $ cat msg.patch | hg --cwd b import - |
|
359 | $ cat msg.patch | hg --cwd b import - | |
360 | applying patch from stdin |
|
360 | applying patch from stdin | |
361 | $ hg --cwd b tip | grep second |
|
361 | $ hg --cwd b tip | grep second | |
362 | summary: second change |
|
362 | summary: second change | |
363 | $ rm -r b |
|
363 | $ rm -r b | |
364 |
|
364 | |||
365 |
|
365 | |||
366 | subject: duplicate detection, removal of [PATCH] |
|
366 | subject: duplicate detection, removal of [PATCH] | |
367 | The '---' tests the gitsendmail handling without proper mail headers |
|
367 | The '---' tests the gitsendmail handling without proper mail headers | |
368 |
|
368 | |||
369 | $ cat > mkmsg2.py <<EOF |
|
369 | $ cat > mkmsg2.py <<EOF | |
370 | > import email.Message, sys |
|
370 | > import email.Message, sys | |
371 | > msg = email.Message.Message() |
|
371 | > msg = email.Message.Message() | |
372 | > patch = open(sys.argv[1], 'rb').read() |
|
372 | > patch = open(sys.argv[1], 'rb').read() | |
373 | > msg.set_payload('email patch\n\nnext line\n---\n' + patch) |
|
373 | > msg.set_payload('email patch\n\nnext line\n---\n' + patch) | |
374 | > msg['Subject'] = '[PATCH] email patch' |
|
374 | > msg['Subject'] = '[PATCH] email patch' | |
375 | > msg['From'] = 'email patcher' |
|
375 | > msg['From'] = 'email patcher' | |
376 | > file(sys.argv[2], 'wb').write(msg.as_string()) |
|
376 | > file(sys.argv[2], 'wb').write(msg.as_string()) | |
377 | > EOF |
|
377 | > EOF | |
378 |
|
378 | |||
379 |
|
379 | |||
380 | plain diff in email, [PATCH] subject, message body with subject |
|
380 | plain diff in email, [PATCH] subject, message body with subject | |
381 |
|
381 | |||
382 | $ hg clone -r0 a b |
|
382 | $ hg clone -r0 a b | |
383 | adding changesets |
|
383 | adding changesets | |
384 | adding manifests |
|
384 | adding manifests | |
385 | adding file changes |
|
385 | adding file changes | |
386 | added 1 changesets with 2 changes to 2 files |
|
386 | added 1 changesets with 2 changes to 2 files | |
387 | updating to branch default |
|
387 | updating to branch default | |
388 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
388 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
389 | $ python mkmsg2.py diffed-tip.patch msg.patch |
|
389 | $ python mkmsg2.py diffed-tip.patch msg.patch | |
390 | $ cat msg.patch | hg --cwd b import - |
|
390 | $ cat msg.patch | hg --cwd b import - | |
391 | applying patch from stdin |
|
391 | applying patch from stdin | |
392 | $ hg --cwd b tip --template '{desc}\n' |
|
392 | $ hg --cwd b tip --template '{desc}\n' | |
393 | email patch |
|
393 | email patch | |
394 |
|
394 | |||
395 | next line |
|
395 | next line | |
396 | $ rm -r b |
|
396 | $ rm -r b | |
397 |
|
397 | |||
398 |
|
398 | |||
399 | Issue963: Parent of working dir incorrect after import of multiple |
|
399 | Issue963: Parent of working dir incorrect after import of multiple | |
400 | patches and rollback |
|
400 | patches and rollback | |
401 |
|
401 | |||
402 | We weren't backing up the correct dirstate file when importing many |
|
402 | We weren't backing up the correct dirstate file when importing many | |
403 | patches: import patch1 patch2; rollback |
|
403 | patches: import patch1 patch2; rollback | |
404 |
|
404 | |||
405 | $ echo line 3 >> a/a |
|
405 | $ echo line 3 >> a/a | |
406 | $ hg --cwd a ci -m'third change' |
|
406 | $ hg --cwd a ci -m'third change' | |
407 | $ hg --cwd a export -o '../patch%R' 1 2 |
|
407 | $ hg --cwd a export -o '../patch%R' 1 2 | |
408 | $ hg clone -qr0 a b |
|
408 | $ hg clone -qr0 a b | |
409 | $ hg --cwd b parents --template 'parent: {rev}\n' |
|
409 | $ hg --cwd b parents --template 'parent: {rev}\n' | |
410 | parent: 0 |
|
410 | parent: 0 | |
411 | $ hg --cwd b import -v ../patch1 ../patch2 |
|
411 | $ hg --cwd b import -v ../patch1 ../patch2 | |
412 | applying ../patch1 |
|
412 | applying ../patch1 | |
413 | patching file a |
|
413 | patching file a | |
414 | committing files: |
|
414 | committing files: | |
415 | a |
|
415 | a | |
416 | committing manifest |
|
416 | committing manifest | |
417 | committing changelog |
|
417 | committing changelog | |
418 | created 1d4bd90af0e4 |
|
418 | created 1d4bd90af0e4 | |
419 | applying ../patch2 |
|
419 | applying ../patch2 | |
420 | patching file a |
|
420 | patching file a | |
421 | committing files: |
|
421 | committing files: | |
422 | a |
|
422 | a | |
423 | committing manifest |
|
423 | committing manifest | |
424 | committing changelog |
|
424 | committing changelog | |
425 | created 6d019af21222 |
|
425 | created 6d019af21222 | |
426 | $ hg --cwd b rollback |
|
426 | $ hg --cwd b rollback | |
427 | repository tip rolled back to revision 0 (undo import) |
|
427 | repository tip rolled back to revision 0 (undo import) | |
428 | working directory now based on revision 0 |
|
428 | working directory now based on revision 0 | |
429 | $ hg --cwd b parents --template 'parent: {rev}\n' |
|
429 | $ hg --cwd b parents --template 'parent: {rev}\n' | |
430 | parent: 0 |
|
430 | parent: 0 | |
|
431 | ||||
|
432 | Test that "hg rollback" doesn't restore dirstate to one at the | |||
|
433 | beginning of the rollbacked transaction in not-"parent-gone" case. | |||
|
434 | ||||
|
435 | invoking pretxncommit hook will cause marking '.hg/dirstate' as a file | |||
|
436 | to be restored at rollbacking, after DirstateTransactionPlan (see wiki | |||
|
437 | page for detail). | |||
|
438 | ||||
|
439 | $ hg --cwd b branch -q foobar | |||
|
440 | $ hg --cwd b commit -m foobar | |||
|
441 | $ hg --cwd b update 0 -q | |||
|
442 | $ hg --cwd b import ../patch1 ../patch2 --config hooks.pretxncommit=true | |||
|
443 | applying ../patch1 | |||
|
444 | applying ../patch2 | |||
|
445 | $ hg --cwd b update -q 1 | |||
|
446 | $ hg --cwd b rollback -q | |||
|
447 | $ hg --cwd b parents --template 'parent: {rev}\n' | |||
|
448 | parent: 1 | |||
|
449 | ||||
431 | $ rm -r b |
|
450 | $ rm -r b | |
432 |
|
451 | |||
433 |
|
452 | |||
434 | importing a patch in a subdirectory failed at the commit stage |
|
453 | importing a patch in a subdirectory failed at the commit stage | |
435 |
|
454 | |||
436 | $ echo line 2 >> a/d1/d2/a |
|
455 | $ echo line 2 >> a/d1/d2/a | |
437 |
$ hg --cwd a ci -u someoneelse -d '1 |
|
456 | $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' | |
438 |
|
457 | |||
439 | hg import in a subdirectory |
|
458 | hg import in a subdirectory | |
440 |
|
459 | |||
441 | $ hg clone -r0 a b |
|
460 | $ hg clone -r0 a b | |
442 | adding changesets |
|
461 | adding changesets | |
443 | adding manifests |
|
462 | adding manifests | |
444 | adding file changes |
|
463 | adding file changes | |
445 | added 1 changesets with 2 changes to 2 files |
|
464 | added 1 changesets with 2 changes to 2 files | |
446 | updating to branch default |
|
465 | updating to branch default | |
447 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
466 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
448 | $ hg --cwd a export tip > tmp |
|
467 | $ hg --cwd a export tip > tmp | |
449 | $ sed -e 's/d1\/d2\///' < tmp > subdir-tip.patch |
|
468 | $ sed -e 's/d1\/d2\///' < tmp > subdir-tip.patch | |
450 | $ dir=`pwd` |
|
469 | $ dir=`pwd` | |
451 | $ cd b/d1/d2 2>&1 > /dev/null |
|
470 | $ cd b/d1/d2 2>&1 > /dev/null | |
452 | $ hg import ../../../subdir-tip.patch |
|
471 | $ hg import ../../../subdir-tip.patch | |
453 | applying ../../../subdir-tip.patch |
|
472 | applying ../../../subdir-tip.patch | |
454 | $ cd "$dir" |
|
473 | $ cd "$dir" | |
455 |
|
474 | |||
456 | message should be 'subdir change' |
|
475 | message should be 'subdir change' | |
457 | committer should be 'someoneelse' |
|
476 | committer should be 'someoneelse' | |
458 |
|
477 | |||
459 | $ hg --cwd b tip |
|
478 | $ hg --cwd b tip | |
460 | changeset: 1:3577f5aea227 |
|
479 | changeset: 1:3577f5aea227 | |
461 | tag: tip |
|
480 | tag: tip | |
462 | user: someoneelse |
|
481 | user: someoneelse | |
463 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
482 | date: Thu Jan 01 00:00:01 1970 +0000 | |
464 | summary: subdir change |
|
483 | summary: subdir change | |
465 |
|
484 | |||
466 |
|
485 | |||
467 | should be empty |
|
486 | should be empty | |
468 |
|
487 | |||
469 | $ hg --cwd b status |
|
488 | $ hg --cwd b status | |
470 |
|
489 | |||
471 |
|
490 | |||
472 | Test fuzziness (ambiguous patch location, fuzz=2) |
|
491 | Test fuzziness (ambiguous patch location, fuzz=2) | |
473 |
|
492 | |||
474 | $ hg init fuzzy |
|
493 | $ hg init fuzzy | |
475 | $ cd fuzzy |
|
494 | $ cd fuzzy | |
476 | $ echo line1 > a |
|
495 | $ echo line1 > a | |
477 | $ echo line0 >> a |
|
496 | $ echo line0 >> a | |
478 | $ echo line3 >> a |
|
497 | $ echo line3 >> a | |
479 | $ hg ci -Am adda |
|
498 | $ hg ci -Am adda | |
480 | adding a |
|
499 | adding a | |
481 | $ echo line1 > a |
|
500 | $ echo line1 > a | |
482 | $ echo line2 >> a |
|
501 | $ echo line2 >> a | |
483 | $ echo line0 >> a |
|
502 | $ echo line0 >> a | |
484 | $ echo line3 >> a |
|
503 | $ echo line3 >> a | |
485 | $ hg ci -m change a |
|
504 | $ hg ci -m change a | |
486 | $ hg export tip > fuzzy-tip.patch |
|
505 | $ hg export tip > fuzzy-tip.patch | |
487 | $ hg up -C 0 |
|
506 | $ hg up -C 0 | |
488 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
507 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
489 | $ echo line1 > a |
|
508 | $ echo line1 > a | |
490 | $ echo line0 >> a |
|
509 | $ echo line0 >> a | |
491 | $ echo line1 >> a |
|
510 | $ echo line1 >> a | |
492 | $ echo line0 >> a |
|
511 | $ echo line0 >> a | |
493 | $ hg ci -m brancha |
|
512 | $ hg ci -m brancha | |
494 | created new head |
|
513 | created new head | |
495 | $ hg import --config patch.fuzz=0 -v fuzzy-tip.patch |
|
514 | $ hg import --config patch.fuzz=0 -v fuzzy-tip.patch | |
496 | applying fuzzy-tip.patch |
|
515 | applying fuzzy-tip.patch | |
497 | patching file a |
|
516 | patching file a | |
498 | Hunk #1 FAILED at 0 |
|
517 | Hunk #1 FAILED at 0 | |
499 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
518 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
500 | abort: patch failed to apply |
|
519 | abort: patch failed to apply | |
501 | [255] |
|
520 | [255] | |
502 | $ hg import --no-commit -v fuzzy-tip.patch |
|
521 | $ hg import --no-commit -v fuzzy-tip.patch | |
503 | applying fuzzy-tip.patch |
|
522 | applying fuzzy-tip.patch | |
504 | patching file a |
|
523 | patching file a | |
505 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). |
|
524 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). | |
506 | applied to working directory |
|
525 | applied to working directory | |
507 | $ hg revert -a |
|
526 | $ hg revert -a | |
508 | reverting a |
|
527 | reverting a | |
509 |
|
528 | |||
510 |
|
529 | |||
511 | import with --no-commit should have written .hg/last-message.txt |
|
530 | import with --no-commit should have written .hg/last-message.txt | |
512 |
|
531 | |||
513 | $ cat .hg/last-message.txt |
|
532 | $ cat .hg/last-message.txt | |
514 | change (no-eol) |
|
533 | change (no-eol) | |
515 |
|
534 | |||
516 |
|
535 | |||
517 | test fuzziness with eol=auto |
|
536 | test fuzziness with eol=auto | |
518 |
|
537 | |||
519 | $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch |
|
538 | $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch | |
520 | applying fuzzy-tip.patch |
|
539 | applying fuzzy-tip.patch | |
521 | patching file a |
|
540 | patching file a | |
522 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). |
|
541 | Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines). | |
523 | applied to working directory |
|
542 | applied to working directory | |
524 | $ cd .. |
|
543 | $ cd .. | |
525 |
|
544 | |||
526 |
|
545 | |||
527 | Test hunk touching empty files (issue906) |
|
546 | Test hunk touching empty files (issue906) | |
528 |
|
547 | |||
529 | $ hg init empty |
|
548 | $ hg init empty | |
530 | $ cd empty |
|
549 | $ cd empty | |
531 | $ touch a |
|
550 | $ touch a | |
532 | $ touch b1 |
|
551 | $ touch b1 | |
533 | $ touch c1 |
|
552 | $ touch c1 | |
534 | $ echo d > d |
|
553 | $ echo d > d | |
535 | $ hg ci -Am init |
|
554 | $ hg ci -Am init | |
536 | adding a |
|
555 | adding a | |
537 | adding b1 |
|
556 | adding b1 | |
538 | adding c1 |
|
557 | adding c1 | |
539 | adding d |
|
558 | adding d | |
540 | $ echo a > a |
|
559 | $ echo a > a | |
541 | $ echo b > b1 |
|
560 | $ echo b > b1 | |
542 | $ hg mv b1 b2 |
|
561 | $ hg mv b1 b2 | |
543 | $ echo c > c1 |
|
562 | $ echo c > c1 | |
544 | $ hg copy c1 c2 |
|
563 | $ hg copy c1 c2 | |
545 | $ rm d |
|
564 | $ rm d | |
546 | $ touch d |
|
565 | $ touch d | |
547 | $ hg diff --git |
|
566 | $ hg diff --git | |
548 | diff --git a/a b/a |
|
567 | diff --git a/a b/a | |
549 | --- a/a |
|
568 | --- a/a | |
550 | +++ b/a |
|
569 | +++ b/a | |
551 | @@ -0,0 +1,1 @@ |
|
570 | @@ -0,0 +1,1 @@ | |
552 | +a |
|
571 | +a | |
553 | diff --git a/b1 b/b2 |
|
572 | diff --git a/b1 b/b2 | |
554 | rename from b1 |
|
573 | rename from b1 | |
555 | rename to b2 |
|
574 | rename to b2 | |
556 | --- a/b1 |
|
575 | --- a/b1 | |
557 | +++ b/b2 |
|
576 | +++ b/b2 | |
558 | @@ -0,0 +1,1 @@ |
|
577 | @@ -0,0 +1,1 @@ | |
559 | +b |
|
578 | +b | |
560 | diff --git a/c1 b/c1 |
|
579 | diff --git a/c1 b/c1 | |
561 | --- a/c1 |
|
580 | --- a/c1 | |
562 | +++ b/c1 |
|
581 | +++ b/c1 | |
563 | @@ -0,0 +1,1 @@ |
|
582 | @@ -0,0 +1,1 @@ | |
564 | +c |
|
583 | +c | |
565 | diff --git a/c1 b/c2 |
|
584 | diff --git a/c1 b/c2 | |
566 | copy from c1 |
|
585 | copy from c1 | |
567 | copy to c2 |
|
586 | copy to c2 | |
568 | --- a/c1 |
|
587 | --- a/c1 | |
569 | +++ b/c2 |
|
588 | +++ b/c2 | |
570 | @@ -0,0 +1,1 @@ |
|
589 | @@ -0,0 +1,1 @@ | |
571 | +c |
|
590 | +c | |
572 | diff --git a/d b/d |
|
591 | diff --git a/d b/d | |
573 | --- a/d |
|
592 | --- a/d | |
574 | +++ b/d |
|
593 | +++ b/d | |
575 | @@ -1,1 +0,0 @@ |
|
594 | @@ -1,1 +0,0 @@ | |
576 | -d |
|
595 | -d | |
577 | $ hg ci -m empty |
|
596 | $ hg ci -m empty | |
578 | $ hg export --git tip > empty.diff |
|
597 | $ hg export --git tip > empty.diff | |
579 | $ hg up -C 0 |
|
598 | $ hg up -C 0 | |
580 | 4 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
599 | 4 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
581 | $ hg import empty.diff |
|
600 | $ hg import empty.diff | |
582 | applying empty.diff |
|
601 | applying empty.diff | |
583 | $ for name in a b1 b2 c1 c2 d; do |
|
602 | $ for name in a b1 b2 c1 c2 d; do | |
584 | > echo % $name file |
|
603 | > echo % $name file | |
585 | > test -f $name && cat $name |
|
604 | > test -f $name && cat $name | |
586 | > done |
|
605 | > done | |
587 | % a file |
|
606 | % a file | |
588 | a |
|
607 | a | |
589 | % b1 file |
|
608 | % b1 file | |
590 | % b2 file |
|
609 | % b2 file | |
591 | b |
|
610 | b | |
592 | % c1 file |
|
611 | % c1 file | |
593 | c |
|
612 | c | |
594 | % c2 file |
|
613 | % c2 file | |
595 | c |
|
614 | c | |
596 | % d file |
|
615 | % d file | |
597 | $ cd .. |
|
616 | $ cd .. | |
598 |
|
617 | |||
599 |
|
618 | |||
600 | Test importing a patch ending with a binary file removal |
|
619 | Test importing a patch ending with a binary file removal | |
601 |
|
620 | |||
602 | $ hg init binaryremoval |
|
621 | $ hg init binaryremoval | |
603 | $ cd binaryremoval |
|
622 | $ cd binaryremoval | |
604 | $ echo a > a |
|
623 | $ echo a > a | |
605 | $ $PYTHON -c "file('b', 'wb').write('a\x00b')" |
|
624 | $ $PYTHON -c "file('b', 'wb').write('a\x00b')" | |
606 | $ hg ci -Am addall |
|
625 | $ hg ci -Am addall | |
607 | adding a |
|
626 | adding a | |
608 | adding b |
|
627 | adding b | |
609 | $ hg rm a |
|
628 | $ hg rm a | |
610 | $ hg rm b |
|
629 | $ hg rm b | |
611 | $ hg st |
|
630 | $ hg st | |
612 | R a |
|
631 | R a | |
613 | R b |
|
632 | R b | |
614 | $ hg ci -m remove |
|
633 | $ hg ci -m remove | |
615 | $ hg export --git . > remove.diff |
|
634 | $ hg export --git . > remove.diff | |
616 | $ cat remove.diff | grep git |
|
635 | $ cat remove.diff | grep git | |
617 | diff --git a/a b/a |
|
636 | diff --git a/a b/a | |
618 | diff --git a/b b/b |
|
637 | diff --git a/b b/b | |
619 | $ hg up -C 0 |
|
638 | $ hg up -C 0 | |
620 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
639 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
621 | $ hg import remove.diff |
|
640 | $ hg import remove.diff | |
622 | applying remove.diff |
|
641 | applying remove.diff | |
623 | $ hg manifest |
|
642 | $ hg manifest | |
624 | $ cd .. |
|
643 | $ cd .. | |
625 |
|
644 | |||
626 |
|
645 | |||
627 | Issue927: test update+rename with common name |
|
646 | Issue927: test update+rename with common name | |
628 |
|
647 | |||
629 | $ hg init t |
|
648 | $ hg init t | |
630 | $ cd t |
|
649 | $ cd t | |
631 | $ touch a |
|
650 | $ touch a | |
632 | $ hg ci -Am t |
|
651 | $ hg ci -Am t | |
633 | adding a |
|
652 | adding a | |
634 | $ echo a > a |
|
653 | $ echo a > a | |
635 |
|
654 | |||
636 | Here, bfile.startswith(afile) |
|
655 | Here, bfile.startswith(afile) | |
637 |
|
656 | |||
638 | $ hg copy a a2 |
|
657 | $ hg copy a a2 | |
639 | $ hg ci -m copya |
|
658 | $ hg ci -m copya | |
640 | $ hg export --git tip > copy.diff |
|
659 | $ hg export --git tip > copy.diff | |
641 | $ hg up -C 0 |
|
660 | $ hg up -C 0 | |
642 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
661 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
643 | $ hg import copy.diff |
|
662 | $ hg import copy.diff | |
644 | applying copy.diff |
|
663 | applying copy.diff | |
645 |
|
664 | |||
646 | a should contain an 'a' |
|
665 | a should contain an 'a' | |
647 |
|
666 | |||
648 | $ cat a |
|
667 | $ cat a | |
649 | a |
|
668 | a | |
650 |
|
669 | |||
651 | and a2 should have duplicated it |
|
670 | and a2 should have duplicated it | |
652 |
|
671 | |||
653 | $ cat a2 |
|
672 | $ cat a2 | |
654 | a |
|
673 | a | |
655 | $ cd .. |
|
674 | $ cd .. | |
656 |
|
675 | |||
657 |
|
676 | |||
658 | test -p0 |
|
677 | test -p0 | |
659 |
|
678 | |||
660 | $ hg init p0 |
|
679 | $ hg init p0 | |
661 | $ cd p0 |
|
680 | $ cd p0 | |
662 | $ echo a > a |
|
681 | $ echo a > a | |
663 | $ hg ci -Am t |
|
682 | $ hg ci -Am t | |
664 | adding a |
|
683 | adding a | |
665 | $ hg import -p foo |
|
684 | $ hg import -p foo | |
666 | abort: invalid value 'foo' for option -p, expected int |
|
685 | abort: invalid value 'foo' for option -p, expected int | |
667 | [255] |
|
686 | [255] | |
668 | $ hg import -p0 - << EOF |
|
687 | $ hg import -p0 - << EOF | |
669 | > foobar |
|
688 | > foobar | |
670 | > --- a Sat Apr 12 22:43:58 2008 -0400 |
|
689 | > --- a Sat Apr 12 22:43:58 2008 -0400 | |
671 | > +++ a Sat Apr 12 22:44:05 2008 -0400 |
|
690 | > +++ a Sat Apr 12 22:44:05 2008 -0400 | |
672 | > @@ -1,1 +1,1 @@ |
|
691 | > @@ -1,1 +1,1 @@ | |
673 | > -a |
|
692 | > -a | |
674 | > +bb |
|
693 | > +bb | |
675 | > EOF |
|
694 | > EOF | |
676 | applying patch from stdin |
|
695 | applying patch from stdin | |
677 | $ hg status |
|
696 | $ hg status | |
678 | $ cat a |
|
697 | $ cat a | |
679 | bb |
|
698 | bb | |
680 |
|
699 | |||
681 | test --prefix |
|
700 | test --prefix | |
682 |
|
701 | |||
683 | $ mkdir -p dir/dir2 |
|
702 | $ mkdir -p dir/dir2 | |
684 | $ echo b > dir/dir2/b |
|
703 | $ echo b > dir/dir2/b | |
685 | $ hg ci -Am b |
|
704 | $ hg ci -Am b | |
686 | adding dir/dir2/b |
|
705 | adding dir/dir2/b | |
687 | $ hg import -p2 --prefix dir - << EOF |
|
706 | $ hg import -p2 --prefix dir - << EOF | |
688 | > foobar |
|
707 | > foobar | |
689 | > --- drop1/drop2/dir2/b |
|
708 | > --- drop1/drop2/dir2/b | |
690 | > +++ drop1/drop2/dir2/b |
|
709 | > +++ drop1/drop2/dir2/b | |
691 | > @@ -1,1 +1,1 @@ |
|
710 | > @@ -1,1 +1,1 @@ | |
692 | > -b |
|
711 | > -b | |
693 | > +cc |
|
712 | > +cc | |
694 | > EOF |
|
713 | > EOF | |
695 | applying patch from stdin |
|
714 | applying patch from stdin | |
696 | $ hg status |
|
715 | $ hg status | |
697 | $ cat dir/dir2/b |
|
716 | $ cat dir/dir2/b | |
698 | cc |
|
717 | cc | |
699 | $ cd .. |
|
718 | $ cd .. | |
700 |
|
719 | |||
701 |
|
720 | |||
702 | test paths outside repo root |
|
721 | test paths outside repo root | |
703 |
|
722 | |||
704 | $ mkdir outside |
|
723 | $ mkdir outside | |
705 | $ touch outside/foo |
|
724 | $ touch outside/foo | |
706 | $ hg init inside |
|
725 | $ hg init inside | |
707 | $ cd inside |
|
726 | $ cd inside | |
708 | $ hg import - <<EOF |
|
727 | $ hg import - <<EOF | |
709 | > diff --git a/a b/b |
|
728 | > diff --git a/a b/b | |
710 | > rename from ../outside/foo |
|
729 | > rename from ../outside/foo | |
711 | > rename to bar |
|
730 | > rename to bar | |
712 | > EOF |
|
731 | > EOF | |
713 | applying patch from stdin |
|
732 | applying patch from stdin | |
714 | abort: path contains illegal component: ../outside/foo (glob) |
|
733 | abort: path contains illegal component: ../outside/foo (glob) | |
715 | [255] |
|
734 | [255] | |
716 | $ cd .. |
|
735 | $ cd .. | |
717 |
|
736 | |||
718 |
|
737 | |||
719 | test import with similarity and git and strip (issue295 et al.) |
|
738 | test import with similarity and git and strip (issue295 et al.) | |
720 |
|
739 | |||
721 | $ hg init sim |
|
740 | $ hg init sim | |
722 | $ cd sim |
|
741 | $ cd sim | |
723 | $ echo 'this is a test' > a |
|
742 | $ echo 'this is a test' > a | |
724 | $ hg ci -Ama |
|
743 | $ hg ci -Ama | |
725 | adding a |
|
744 | adding a | |
726 | $ cat > ../rename.diff <<EOF |
|
745 | $ cat > ../rename.diff <<EOF | |
727 | > diff --git a/foo/a b/foo/a |
|
746 | > diff --git a/foo/a b/foo/a | |
728 | > deleted file mode 100644 |
|
747 | > deleted file mode 100644 | |
729 | > --- a/foo/a |
|
748 | > --- a/foo/a | |
730 | > +++ /dev/null |
|
749 | > +++ /dev/null | |
731 | > @@ -1,1 +0,0 @@ |
|
750 | > @@ -1,1 +0,0 @@ | |
732 | > -this is a test |
|
751 | > -this is a test | |
733 | > diff --git a/foo/b b/foo/b |
|
752 | > diff --git a/foo/b b/foo/b | |
734 | > new file mode 100644 |
|
753 | > new file mode 100644 | |
735 | > --- /dev/null |
|
754 | > --- /dev/null | |
736 | > +++ b/foo/b |
|
755 | > +++ b/foo/b | |
737 | > @@ -0,0 +1,2 @@ |
|
756 | > @@ -0,0 +1,2 @@ | |
738 | > +this is a test |
|
757 | > +this is a test | |
739 | > +foo |
|
758 | > +foo | |
740 | > EOF |
|
759 | > EOF | |
741 | $ hg import --no-commit -v -s 1 ../rename.diff -p2 |
|
760 | $ hg import --no-commit -v -s 1 ../rename.diff -p2 | |
742 | applying ../rename.diff |
|
761 | applying ../rename.diff | |
743 | patching file a |
|
762 | patching file a | |
744 | patching file b |
|
763 | patching file b | |
745 | adding b |
|
764 | adding b | |
746 | recording removal of a as rename to b (88% similar) |
|
765 | recording removal of a as rename to b (88% similar) | |
747 | applied to working directory |
|
766 | applied to working directory | |
748 | $ hg st -C |
|
767 | $ hg st -C | |
749 | A b |
|
768 | A b | |
750 | a |
|
769 | a | |
751 | R a |
|
770 | R a | |
752 | $ hg revert -a |
|
771 | $ hg revert -a | |
753 | undeleting a |
|
772 | undeleting a | |
754 | forgetting b |
|
773 | forgetting b | |
755 | $ rm b |
|
774 | $ rm b | |
756 | $ hg import --no-commit -v -s 100 ../rename.diff -p2 |
|
775 | $ hg import --no-commit -v -s 100 ../rename.diff -p2 | |
757 | applying ../rename.diff |
|
776 | applying ../rename.diff | |
758 | patching file a |
|
777 | patching file a | |
759 | patching file b |
|
778 | patching file b | |
760 | adding b |
|
779 | adding b | |
761 | applied to working directory |
|
780 | applied to working directory | |
762 | $ hg st -C |
|
781 | $ hg st -C | |
763 | A b |
|
782 | A b | |
764 | R a |
|
783 | R a | |
765 | $ cd .. |
|
784 | $ cd .. | |
766 |
|
785 | |||
767 |
|
786 | |||
768 | Issue1495: add empty file from the end of patch |
|
787 | Issue1495: add empty file from the end of patch | |
769 |
|
788 | |||
770 | $ hg init addemptyend |
|
789 | $ hg init addemptyend | |
771 | $ cd addemptyend |
|
790 | $ cd addemptyend | |
772 | $ touch a |
|
791 | $ touch a | |
773 | $ hg addremove |
|
792 | $ hg addremove | |
774 | adding a |
|
793 | adding a | |
775 | $ hg ci -m "commit" |
|
794 | $ hg ci -m "commit" | |
776 | $ cat > a.patch <<EOF |
|
795 | $ cat > a.patch <<EOF | |
777 | > add a, b |
|
796 | > add a, b | |
778 | > diff --git a/a b/a |
|
797 | > diff --git a/a b/a | |
779 | > --- a/a |
|
798 | > --- a/a | |
780 | > +++ b/a |
|
799 | > +++ b/a | |
781 | > @@ -0,0 +1,1 @@ |
|
800 | > @@ -0,0 +1,1 @@ | |
782 | > +a |
|
801 | > +a | |
783 | > diff --git a/b b/b |
|
802 | > diff --git a/b b/b | |
784 | > new file mode 100644 |
|
803 | > new file mode 100644 | |
785 | > EOF |
|
804 | > EOF | |
786 | $ hg import --no-commit a.patch |
|
805 | $ hg import --no-commit a.patch | |
787 | applying a.patch |
|
806 | applying a.patch | |
788 |
|
807 | |||
789 | apply a good patch followed by an empty patch (mainly to ensure |
|
808 | apply a good patch followed by an empty patch (mainly to ensure | |
790 | that dirstate is *not* updated when import crashes) |
|
809 | that dirstate is *not* updated when import crashes) | |
791 | $ hg update -q -C . |
|
810 | $ hg update -q -C . | |
792 | $ rm b |
|
811 | $ rm b | |
793 | $ touch empty.patch |
|
812 | $ touch empty.patch | |
794 | $ hg import a.patch empty.patch |
|
813 | $ hg import a.patch empty.patch | |
795 | applying a.patch |
|
814 | applying a.patch | |
796 | applying empty.patch |
|
815 | applying empty.patch | |
797 | transaction abort! |
|
816 | transaction abort! | |
798 | rollback completed |
|
817 | rollback completed | |
799 | abort: empty.patch: no diffs found |
|
818 | abort: empty.patch: no diffs found | |
800 | [255] |
|
819 | [255] | |
801 | $ hg tip --template '{rev} {desc|firstline}\n' |
|
820 | $ hg tip --template '{rev} {desc|firstline}\n' | |
802 | 0 commit |
|
821 | 0 commit | |
803 | $ hg -q status |
|
822 | $ hg -q status | |
804 | M a |
|
823 | M a | |
805 | $ cd .. |
|
824 | $ cd .. | |
806 |
|
825 | |||
807 | create file when source is not /dev/null |
|
826 | create file when source is not /dev/null | |
808 |
|
827 | |||
809 | $ cat > create.patch <<EOF |
|
828 | $ cat > create.patch <<EOF | |
810 | > diff -Naur proj-orig/foo proj-new/foo |
|
829 | > diff -Naur proj-orig/foo proj-new/foo | |
811 | > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800 |
|
830 | > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800 | |
812 | > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 |
|
831 | > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 | |
813 | > @@ -0,0 +1,1 @@ |
|
832 | > @@ -0,0 +1,1 @@ | |
814 | > +a |
|
833 | > +a | |
815 | > EOF |
|
834 | > EOF | |
816 |
|
835 | |||
817 | some people have patches like the following too |
|
836 | some people have patches like the following too | |
818 |
|
837 | |||
819 | $ cat > create2.patch <<EOF |
|
838 | $ cat > create2.patch <<EOF | |
820 | > diff -Naur proj-orig/foo proj-new/foo |
|
839 | > diff -Naur proj-orig/foo proj-new/foo | |
821 | > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800 |
|
840 | > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800 | |
822 | > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 |
|
841 | > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 | |
823 | > @@ -0,0 +1,1 @@ |
|
842 | > @@ -0,0 +1,1 @@ | |
824 | > +a |
|
843 | > +a | |
825 | > EOF |
|
844 | > EOF | |
826 | $ hg init oddcreate |
|
845 | $ hg init oddcreate | |
827 | $ cd oddcreate |
|
846 | $ cd oddcreate | |
828 | $ hg import --no-commit ../create.patch |
|
847 | $ hg import --no-commit ../create.patch | |
829 | applying ../create.patch |
|
848 | applying ../create.patch | |
830 | $ cat foo |
|
849 | $ cat foo | |
831 | a |
|
850 | a | |
832 | $ rm foo |
|
851 | $ rm foo | |
833 | $ hg revert foo |
|
852 | $ hg revert foo | |
834 | $ hg import --no-commit ../create2.patch |
|
853 | $ hg import --no-commit ../create2.patch | |
835 | applying ../create2.patch |
|
854 | applying ../create2.patch | |
836 | $ cat foo |
|
855 | $ cat foo | |
837 | a |
|
856 | a | |
838 |
|
857 | |||
839 | $ cd .. |
|
858 | $ cd .. | |
840 |
|
859 | |||
841 | Issue1859: first line mistaken for email headers |
|
860 | Issue1859: first line mistaken for email headers | |
842 |
|
861 | |||
843 | $ hg init emailconfusion |
|
862 | $ hg init emailconfusion | |
844 | $ cd emailconfusion |
|
863 | $ cd emailconfusion | |
845 | $ cat > a.patch <<EOF |
|
864 | $ cat > a.patch <<EOF | |
846 | > module: summary |
|
865 | > module: summary | |
847 | > |
|
866 | > | |
848 | > description |
|
867 | > description | |
849 | > |
|
868 | > | |
850 | > |
|
869 | > | |
851 | > diff -r 000000000000 -r 9b4c1e343b55 test.txt |
|
870 | > diff -r 000000000000 -r 9b4c1e343b55 test.txt | |
852 | > --- /dev/null |
|
871 | > --- /dev/null | |
853 | > +++ b/a |
|
872 | > +++ b/a | |
854 | > @@ -0,0 +1,1 @@ |
|
873 | > @@ -0,0 +1,1 @@ | |
855 | > +a |
|
874 | > +a | |
856 | > EOF |
|
875 | > EOF | |
857 | $ hg import -d '0 0' a.patch |
|
876 | $ hg import -d '0 0' a.patch | |
858 | applying a.patch |
|
877 | applying a.patch | |
859 | $ hg parents -v |
|
878 | $ hg parents -v | |
860 | changeset: 0:5a681217c0ad |
|
879 | changeset: 0:5a681217c0ad | |
861 | tag: tip |
|
880 | tag: tip | |
862 | user: test |
|
881 | user: test | |
863 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
882 | date: Thu Jan 01 00:00:00 1970 +0000 | |
864 | files: a |
|
883 | files: a | |
865 | description: |
|
884 | description: | |
866 | module: summary |
|
885 | module: summary | |
867 |
|
886 | |||
868 | description |
|
887 | description | |
869 |
|
888 | |||
870 |
|
889 | |||
871 | $ cd .. |
|
890 | $ cd .. | |
872 |
|
891 | |||
873 |
|
892 | |||
874 | in commit message |
|
893 | in commit message | |
875 |
|
894 | |||
876 | $ hg init commitconfusion |
|
895 | $ hg init commitconfusion | |
877 | $ cd commitconfusion |
|
896 | $ cd commitconfusion | |
878 | $ cat > a.patch <<EOF |
|
897 | $ cat > a.patch <<EOF | |
879 | > module: summary |
|
898 | > module: summary | |
880 | > |
|
899 | > | |
881 | > --- description |
|
900 | > --- description | |
882 | > |
|
901 | > | |
883 | > diff --git a/a b/a |
|
902 | > diff --git a/a b/a | |
884 | > new file mode 100644 |
|
903 | > new file mode 100644 | |
885 | > --- /dev/null |
|
904 | > --- /dev/null | |
886 | > +++ b/a |
|
905 | > +++ b/a | |
887 | > @@ -0,0 +1,1 @@ |
|
906 | > @@ -0,0 +1,1 @@ | |
888 | > +a |
|
907 | > +a | |
889 | > EOF |
|
908 | > EOF | |
890 | > hg import -d '0 0' a.patch |
|
909 | > hg import -d '0 0' a.patch | |
891 | > hg parents -v |
|
910 | > hg parents -v | |
892 | > cd .. |
|
911 | > cd .. | |
893 | > |
|
912 | > | |
894 | > echo '% tricky header splitting' |
|
913 | > echo '% tricky header splitting' | |
895 | > cat > trickyheaders.patch <<EOF |
|
914 | > cat > trickyheaders.patch <<EOF | |
896 | > From: User A <user@a> |
|
915 | > From: User A <user@a> | |
897 | > Subject: [PATCH] from: tricky! |
|
916 | > Subject: [PATCH] from: tricky! | |
898 | > |
|
917 | > | |
899 | > # HG changeset patch |
|
918 | > # HG changeset patch | |
900 | > # User User B |
|
919 | > # User User B | |
901 | > # Date 1266264441 18000 |
|
920 | > # Date 1266264441 18000 | |
902 | > # Branch stable |
|
921 | > # Branch stable | |
903 | > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0 |
|
922 | > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0 | |
904 | > # Parent 0000000000000000000000000000000000000000 |
|
923 | > # Parent 0000000000000000000000000000000000000000 | |
905 | > from: tricky! |
|
924 | > from: tricky! | |
906 | > |
|
925 | > | |
907 | > That is not a header. |
|
926 | > That is not a header. | |
908 | > |
|
927 | > | |
909 | > diff -r 000000000000 -r f2be6a1170ac foo |
|
928 | > diff -r 000000000000 -r f2be6a1170ac foo | |
910 | > --- /dev/null |
|
929 | > --- /dev/null | |
911 | > +++ b/foo |
|
930 | > +++ b/foo | |
912 | > @@ -0,0 +1,1 @@ |
|
931 | > @@ -0,0 +1,1 @@ | |
913 | > +foo |
|
932 | > +foo | |
914 | > EOF |
|
933 | > EOF | |
915 | applying a.patch |
|
934 | applying a.patch | |
916 | changeset: 0:f34d9187897d |
|
935 | changeset: 0:f34d9187897d | |
917 | tag: tip |
|
936 | tag: tip | |
918 | user: test |
|
937 | user: test | |
919 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
938 | date: Thu Jan 01 00:00:00 1970 +0000 | |
920 | files: a |
|
939 | files: a | |
921 | description: |
|
940 | description: | |
922 | module: summary |
|
941 | module: summary | |
923 |
|
942 | |||
924 |
|
943 | |||
925 | % tricky header splitting |
|
944 | % tricky header splitting | |
926 |
|
945 | |||
927 | $ hg init trickyheaders |
|
946 | $ hg init trickyheaders | |
928 | $ cd trickyheaders |
|
947 | $ cd trickyheaders | |
929 | $ hg import -d '0 0' ../trickyheaders.patch |
|
948 | $ hg import -d '0 0' ../trickyheaders.patch | |
930 | applying ../trickyheaders.patch |
|
949 | applying ../trickyheaders.patch | |
931 | $ hg export --git tip |
|
950 | $ hg export --git tip | |
932 | # HG changeset patch |
|
951 | # HG changeset patch | |
933 | # User User B |
|
952 | # User User B | |
934 | # Date 0 0 |
|
953 | # Date 0 0 | |
935 | # Thu Jan 01 00:00:00 1970 +0000 |
|
954 | # Thu Jan 01 00:00:00 1970 +0000 | |
936 | # Node ID eb56ab91903632294ac504838508cb370c0901d2 |
|
955 | # Node ID eb56ab91903632294ac504838508cb370c0901d2 | |
937 | # Parent 0000000000000000000000000000000000000000 |
|
956 | # Parent 0000000000000000000000000000000000000000 | |
938 | from: tricky! |
|
957 | from: tricky! | |
939 |
|
958 | |||
940 | That is not a header. |
|
959 | That is not a header. | |
941 |
|
960 | |||
942 | diff --git a/foo b/foo |
|
961 | diff --git a/foo b/foo | |
943 | new file mode 100644 |
|
962 | new file mode 100644 | |
944 | --- /dev/null |
|
963 | --- /dev/null | |
945 | +++ b/foo |
|
964 | +++ b/foo | |
946 | @@ -0,0 +1,1 @@ |
|
965 | @@ -0,0 +1,1 @@ | |
947 | +foo |
|
966 | +foo | |
948 | $ cd .. |
|
967 | $ cd .. | |
949 |
|
968 | |||
950 |
|
969 | |||
951 | Issue2102: hg export and hg import speak different languages |
|
970 | Issue2102: hg export and hg import speak different languages | |
952 |
|
971 | |||
953 | $ hg init issue2102 |
|
972 | $ hg init issue2102 | |
954 | $ cd issue2102 |
|
973 | $ cd issue2102 | |
955 | $ mkdir -p src/cmd/gc |
|
974 | $ mkdir -p src/cmd/gc | |
956 | $ touch src/cmd/gc/mksys.bash |
|
975 | $ touch src/cmd/gc/mksys.bash | |
957 | $ hg ci -Am init |
|
976 | $ hg ci -Am init | |
958 | adding src/cmd/gc/mksys.bash |
|
977 | adding src/cmd/gc/mksys.bash | |
959 | $ hg import - <<EOF |
|
978 | $ hg import - <<EOF | |
960 | > # HG changeset patch |
|
979 | > # HG changeset patch | |
961 | > # User Rob Pike |
|
980 | > # User Rob Pike | |
962 | > # Date 1216685449 25200 |
|
981 | > # Date 1216685449 25200 | |
963 | > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98 |
|
982 | > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98 | |
964 | > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84 |
|
983 | > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84 | |
965 | > help management of empty pkg and lib directories in perforce |
|
984 | > help management of empty pkg and lib directories in perforce | |
966 | > |
|
985 | > | |
967 | > R=gri |
|
986 | > R=gri | |
968 | > DELTA=4 (4 added, 0 deleted, 0 changed) |
|
987 | > DELTA=4 (4 added, 0 deleted, 0 changed) | |
969 | > OCL=13328 |
|
988 | > OCL=13328 | |
970 | > CL=13328 |
|
989 | > CL=13328 | |
971 | > |
|
990 | > | |
972 | > diff --git a/lib/place-holder b/lib/place-holder |
|
991 | > diff --git a/lib/place-holder b/lib/place-holder | |
973 | > new file mode 100644 |
|
992 | > new file mode 100644 | |
974 | > --- /dev/null |
|
993 | > --- /dev/null | |
975 | > +++ b/lib/place-holder |
|
994 | > +++ b/lib/place-holder | |
976 | > @@ -0,0 +1,2 @@ |
|
995 | > @@ -0,0 +1,2 @@ | |
977 | > +perforce does not maintain empty directories. |
|
996 | > +perforce does not maintain empty directories. | |
978 | > +this file helps. |
|
997 | > +this file helps. | |
979 | > diff --git a/pkg/place-holder b/pkg/place-holder |
|
998 | > diff --git a/pkg/place-holder b/pkg/place-holder | |
980 | > new file mode 100644 |
|
999 | > new file mode 100644 | |
981 | > --- /dev/null |
|
1000 | > --- /dev/null | |
982 | > +++ b/pkg/place-holder |
|
1001 | > +++ b/pkg/place-holder | |
983 | > @@ -0,0 +1,2 @@ |
|
1002 | > @@ -0,0 +1,2 @@ | |
984 | > +perforce does not maintain empty directories. |
|
1003 | > +perforce does not maintain empty directories. | |
985 | > +this file helps. |
|
1004 | > +this file helps. | |
986 | > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash |
|
1005 | > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash | |
987 | > old mode 100644 |
|
1006 | > old mode 100644 | |
988 | > new mode 100755 |
|
1007 | > new mode 100755 | |
989 | > EOF |
|
1008 | > EOF | |
990 | applying patch from stdin |
|
1009 | applying patch from stdin | |
991 |
|
1010 | |||
992 | #if execbit |
|
1011 | #if execbit | |
993 |
|
1012 | |||
994 | $ hg sum |
|
1013 | $ hg sum | |
995 | parent: 1:d59915696727 tip |
|
1014 | parent: 1:d59915696727 tip | |
996 | help management of empty pkg and lib directories in perforce |
|
1015 | help management of empty pkg and lib directories in perforce | |
997 | branch: default |
|
1016 | branch: default | |
998 | commit: (clean) |
|
1017 | commit: (clean) | |
999 | update: (current) |
|
1018 | update: (current) | |
1000 | phases: 2 draft |
|
1019 | phases: 2 draft | |
1001 |
|
1020 | |||
1002 | $ hg diff --git -c tip |
|
1021 | $ hg diff --git -c tip | |
1003 | diff --git a/lib/place-holder b/lib/place-holder |
|
1022 | diff --git a/lib/place-holder b/lib/place-holder | |
1004 | new file mode 100644 |
|
1023 | new file mode 100644 | |
1005 | --- /dev/null |
|
1024 | --- /dev/null | |
1006 | +++ b/lib/place-holder |
|
1025 | +++ b/lib/place-holder | |
1007 | @@ -0,0 +1,2 @@ |
|
1026 | @@ -0,0 +1,2 @@ | |
1008 | +perforce does not maintain empty directories. |
|
1027 | +perforce does not maintain empty directories. | |
1009 | +this file helps. |
|
1028 | +this file helps. | |
1010 | diff --git a/pkg/place-holder b/pkg/place-holder |
|
1029 | diff --git a/pkg/place-holder b/pkg/place-holder | |
1011 | new file mode 100644 |
|
1030 | new file mode 100644 | |
1012 | --- /dev/null |
|
1031 | --- /dev/null | |
1013 | +++ b/pkg/place-holder |
|
1032 | +++ b/pkg/place-holder | |
1014 | @@ -0,0 +1,2 @@ |
|
1033 | @@ -0,0 +1,2 @@ | |
1015 | +perforce does not maintain empty directories. |
|
1034 | +perforce does not maintain empty directories. | |
1016 | +this file helps. |
|
1035 | +this file helps. | |
1017 | diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash |
|
1036 | diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash | |
1018 | old mode 100644 |
|
1037 | old mode 100644 | |
1019 | new mode 100755 |
|
1038 | new mode 100755 | |
1020 |
|
1039 | |||
1021 | #else |
|
1040 | #else | |
1022 |
|
1041 | |||
1023 | $ hg sum |
|
1042 | $ hg sum | |
1024 | parent: 1:28f089cc9ccc tip |
|
1043 | parent: 1:28f089cc9ccc tip | |
1025 | help management of empty pkg and lib directories in perforce |
|
1044 | help management of empty pkg and lib directories in perforce | |
1026 | branch: default |
|
1045 | branch: default | |
1027 | commit: (clean) |
|
1046 | commit: (clean) | |
1028 | update: (current) |
|
1047 | update: (current) | |
1029 | phases: 2 draft |
|
1048 | phases: 2 draft | |
1030 |
|
1049 | |||
1031 | $ hg diff --git -c tip |
|
1050 | $ hg diff --git -c tip | |
1032 | diff --git a/lib/place-holder b/lib/place-holder |
|
1051 | diff --git a/lib/place-holder b/lib/place-holder | |
1033 | new file mode 100644 |
|
1052 | new file mode 100644 | |
1034 | --- /dev/null |
|
1053 | --- /dev/null | |
1035 | +++ b/lib/place-holder |
|
1054 | +++ b/lib/place-holder | |
1036 | @@ -0,0 +1,2 @@ |
|
1055 | @@ -0,0 +1,2 @@ | |
1037 | +perforce does not maintain empty directories. |
|
1056 | +perforce does not maintain empty directories. | |
1038 | +this file helps. |
|
1057 | +this file helps. | |
1039 | diff --git a/pkg/place-holder b/pkg/place-holder |
|
1058 | diff --git a/pkg/place-holder b/pkg/place-holder | |
1040 | new file mode 100644 |
|
1059 | new file mode 100644 | |
1041 | --- /dev/null |
|
1060 | --- /dev/null | |
1042 | +++ b/pkg/place-holder |
|
1061 | +++ b/pkg/place-holder | |
1043 | @@ -0,0 +1,2 @@ |
|
1062 | @@ -0,0 +1,2 @@ | |
1044 | +perforce does not maintain empty directories. |
|
1063 | +perforce does not maintain empty directories. | |
1045 | +this file helps. |
|
1064 | +this file helps. | |
1046 |
|
1065 | |||
1047 | /* The mode change for mksys.bash is missing here, because on platforms */ |
|
1066 | /* The mode change for mksys.bash is missing here, because on platforms */ | |
1048 | /* that don't support execbits, mode changes in patches are ignored when */ |
|
1067 | /* that don't support execbits, mode changes in patches are ignored when */ | |
1049 | /* they are imported. This is obviously also the reason for why the hash */ |
|
1068 | /* they are imported. This is obviously also the reason for why the hash */ | |
1050 | /* in the created changeset is different to the one you see above the */ |
|
1069 | /* in the created changeset is different to the one you see above the */ | |
1051 | /* #else clause */ |
|
1070 | /* #else clause */ | |
1052 |
|
1071 | |||
1053 | #endif |
|
1072 | #endif | |
1054 | $ cd .. |
|
1073 | $ cd .. | |
1055 |
|
1074 | |||
1056 |
|
1075 | |||
1057 | diff lines looking like headers |
|
1076 | diff lines looking like headers | |
1058 |
|
1077 | |||
1059 | $ hg init difflineslikeheaders |
|
1078 | $ hg init difflineslikeheaders | |
1060 | $ cd difflineslikeheaders |
|
1079 | $ cd difflineslikeheaders | |
1061 | $ echo a >a |
|
1080 | $ echo a >a | |
1062 | $ echo b >b |
|
1081 | $ echo b >b | |
1063 | $ echo c >c |
|
1082 | $ echo c >c | |
1064 | $ hg ci -Am1 |
|
1083 | $ hg ci -Am1 | |
1065 | adding a |
|
1084 | adding a | |
1066 | adding b |
|
1085 | adding b | |
1067 | adding c |
|
1086 | adding c | |
1068 |
|
1087 | |||
1069 | $ echo "key: value" >>a |
|
1088 | $ echo "key: value" >>a | |
1070 | $ echo "key: value" >>b |
|
1089 | $ echo "key: value" >>b | |
1071 | $ echo "foo" >>c |
|
1090 | $ echo "foo" >>c | |
1072 | $ hg ci -m2 |
|
1091 | $ hg ci -m2 | |
1073 |
|
1092 | |||
1074 | $ hg up -C 0 |
|
1093 | $ hg up -C 0 | |
1075 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1094 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1076 | $ hg diff --git -c1 >want |
|
1095 | $ hg diff --git -c1 >want | |
1077 | $ hg diff -c1 | hg import --no-commit - |
|
1096 | $ hg diff -c1 | hg import --no-commit - | |
1078 | applying patch from stdin |
|
1097 | applying patch from stdin | |
1079 | $ hg diff --git >have |
|
1098 | $ hg diff --git >have | |
1080 | $ diff want have |
|
1099 | $ diff want have | |
1081 | $ cd .. |
|
1100 | $ cd .. | |
1082 |
|
1101 | |||
1083 | import a unified diff with no lines of context (diff -U0) |
|
1102 | import a unified diff with no lines of context (diff -U0) | |
1084 |
|
1103 | |||
1085 | $ hg init diffzero |
|
1104 | $ hg init diffzero | |
1086 | $ cd diffzero |
|
1105 | $ cd diffzero | |
1087 | $ cat > f << EOF |
|
1106 | $ cat > f << EOF | |
1088 | > c2 |
|
1107 | > c2 | |
1089 | > c4 |
|
1108 | > c4 | |
1090 | > c5 |
|
1109 | > c5 | |
1091 | > EOF |
|
1110 | > EOF | |
1092 | $ hg commit -Am0 |
|
1111 | $ hg commit -Am0 | |
1093 | adding f |
|
1112 | adding f | |
1094 |
|
1113 | |||
1095 | $ hg import --no-commit - << EOF |
|
1114 | $ hg import --no-commit - << EOF | |
1096 | > # HG changeset patch |
|
1115 | > # HG changeset patch | |
1097 | > # User test |
|
1116 | > # User test | |
1098 | > # Date 0 0 |
|
1117 | > # Date 0 0 | |
1099 | > # Node ID f4974ab632f3dee767567b0576c0ec9a4508575c |
|
1118 | > # Node ID f4974ab632f3dee767567b0576c0ec9a4508575c | |
1100 | > # Parent 8679a12a975b819fae5f7ad3853a2886d143d794 |
|
1119 | > # Parent 8679a12a975b819fae5f7ad3853a2886d143d794 | |
1101 | > 1 |
|
1120 | > 1 | |
1102 | > diff -r 8679a12a975b -r f4974ab632f3 f |
|
1121 | > diff -r 8679a12a975b -r f4974ab632f3 f | |
1103 | > --- a/f Thu Jan 01 00:00:00 1970 +0000 |
|
1122 | > --- a/f Thu Jan 01 00:00:00 1970 +0000 | |
1104 | > +++ b/f Thu Jan 01 00:00:00 1970 +0000 |
|
1123 | > +++ b/f Thu Jan 01 00:00:00 1970 +0000 | |
1105 | > @@ -0,0 +1,1 @@ |
|
1124 | > @@ -0,0 +1,1 @@ | |
1106 | > +c1 |
|
1125 | > +c1 | |
1107 | > @@ -1,0 +3,1 @@ |
|
1126 | > @@ -1,0 +3,1 @@ | |
1108 | > +c3 |
|
1127 | > +c3 | |
1109 | > @@ -3,1 +4,0 @@ |
|
1128 | > @@ -3,1 +4,0 @@ | |
1110 | > -c5 |
|
1129 | > -c5 | |
1111 | > EOF |
|
1130 | > EOF | |
1112 | applying patch from stdin |
|
1131 | applying patch from stdin | |
1113 |
|
1132 | |||
1114 | $ cat f |
|
1133 | $ cat f | |
1115 | c1 |
|
1134 | c1 | |
1116 | c2 |
|
1135 | c2 | |
1117 | c3 |
|
1136 | c3 | |
1118 | c4 |
|
1137 | c4 | |
1119 |
|
1138 | |||
1120 | $ cd .. |
|
1139 | $ cd .. | |
1121 |
|
1140 | |||
1122 | no segfault while importing a unified diff which start line is zero but chunk |
|
1141 | no segfault while importing a unified diff which start line is zero but chunk | |
1123 | size is non-zero |
|
1142 | size is non-zero | |
1124 |
|
1143 | |||
1125 | $ hg init startlinezero |
|
1144 | $ hg init startlinezero | |
1126 | $ cd startlinezero |
|
1145 | $ cd startlinezero | |
1127 | $ echo foo > foo |
|
1146 | $ echo foo > foo | |
1128 | $ hg commit -Amfoo |
|
1147 | $ hg commit -Amfoo | |
1129 | adding foo |
|
1148 | adding foo | |
1130 |
|
1149 | |||
1131 | $ hg import --no-commit - << EOF |
|
1150 | $ hg import --no-commit - << EOF | |
1132 | > diff a/foo b/foo |
|
1151 | > diff a/foo b/foo | |
1133 | > --- a/foo |
|
1152 | > --- a/foo | |
1134 | > +++ b/foo |
|
1153 | > +++ b/foo | |
1135 | > @@ -0,1 +0,1 @@ |
|
1154 | > @@ -0,1 +0,1 @@ | |
1136 | > foo |
|
1155 | > foo | |
1137 | > EOF |
|
1156 | > EOF | |
1138 | applying patch from stdin |
|
1157 | applying patch from stdin | |
1139 |
|
1158 | |||
1140 | $ cd .. |
|
1159 | $ cd .. | |
1141 |
|
1160 | |||
1142 | Test corner case involving fuzz and skew |
|
1161 | Test corner case involving fuzz and skew | |
1143 |
|
1162 | |||
1144 | $ hg init morecornercases |
|
1163 | $ hg init morecornercases | |
1145 | $ cd morecornercases |
|
1164 | $ cd morecornercases | |
1146 |
|
1165 | |||
1147 | $ cat > 01-no-context-beginning-of-file.diff <<EOF |
|
1166 | $ cat > 01-no-context-beginning-of-file.diff <<EOF | |
1148 | > diff --git a/a b/a |
|
1167 | > diff --git a/a b/a | |
1149 | > --- a/a |
|
1168 | > --- a/a | |
1150 | > +++ b/a |
|
1169 | > +++ b/a | |
1151 | > @@ -1,0 +1,1 @@ |
|
1170 | > @@ -1,0 +1,1 @@ | |
1152 | > +line |
|
1171 | > +line | |
1153 | > EOF |
|
1172 | > EOF | |
1154 |
|
1173 | |||
1155 | $ cat > 02-no-context-middle-of-file.diff <<EOF |
|
1174 | $ cat > 02-no-context-middle-of-file.diff <<EOF | |
1156 | > diff --git a/a b/a |
|
1175 | > diff --git a/a b/a | |
1157 | > --- a/a |
|
1176 | > --- a/a | |
1158 | > +++ b/a |
|
1177 | > +++ b/a | |
1159 | > @@ -1,1 +1,1 @@ |
|
1178 | > @@ -1,1 +1,1 @@ | |
1160 | > -2 |
|
1179 | > -2 | |
1161 | > +add some skew |
|
1180 | > +add some skew | |
1162 | > @@ -2,0 +2,1 @@ |
|
1181 | > @@ -2,0 +2,1 @@ | |
1163 | > +line |
|
1182 | > +line | |
1164 | > EOF |
|
1183 | > EOF | |
1165 |
|
1184 | |||
1166 | $ cat > 03-no-context-end-of-file.diff <<EOF |
|
1185 | $ cat > 03-no-context-end-of-file.diff <<EOF | |
1167 | > diff --git a/a b/a |
|
1186 | > diff --git a/a b/a | |
1168 | > --- a/a |
|
1187 | > --- a/a | |
1169 | > +++ b/a |
|
1188 | > +++ b/a | |
1170 | > @@ -10,0 +10,1 @@ |
|
1189 | > @@ -10,0 +10,1 @@ | |
1171 | > +line |
|
1190 | > +line | |
1172 | > EOF |
|
1191 | > EOF | |
1173 |
|
1192 | |||
1174 | $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF |
|
1193 | $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF | |
1175 | > diff --git a/a b/a |
|
1194 | > diff --git a/a b/a | |
1176 | > --- a/a |
|
1195 | > --- a/a | |
1177 | > +++ b/a |
|
1196 | > +++ b/a | |
1178 | > @@ -1,1 +1,1 @@ |
|
1197 | > @@ -1,1 +1,1 @@ | |
1179 | > -2 |
|
1198 | > -2 | |
1180 | > +add some skew |
|
1199 | > +add some skew | |
1181 | > @@ -2,2 +2,3 @@ |
|
1200 | > @@ -2,2 +2,3 @@ | |
1182 | > not matching, should fuzz |
|
1201 | > not matching, should fuzz | |
1183 | > ... a bit |
|
1202 | > ... a bit | |
1184 | > +line |
|
1203 | > +line | |
1185 | > EOF |
|
1204 | > EOF | |
1186 |
|
1205 | |||
1187 | $ cat > a <<EOF |
|
1206 | $ cat > a <<EOF | |
1188 | > 1 |
|
1207 | > 1 | |
1189 | > 2 |
|
1208 | > 2 | |
1190 | > 3 |
|
1209 | > 3 | |
1191 | > 4 |
|
1210 | > 4 | |
1192 | > EOF |
|
1211 | > EOF | |
1193 | $ hg ci -Am adda a |
|
1212 | $ hg ci -Am adda a | |
1194 | $ for p in *.diff; do |
|
1213 | $ for p in *.diff; do | |
1195 | > hg import -v --no-commit $p |
|
1214 | > hg import -v --no-commit $p | |
1196 | > cat a |
|
1215 | > cat a | |
1197 | > hg revert -aqC a |
|
1216 | > hg revert -aqC a | |
1198 | > # patch -p1 < $p |
|
1217 | > # patch -p1 < $p | |
1199 | > # cat a |
|
1218 | > # cat a | |
1200 | > # hg revert -aC a |
|
1219 | > # hg revert -aC a | |
1201 | > done |
|
1220 | > done | |
1202 | applying 01-no-context-beginning-of-file.diff |
|
1221 | applying 01-no-context-beginning-of-file.diff | |
1203 | patching file a |
|
1222 | patching file a | |
1204 | applied to working directory |
|
1223 | applied to working directory | |
1205 | 1 |
|
1224 | 1 | |
1206 | line |
|
1225 | line | |
1207 | 2 |
|
1226 | 2 | |
1208 | 3 |
|
1227 | 3 | |
1209 | 4 |
|
1228 | 4 | |
1210 | applying 02-no-context-middle-of-file.diff |
|
1229 | applying 02-no-context-middle-of-file.diff | |
1211 | patching file a |
|
1230 | patching file a | |
1212 | Hunk #1 succeeded at 2 (offset 1 lines). |
|
1231 | Hunk #1 succeeded at 2 (offset 1 lines). | |
1213 | Hunk #2 succeeded at 4 (offset 1 lines). |
|
1232 | Hunk #2 succeeded at 4 (offset 1 lines). | |
1214 | applied to working directory |
|
1233 | applied to working directory | |
1215 | 1 |
|
1234 | 1 | |
1216 | add some skew |
|
1235 | add some skew | |
1217 | 3 |
|
1236 | 3 | |
1218 | line |
|
1237 | line | |
1219 | 4 |
|
1238 | 4 | |
1220 | applying 03-no-context-end-of-file.diff |
|
1239 | applying 03-no-context-end-of-file.diff | |
1221 | patching file a |
|
1240 | patching file a | |
1222 | Hunk #1 succeeded at 5 (offset -6 lines). |
|
1241 | Hunk #1 succeeded at 5 (offset -6 lines). | |
1223 | applied to working directory |
|
1242 | applied to working directory | |
1224 | 1 |
|
1243 | 1 | |
1225 | 2 |
|
1244 | 2 | |
1226 | 3 |
|
1245 | 3 | |
1227 | 4 |
|
1246 | 4 | |
1228 | line |
|
1247 | line | |
1229 | applying 04-middle-of-file-completely-fuzzed.diff |
|
1248 | applying 04-middle-of-file-completely-fuzzed.diff | |
1230 | patching file a |
|
1249 | patching file a | |
1231 | Hunk #1 succeeded at 2 (offset 1 lines). |
|
1250 | Hunk #1 succeeded at 2 (offset 1 lines). | |
1232 | Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines). |
|
1251 | Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines). | |
1233 | applied to working directory |
|
1252 | applied to working directory | |
1234 | 1 |
|
1253 | 1 | |
1235 | add some skew |
|
1254 | add some skew | |
1236 | 3 |
|
1255 | 3 | |
1237 | 4 |
|
1256 | 4 | |
1238 | line |
|
1257 | line | |
1239 | $ cd .. |
|
1258 | $ cd .. | |
1240 |
|
1259 | |||
1241 | Test partial application |
|
1260 | Test partial application | |
1242 | ------------------------ |
|
1261 | ------------------------ | |
1243 |
|
1262 | |||
1244 | prepare a stack of patches depending on each other |
|
1263 | prepare a stack of patches depending on each other | |
1245 |
|
1264 | |||
1246 | $ hg init partial |
|
1265 | $ hg init partial | |
1247 | $ cd partial |
|
1266 | $ cd partial | |
1248 | $ cat << EOF > a |
|
1267 | $ cat << EOF > a | |
1249 | > one |
|
1268 | > one | |
1250 | > two |
|
1269 | > two | |
1251 | > three |
|
1270 | > three | |
1252 | > four |
|
1271 | > four | |
1253 | > five |
|
1272 | > five | |
1254 | > six |
|
1273 | > six | |
1255 | > seven |
|
1274 | > seven | |
1256 | > EOF |
|
1275 | > EOF | |
1257 | $ hg add a |
|
1276 | $ hg add a | |
1258 | $ echo 'b' > b |
|
1277 | $ echo 'b' > b | |
1259 | $ hg add b |
|
1278 | $ hg add b | |
1260 | $ hg commit -m 'initial' -u Babar |
|
1279 | $ hg commit -m 'initial' -u Babar | |
1261 | $ cat << EOF > a |
|
1280 | $ cat << EOF > a | |
1262 | > one |
|
1281 | > one | |
1263 | > two |
|
1282 | > two | |
1264 | > 3 |
|
1283 | > 3 | |
1265 | > four |
|
1284 | > four | |
1266 | > five |
|
1285 | > five | |
1267 | > six |
|
1286 | > six | |
1268 | > seven |
|
1287 | > seven | |
1269 | > EOF |
|
1288 | > EOF | |
1270 | $ hg commit -m 'three' -u Celeste |
|
1289 | $ hg commit -m 'three' -u Celeste | |
1271 | $ cat << EOF > a |
|
1290 | $ cat << EOF > a | |
1272 | > one |
|
1291 | > one | |
1273 | > two |
|
1292 | > two | |
1274 | > 3 |
|
1293 | > 3 | |
1275 | > 4 |
|
1294 | > 4 | |
1276 | > five |
|
1295 | > five | |
1277 | > six |
|
1296 | > six | |
1278 | > seven |
|
1297 | > seven | |
1279 | > EOF |
|
1298 | > EOF | |
1280 | $ hg commit -m 'four' -u Rataxes |
|
1299 | $ hg commit -m 'four' -u Rataxes | |
1281 | $ cat << EOF > a |
|
1300 | $ cat << EOF > a | |
1282 | > one |
|
1301 | > one | |
1283 | > two |
|
1302 | > two | |
1284 | > 3 |
|
1303 | > 3 | |
1285 | > 4 |
|
1304 | > 4 | |
1286 | > 5 |
|
1305 | > 5 | |
1287 | > six |
|
1306 | > six | |
1288 | > seven |
|
1307 | > seven | |
1289 | > EOF |
|
1308 | > EOF | |
1290 | $ echo bb >> b |
|
1309 | $ echo bb >> b | |
1291 | $ hg commit -m 'five' -u Arthur |
|
1310 | $ hg commit -m 'five' -u Arthur | |
1292 | $ echo 'Babar' > jungle |
|
1311 | $ echo 'Babar' > jungle | |
1293 | $ hg add jungle |
|
1312 | $ hg add jungle | |
1294 | $ hg ci -m 'jungle' -u Zephir |
|
1313 | $ hg ci -m 'jungle' -u Zephir | |
1295 | $ echo 'Celeste' >> jungle |
|
1314 | $ echo 'Celeste' >> jungle | |
1296 | $ hg ci -m 'extended jungle' -u Cornelius |
|
1315 | $ hg ci -m 'extended jungle' -u Cornelius | |
1297 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' |
|
1316 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' | |
1298 | @ extended jungle [Cornelius] 1: +1/-0 |
|
1317 | @ extended jungle [Cornelius] 1: +1/-0 | |
1299 | | |
|
1318 | | | |
1300 | o jungle [Zephir] 1: +1/-0 |
|
1319 | o jungle [Zephir] 1: +1/-0 | |
1301 | | |
|
1320 | | | |
1302 | o five [Arthur] 2: +2/-1 |
|
1321 | o five [Arthur] 2: +2/-1 | |
1303 | | |
|
1322 | | | |
1304 | o four [Rataxes] 1: +1/-1 |
|
1323 | o four [Rataxes] 1: +1/-1 | |
1305 | | |
|
1324 | | | |
1306 | o three [Celeste] 1: +1/-1 |
|
1325 | o three [Celeste] 1: +1/-1 | |
1307 | | |
|
1326 | | | |
1308 | o initial [Babar] 2: +8/-0 |
|
1327 | o initial [Babar] 2: +8/-0 | |
1309 |
|
1328 | |||
1310 |
|
1329 | |||
1311 | Importing with some success and some errors: |
|
1330 | Importing with some success and some errors: | |
1312 |
|
1331 | |||
1313 | $ hg update --rev 'desc(initial)' |
|
1332 | $ hg update --rev 'desc(initial)' | |
1314 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1333 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
1315 | $ hg export --rev 'desc(five)' | hg import --partial - |
|
1334 | $ hg export --rev 'desc(five)' | hg import --partial - | |
1316 | applying patch from stdin |
|
1335 | applying patch from stdin | |
1317 | patching file a |
|
1336 | patching file a | |
1318 | Hunk #1 FAILED at 1 |
|
1337 | Hunk #1 FAILED at 1 | |
1319 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
1338 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
1320 | patch applied partially |
|
1339 | patch applied partially | |
1321 | (fix the .rej files and run `hg commit --amend`) |
|
1340 | (fix the .rej files and run `hg commit --amend`) | |
1322 | [1] |
|
1341 | [1] | |
1323 |
|
1342 | |||
1324 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' |
|
1343 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' | |
1325 | @ five [Arthur] 1: +1/-0 |
|
1344 | @ five [Arthur] 1: +1/-0 | |
1326 | | |
|
1345 | | | |
1327 | | o extended jungle [Cornelius] 1: +1/-0 |
|
1346 | | o extended jungle [Cornelius] 1: +1/-0 | |
1328 | | | |
|
1347 | | | | |
1329 | | o jungle [Zephir] 1: +1/-0 |
|
1348 | | o jungle [Zephir] 1: +1/-0 | |
1330 | | | |
|
1349 | | | | |
1331 | | o five [Arthur] 2: +2/-1 |
|
1350 | | o five [Arthur] 2: +2/-1 | |
1332 | | | |
|
1351 | | | | |
1333 | | o four [Rataxes] 1: +1/-1 |
|
1352 | | o four [Rataxes] 1: +1/-1 | |
1334 | | | |
|
1353 | | | | |
1335 | | o three [Celeste] 1: +1/-1 |
|
1354 | | o three [Celeste] 1: +1/-1 | |
1336 | |/ |
|
1355 | |/ | |
1337 | o initial [Babar] 2: +8/-0 |
|
1356 | o initial [Babar] 2: +8/-0 | |
1338 |
|
1357 | |||
1339 | $ hg export |
|
1358 | $ hg export | |
1340 | # HG changeset patch |
|
1359 | # HG changeset patch | |
1341 | # User Arthur |
|
1360 | # User Arthur | |
1342 | # Date 0 0 |
|
1361 | # Date 0 0 | |
1343 | # Thu Jan 01 00:00:00 1970 +0000 |
|
1362 | # Thu Jan 01 00:00:00 1970 +0000 | |
1344 | # Node ID 26e6446bb2526e2be1037935f5fca2b2706f1509 |
|
1363 | # Node ID 26e6446bb2526e2be1037935f5fca2b2706f1509 | |
1345 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e |
|
1364 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e | |
1346 | five |
|
1365 | five | |
1347 |
|
1366 | |||
1348 | diff -r 8e4f0351909e -r 26e6446bb252 b |
|
1367 | diff -r 8e4f0351909e -r 26e6446bb252 b | |
1349 | --- a/b Thu Jan 01 00:00:00 1970 +0000 |
|
1368 | --- a/b Thu Jan 01 00:00:00 1970 +0000 | |
1350 | +++ b/b Thu Jan 01 00:00:00 1970 +0000 |
|
1369 | +++ b/b Thu Jan 01 00:00:00 1970 +0000 | |
1351 | @@ -1,1 +1,2 @@ |
|
1370 | @@ -1,1 +1,2 @@ | |
1352 | b |
|
1371 | b | |
1353 | +bb |
|
1372 | +bb | |
1354 | $ hg status -c . |
|
1373 | $ hg status -c . | |
1355 | C a |
|
1374 | C a | |
1356 | C b |
|
1375 | C b | |
1357 | $ ls |
|
1376 | $ ls | |
1358 | a |
|
1377 | a | |
1359 | a.rej |
|
1378 | a.rej | |
1360 | b |
|
1379 | b | |
1361 |
|
1380 | |||
1362 | Importing with zero success: |
|
1381 | Importing with zero success: | |
1363 |
|
1382 | |||
1364 | $ hg update --rev 'desc(initial)' |
|
1383 | $ hg update --rev 'desc(initial)' | |
1365 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1384 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1366 | $ hg export --rev 'desc(four)' | hg import --partial - |
|
1385 | $ hg export --rev 'desc(four)' | hg import --partial - | |
1367 | applying patch from stdin |
|
1386 | applying patch from stdin | |
1368 | patching file a |
|
1387 | patching file a | |
1369 | Hunk #1 FAILED at 0 |
|
1388 | Hunk #1 FAILED at 0 | |
1370 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
1389 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
1371 | patch applied partially |
|
1390 | patch applied partially | |
1372 | (fix the .rej files and run `hg commit --amend`) |
|
1391 | (fix the .rej files and run `hg commit --amend`) | |
1373 | [1] |
|
1392 | [1] | |
1374 |
|
1393 | |||
1375 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' |
|
1394 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' | |
1376 | @ four [Rataxes] 0: +0/-0 |
|
1395 | @ four [Rataxes] 0: +0/-0 | |
1377 | | |
|
1396 | | | |
1378 | | o five [Arthur] 1: +1/-0 |
|
1397 | | o five [Arthur] 1: +1/-0 | |
1379 | |/ |
|
1398 | |/ | |
1380 | | o extended jungle [Cornelius] 1: +1/-0 |
|
1399 | | o extended jungle [Cornelius] 1: +1/-0 | |
1381 | | | |
|
1400 | | | | |
1382 | | o jungle [Zephir] 1: +1/-0 |
|
1401 | | o jungle [Zephir] 1: +1/-0 | |
1383 | | | |
|
1402 | | | | |
1384 | | o five [Arthur] 2: +2/-1 |
|
1403 | | o five [Arthur] 2: +2/-1 | |
1385 | | | |
|
1404 | | | | |
1386 | | o four [Rataxes] 1: +1/-1 |
|
1405 | | o four [Rataxes] 1: +1/-1 | |
1387 | | | |
|
1406 | | | | |
1388 | | o three [Celeste] 1: +1/-1 |
|
1407 | | o three [Celeste] 1: +1/-1 | |
1389 | |/ |
|
1408 | |/ | |
1390 | o initial [Babar] 2: +8/-0 |
|
1409 | o initial [Babar] 2: +8/-0 | |
1391 |
|
1410 | |||
1392 | $ hg export |
|
1411 | $ hg export | |
1393 | # HG changeset patch |
|
1412 | # HG changeset patch | |
1394 | # User Rataxes |
|
1413 | # User Rataxes | |
1395 | # Date 0 0 |
|
1414 | # Date 0 0 | |
1396 | # Thu Jan 01 00:00:00 1970 +0000 |
|
1415 | # Thu Jan 01 00:00:00 1970 +0000 | |
1397 | # Node ID cb9b1847a74d9ad52e93becaf14b98dbcc274e1e |
|
1416 | # Node ID cb9b1847a74d9ad52e93becaf14b98dbcc274e1e | |
1398 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e |
|
1417 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e | |
1399 | four |
|
1418 | four | |
1400 |
|
1419 | |||
1401 | $ hg status -c . |
|
1420 | $ hg status -c . | |
1402 | C a |
|
1421 | C a | |
1403 | C b |
|
1422 | C b | |
1404 | $ ls |
|
1423 | $ ls | |
1405 | a |
|
1424 | a | |
1406 | a.rej |
|
1425 | a.rej | |
1407 | b |
|
1426 | b | |
1408 |
|
1427 | |||
1409 | Importing with unknown file: |
|
1428 | Importing with unknown file: | |
1410 |
|
1429 | |||
1411 | $ hg update --rev 'desc(initial)' |
|
1430 | $ hg update --rev 'desc(initial)' | |
1412 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1431 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1413 | $ hg export --rev 'desc("extended jungle")' | hg import --partial - |
|
1432 | $ hg export --rev 'desc("extended jungle")' | hg import --partial - | |
1414 | applying patch from stdin |
|
1433 | applying patch from stdin | |
1415 | unable to find 'jungle' for patching |
|
1434 | unable to find 'jungle' for patching | |
1416 | 1 out of 1 hunks FAILED -- saving rejects to file jungle.rej |
|
1435 | 1 out of 1 hunks FAILED -- saving rejects to file jungle.rej | |
1417 | patch applied partially |
|
1436 | patch applied partially | |
1418 | (fix the .rej files and run `hg commit --amend`) |
|
1437 | (fix the .rej files and run `hg commit --amend`) | |
1419 | [1] |
|
1438 | [1] | |
1420 |
|
1439 | |||
1421 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' |
|
1440 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' | |
1422 | @ extended jungle [Cornelius] 0: +0/-0 |
|
1441 | @ extended jungle [Cornelius] 0: +0/-0 | |
1423 | | |
|
1442 | | | |
1424 | | o four [Rataxes] 0: +0/-0 |
|
1443 | | o four [Rataxes] 0: +0/-0 | |
1425 | |/ |
|
1444 | |/ | |
1426 | | o five [Arthur] 1: +1/-0 |
|
1445 | | o five [Arthur] 1: +1/-0 | |
1427 | |/ |
|
1446 | |/ | |
1428 | | o extended jungle [Cornelius] 1: +1/-0 |
|
1447 | | o extended jungle [Cornelius] 1: +1/-0 | |
1429 | | | |
|
1448 | | | | |
1430 | | o jungle [Zephir] 1: +1/-0 |
|
1449 | | o jungle [Zephir] 1: +1/-0 | |
1431 | | | |
|
1450 | | | | |
1432 | | o five [Arthur] 2: +2/-1 |
|
1451 | | o five [Arthur] 2: +2/-1 | |
1433 | | | |
|
1452 | | | | |
1434 | | o four [Rataxes] 1: +1/-1 |
|
1453 | | o four [Rataxes] 1: +1/-1 | |
1435 | | | |
|
1454 | | | | |
1436 | | o three [Celeste] 1: +1/-1 |
|
1455 | | o three [Celeste] 1: +1/-1 | |
1437 | |/ |
|
1456 | |/ | |
1438 | o initial [Babar] 2: +8/-0 |
|
1457 | o initial [Babar] 2: +8/-0 | |
1439 |
|
1458 | |||
1440 | $ hg export |
|
1459 | $ hg export | |
1441 | # HG changeset patch |
|
1460 | # HG changeset patch | |
1442 | # User Cornelius |
|
1461 | # User Cornelius | |
1443 | # Date 0 0 |
|
1462 | # Date 0 0 | |
1444 | # Thu Jan 01 00:00:00 1970 +0000 |
|
1463 | # Thu Jan 01 00:00:00 1970 +0000 | |
1445 | # Node ID 1fb1f86bef43c5a75918178f8d23c29fb0a7398d |
|
1464 | # Node ID 1fb1f86bef43c5a75918178f8d23c29fb0a7398d | |
1446 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e |
|
1465 | # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e | |
1447 | extended jungle |
|
1466 | extended jungle | |
1448 |
|
1467 | |||
1449 | $ hg status -c . |
|
1468 | $ hg status -c . | |
1450 | C a |
|
1469 | C a | |
1451 | C b |
|
1470 | C b | |
1452 | $ ls |
|
1471 | $ ls | |
1453 | a |
|
1472 | a | |
1454 | a.rej |
|
1473 | a.rej | |
1455 | b |
|
1474 | b | |
1456 | jungle.rej |
|
1475 | jungle.rej | |
1457 |
|
1476 | |||
1458 | Importing multiple failing patches: |
|
1477 | Importing multiple failing patches: | |
1459 |
|
1478 | |||
1460 | $ hg update --rev 'desc(initial)' |
|
1479 | $ hg update --rev 'desc(initial)' | |
1461 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1480 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1462 | $ echo 'B' > b # just to make another commit |
|
1481 | $ echo 'B' > b # just to make another commit | |
1463 | $ hg commit -m "a new base" |
|
1482 | $ hg commit -m "a new base" | |
1464 | created new head |
|
1483 | created new head | |
1465 | $ hg export --rev 'desc("four") + desc("extended jungle")' | hg import --partial - |
|
1484 | $ hg export --rev 'desc("four") + desc("extended jungle")' | hg import --partial - | |
1466 | applying patch from stdin |
|
1485 | applying patch from stdin | |
1467 | patching file a |
|
1486 | patching file a | |
1468 | Hunk #1 FAILED at 0 |
|
1487 | Hunk #1 FAILED at 0 | |
1469 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
1488 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
1470 | patch applied partially |
|
1489 | patch applied partially | |
1471 | (fix the .rej files and run `hg commit --amend`) |
|
1490 | (fix the .rej files and run `hg commit --amend`) | |
1472 | [1] |
|
1491 | [1] | |
1473 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' |
|
1492 | $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n' | |
1474 | @ four [Rataxes] 0: +0/-0 |
|
1493 | @ four [Rataxes] 0: +0/-0 | |
1475 | | |
|
1494 | | | |
1476 | o a new base [test] 1: +1/-1 |
|
1495 | o a new base [test] 1: +1/-1 | |
1477 | | |
|
1496 | | | |
1478 | | o extended jungle [Cornelius] 0: +0/-0 |
|
1497 | | o extended jungle [Cornelius] 0: +0/-0 | |
1479 | |/ |
|
1498 | |/ | |
1480 | | o four [Rataxes] 0: +0/-0 |
|
1499 | | o four [Rataxes] 0: +0/-0 | |
1481 | |/ |
|
1500 | |/ | |
1482 | | o five [Arthur] 1: +1/-0 |
|
1501 | | o five [Arthur] 1: +1/-0 | |
1483 | |/ |
|
1502 | |/ | |
1484 | | o extended jungle [Cornelius] 1: +1/-0 |
|
1503 | | o extended jungle [Cornelius] 1: +1/-0 | |
1485 | | | |
|
1504 | | | | |
1486 | | o jungle [Zephir] 1: +1/-0 |
|
1505 | | o jungle [Zephir] 1: +1/-0 | |
1487 | | | |
|
1506 | | | | |
1488 | | o five [Arthur] 2: +2/-1 |
|
1507 | | o five [Arthur] 2: +2/-1 | |
1489 | | | |
|
1508 | | | | |
1490 | | o four [Rataxes] 1: +1/-1 |
|
1509 | | o four [Rataxes] 1: +1/-1 | |
1491 | | | |
|
1510 | | | | |
1492 | | o three [Celeste] 1: +1/-1 |
|
1511 | | o three [Celeste] 1: +1/-1 | |
1493 | |/ |
|
1512 | |/ | |
1494 | o initial [Babar] 2: +8/-0 |
|
1513 | o initial [Babar] 2: +8/-0 | |
1495 |
|
1514 | |||
1496 | $ hg export |
|
1515 | $ hg export | |
1497 | # HG changeset patch |
|
1516 | # HG changeset patch | |
1498 | # User Rataxes |
|
1517 | # User Rataxes | |
1499 | # Date 0 0 |
|
1518 | # Date 0 0 | |
1500 | # Thu Jan 01 00:00:00 1970 +0000 |
|
1519 | # Thu Jan 01 00:00:00 1970 +0000 | |
1501 | # Node ID a9d7b6d0ffbb4eb12b7d5939250fcd42e8930a1d |
|
1520 | # Node ID a9d7b6d0ffbb4eb12b7d5939250fcd42e8930a1d | |
1502 | # Parent f59f8d2e95a8ca5b1b4ca64320140da85f3b44fd |
|
1521 | # Parent f59f8d2e95a8ca5b1b4ca64320140da85f3b44fd | |
1503 | four |
|
1522 | four | |
1504 |
|
1523 | |||
1505 | $ hg status -c . |
|
1524 | $ hg status -c . | |
1506 | C a |
|
1525 | C a | |
1507 | C b |
|
1526 | C b | |
1508 |
|
1527 | |||
1509 | Importing some extra header |
|
1528 | Importing some extra header | |
1510 | =========================== |
|
1529 | =========================== | |
1511 |
|
1530 | |||
1512 | $ cat > $TESTTMP/parseextra.py <<EOF |
|
1531 | $ cat > $TESTTMP/parseextra.py <<EOF | |
1513 | > import mercurial.patch |
|
1532 | > import mercurial.patch | |
1514 | > import mercurial.cmdutil |
|
1533 | > import mercurial.cmdutil | |
1515 | > |
|
1534 | > | |
1516 | > def processfoo(repo, data, extra, opts): |
|
1535 | > def processfoo(repo, data, extra, opts): | |
1517 | > if 'foo' in data: |
|
1536 | > if 'foo' in data: | |
1518 | > extra['foo'] = data['foo'] |
|
1537 | > extra['foo'] = data['foo'] | |
1519 | > def postimport(ctx): |
|
1538 | > def postimport(ctx): | |
1520 | > if 'foo' in ctx.extra(): |
|
1539 | > if 'foo' in ctx.extra(): | |
1521 | > ctx.repo().ui.write('imported-foo: %s\n' % ctx.extra()['foo']) |
|
1540 | > ctx.repo().ui.write('imported-foo: %s\n' % ctx.extra()['foo']) | |
1522 | > |
|
1541 | > | |
1523 | > mercurial.patch.patchheadermap.append(('Foo', 'foo')) |
|
1542 | > mercurial.patch.patchheadermap.append(('Foo', 'foo')) | |
1524 | > mercurial.cmdutil.extrapreimport.append('foo') |
|
1543 | > mercurial.cmdutil.extrapreimport.append('foo') | |
1525 | > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo |
|
1544 | > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo | |
1526 | > mercurial.cmdutil.extrapostimport.append('foo') |
|
1545 | > mercurial.cmdutil.extrapostimport.append('foo') | |
1527 | > mercurial.cmdutil.extrapostimportmap['foo'] = postimport |
|
1546 | > mercurial.cmdutil.extrapostimportmap['foo'] = postimport | |
1528 | > EOF |
|
1547 | > EOF | |
1529 | $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH |
|
1548 | $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH | |
1530 | $ hg up -C tip |
|
1549 | $ hg up -C tip | |
1531 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1550 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1532 | $ cat > $TESTTMP/foo.patch <<EOF |
|
1551 | $ cat > $TESTTMP/foo.patch <<EOF | |
1533 | > # HG changeset patch |
|
1552 | > # HG changeset patch | |
1534 | > # User Rataxes |
|
1553 | > # User Rataxes | |
1535 | > # Date 0 0 |
|
1554 | > # Date 0 0 | |
1536 | > # Thu Jan 01 00:00:00 1970 +0000 |
|
1555 | > # Thu Jan 01 00:00:00 1970 +0000 | |
1537 | > # Foo bar |
|
1556 | > # Foo bar | |
1538 | > height |
|
1557 | > height | |
1539 | > |
|
1558 | > | |
1540 | > --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
1559 | > --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
1541 | > +++ b/a Wed Oct 07 09:17:44 2015 +0000 |
|
1560 | > +++ b/a Wed Oct 07 09:17:44 2015 +0000 | |
1542 | > @@ -5,3 +5,4 @@ |
|
1561 | > @@ -5,3 +5,4 @@ | |
1543 | > five |
|
1562 | > five | |
1544 | > six |
|
1563 | > six | |
1545 | > seven |
|
1564 | > seven | |
1546 | > +heigt |
|
1565 | > +heigt | |
1547 | > EOF |
|
1566 | > EOF | |
1548 | $ hg import $TESTTMP/foo.patch |
|
1567 | $ hg import $TESTTMP/foo.patch | |
1549 | applying $TESTTMP/foo.patch |
|
1568 | applying $TESTTMP/foo.patch | |
1550 | imported-foo: bar |
|
1569 | imported-foo: bar | |
1551 | $ hg log --debug -r . | grep extra |
|
1570 | $ hg log --debug -r . | grep extra | |
1552 | extra: branch=default |
|
1571 | extra: branch=default | |
1553 | extra: foo=bar |
|
1572 | extra: foo=bar |
General Comments 0
You need to be logged in to leave comments.
Login now