Show More
@@ -1,2566 +1,2566 b'' | |||||
1 | # context.py - changeset and file context objects for mercurial |
|
1 | # context.py - changeset and file context objects for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import errno |
|
10 | import errno | |
11 | import filecmp |
|
11 | import filecmp | |
12 | import os |
|
12 | import os | |
13 | import stat |
|
13 | import stat | |
14 |
|
14 | |||
15 | from .i18n import _ |
|
15 | from .i18n import _ | |
16 | from .node import ( |
|
16 | from .node import ( | |
17 | addednodeid, |
|
17 | addednodeid, | |
18 | hex, |
|
18 | hex, | |
19 | modifiednodeid, |
|
19 | modifiednodeid, | |
20 | nullid, |
|
20 | nullid, | |
21 | nullrev, |
|
21 | nullrev, | |
22 | short, |
|
22 | short, | |
23 | wdirfilenodeids, |
|
23 | wdirfilenodeids, | |
24 | wdirhex, |
|
24 | wdirhex, | |
25 | ) |
|
25 | ) | |
26 | from . import ( |
|
26 | from . import ( | |
27 | dagop, |
|
27 | dagop, | |
28 | encoding, |
|
28 | encoding, | |
29 | error, |
|
29 | error, | |
30 | fileset, |
|
30 | fileset, | |
31 | match as matchmod, |
|
31 | match as matchmod, | |
32 | obsolete as obsmod, |
|
32 | obsolete as obsmod, | |
33 | patch, |
|
33 | patch, | |
34 | pathutil, |
|
34 | pathutil, | |
35 | phases, |
|
35 | phases, | |
36 | pycompat, |
|
36 | pycompat, | |
37 | repoview, |
|
37 | repoview, | |
38 | scmutil, |
|
38 | scmutil, | |
39 | sparse, |
|
39 | sparse, | |
40 | subrepo, |
|
40 | subrepo, | |
41 | subrepoutil, |
|
41 | subrepoutil, | |
42 | util, |
|
42 | util, | |
43 | ) |
|
43 | ) | |
44 | from .utils import ( |
|
44 | from .utils import ( | |
45 | dateutil, |
|
45 | dateutil, | |
46 | stringutil, |
|
46 | stringutil, | |
47 | ) |
|
47 | ) | |
48 |
|
48 | |||
49 | propertycache = util.propertycache |
|
49 | propertycache = util.propertycache | |
50 |
|
50 | |||
51 | class basectx(object): |
|
51 | class basectx(object): | |
52 | """A basectx object represents the common logic for its children: |
|
52 | """A basectx object represents the common logic for its children: | |
53 | changectx: read-only context that is already present in the repo, |
|
53 | changectx: read-only context that is already present in the repo, | |
54 | workingctx: a context that represents the working directory and can |
|
54 | workingctx: a context that represents the working directory and can | |
55 | be committed, |
|
55 | be committed, | |
56 | memctx: a context that represents changes in-memory and can also |
|
56 | memctx: a context that represents changes in-memory and can also | |
57 | be committed.""" |
|
57 | be committed.""" | |
58 |
|
58 | |||
59 | def __init__(self, repo): |
|
59 | def __init__(self, repo): | |
60 | self._repo = repo |
|
60 | self._repo = repo | |
61 |
|
61 | |||
62 | def __bytes__(self): |
|
62 | def __bytes__(self): | |
63 | return short(self.node()) |
|
63 | return short(self.node()) | |
64 |
|
64 | |||
65 | __str__ = encoding.strmethod(__bytes__) |
|
65 | __str__ = encoding.strmethod(__bytes__) | |
66 |
|
66 | |||
67 | def __repr__(self): |
|
67 | def __repr__(self): | |
68 | return r"<%s %s>" % (type(self).__name__, str(self)) |
|
68 | return r"<%s %s>" % (type(self).__name__, str(self)) | |
69 |
|
69 | |||
70 | def __eq__(self, other): |
|
70 | def __eq__(self, other): | |
71 | try: |
|
71 | try: | |
72 | return type(self) == type(other) and self._rev == other._rev |
|
72 | return type(self) == type(other) and self._rev == other._rev | |
73 | except AttributeError: |
|
73 | except AttributeError: | |
74 | return False |
|
74 | return False | |
75 |
|
75 | |||
76 | def __ne__(self, other): |
|
76 | def __ne__(self, other): | |
77 | return not (self == other) |
|
77 | return not (self == other) | |
78 |
|
78 | |||
79 | def __contains__(self, key): |
|
79 | def __contains__(self, key): | |
80 | return key in self._manifest |
|
80 | return key in self._manifest | |
81 |
|
81 | |||
82 | def __getitem__(self, key): |
|
82 | def __getitem__(self, key): | |
83 | return self.filectx(key) |
|
83 | return self.filectx(key) | |
84 |
|
84 | |||
85 | def __iter__(self): |
|
85 | def __iter__(self): | |
86 | return iter(self._manifest) |
|
86 | return iter(self._manifest) | |
87 |
|
87 | |||
88 | def _buildstatusmanifest(self, status): |
|
88 | def _buildstatusmanifest(self, status): | |
89 | """Builds a manifest that includes the given status results, if this is |
|
89 | """Builds a manifest that includes the given status results, if this is | |
90 | a working copy context. For non-working copy contexts, it just returns |
|
90 | a working copy context. For non-working copy contexts, it just returns | |
91 | the normal manifest.""" |
|
91 | the normal manifest.""" | |
92 | return self.manifest() |
|
92 | return self.manifest() | |
93 |
|
93 | |||
94 | def _matchstatus(self, other, match): |
|
94 | def _matchstatus(self, other, match): | |
95 | """This internal method provides a way for child objects to override the |
|
95 | """This internal method provides a way for child objects to override the | |
96 | match operator. |
|
96 | match operator. | |
97 | """ |
|
97 | """ | |
98 | return match |
|
98 | return match | |
99 |
|
99 | |||
100 | def _buildstatus(self, other, s, match, listignored, listclean, |
|
100 | def _buildstatus(self, other, s, match, listignored, listclean, | |
101 | listunknown): |
|
101 | listunknown): | |
102 | """build a status with respect to another context""" |
|
102 | """build a status with respect to another context""" | |
103 | # Load earliest manifest first for caching reasons. More specifically, |
|
103 | # Load earliest manifest first for caching reasons. More specifically, | |
104 | # if you have revisions 1000 and 1001, 1001 is probably stored as a |
|
104 | # if you have revisions 1000 and 1001, 1001 is probably stored as a | |
105 | # delta against 1000. Thus, if you read 1000 first, we'll reconstruct |
|
105 | # delta against 1000. Thus, if you read 1000 first, we'll reconstruct | |
106 | # 1000 and cache it so that when you read 1001, we just need to apply a |
|
106 | # 1000 and cache it so that when you read 1001, we just need to apply a | |
107 | # delta to what's in the cache. So that's one full reconstruction + one |
|
107 | # delta to what's in the cache. So that's one full reconstruction + one | |
108 | # delta application. |
|
108 | # delta application. | |
109 | mf2 = None |
|
109 | mf2 = None | |
110 | if self.rev() is not None and self.rev() < other.rev(): |
|
110 | if self.rev() is not None and self.rev() < other.rev(): | |
111 | mf2 = self._buildstatusmanifest(s) |
|
111 | mf2 = self._buildstatusmanifest(s) | |
112 | mf1 = other._buildstatusmanifest(s) |
|
112 | mf1 = other._buildstatusmanifest(s) | |
113 | if mf2 is None: |
|
113 | if mf2 is None: | |
114 | mf2 = self._buildstatusmanifest(s) |
|
114 | mf2 = self._buildstatusmanifest(s) | |
115 |
|
115 | |||
116 | modified, added = [], [] |
|
116 | modified, added = [], [] | |
117 | removed = [] |
|
117 | removed = [] | |
118 | clean = [] |
|
118 | clean = [] | |
119 | deleted, unknown, ignored = s.deleted, s.unknown, s.ignored |
|
119 | deleted, unknown, ignored = s.deleted, s.unknown, s.ignored | |
120 | deletedset = set(deleted) |
|
120 | deletedset = set(deleted) | |
121 | d = mf1.diff(mf2, match=match, clean=listclean) |
|
121 | d = mf1.diff(mf2, match=match, clean=listclean) | |
122 | for fn, value in d.iteritems(): |
|
122 | for fn, value in d.iteritems(): | |
123 | if fn in deletedset: |
|
123 | if fn in deletedset: | |
124 | continue |
|
124 | continue | |
125 | if value is None: |
|
125 | if value is None: | |
126 | clean.append(fn) |
|
126 | clean.append(fn) | |
127 | continue |
|
127 | continue | |
128 | (node1, flag1), (node2, flag2) = value |
|
128 | (node1, flag1), (node2, flag2) = value | |
129 | if node1 is None: |
|
129 | if node1 is None: | |
130 | added.append(fn) |
|
130 | added.append(fn) | |
131 | elif node2 is None: |
|
131 | elif node2 is None: | |
132 | removed.append(fn) |
|
132 | removed.append(fn) | |
133 | elif flag1 != flag2: |
|
133 | elif flag1 != flag2: | |
134 | modified.append(fn) |
|
134 | modified.append(fn) | |
135 | elif node2 not in wdirfilenodeids: |
|
135 | elif node2 not in wdirfilenodeids: | |
136 | # When comparing files between two commits, we save time by |
|
136 | # When comparing files between two commits, we save time by | |
137 | # not comparing the file contents when the nodeids differ. |
|
137 | # not comparing the file contents when the nodeids differ. | |
138 | # Note that this means we incorrectly report a reverted change |
|
138 | # Note that this means we incorrectly report a reverted change | |
139 | # to a file as a modification. |
|
139 | # to a file as a modification. | |
140 | modified.append(fn) |
|
140 | modified.append(fn) | |
141 | elif self[fn].cmp(other[fn]): |
|
141 | elif self[fn].cmp(other[fn]): | |
142 | modified.append(fn) |
|
142 | modified.append(fn) | |
143 | else: |
|
143 | else: | |
144 | clean.append(fn) |
|
144 | clean.append(fn) | |
145 |
|
145 | |||
146 | if removed: |
|
146 | if removed: | |
147 | # need to filter files if they are already reported as removed |
|
147 | # need to filter files if they are already reported as removed | |
148 | unknown = [fn for fn in unknown if fn not in mf1 and |
|
148 | unknown = [fn for fn in unknown if fn not in mf1 and | |
149 | (not match or match(fn))] |
|
149 | (not match or match(fn))] | |
150 | ignored = [fn for fn in ignored if fn not in mf1 and |
|
150 | ignored = [fn for fn in ignored if fn not in mf1 and | |
151 | (not match or match(fn))] |
|
151 | (not match or match(fn))] | |
152 | # if they're deleted, don't report them as removed |
|
152 | # if they're deleted, don't report them as removed | |
153 | removed = [fn for fn in removed if fn not in deletedset] |
|
153 | removed = [fn for fn in removed if fn not in deletedset] | |
154 |
|
154 | |||
155 | return scmutil.status(modified, added, removed, deleted, unknown, |
|
155 | return scmutil.status(modified, added, removed, deleted, unknown, | |
156 | ignored, clean) |
|
156 | ignored, clean) | |
157 |
|
157 | |||
158 | @propertycache |
|
158 | @propertycache | |
159 | def substate(self): |
|
159 | def substate(self): | |
160 | return subrepoutil.state(self, self._repo.ui) |
|
160 | return subrepoutil.state(self, self._repo.ui) | |
161 |
|
161 | |||
162 | def subrev(self, subpath): |
|
162 | def subrev(self, subpath): | |
163 | return self.substate[subpath][1] |
|
163 | return self.substate[subpath][1] | |
164 |
|
164 | |||
165 | def rev(self): |
|
165 | def rev(self): | |
166 | return self._rev |
|
166 | return self._rev | |
167 | def node(self): |
|
167 | def node(self): | |
168 | return self._node |
|
168 | return self._node | |
169 | def hex(self): |
|
169 | def hex(self): | |
170 | return hex(self.node()) |
|
170 | return hex(self.node()) | |
171 | def manifest(self): |
|
171 | def manifest(self): | |
172 | return self._manifest |
|
172 | return self._manifest | |
173 | def manifestctx(self): |
|
173 | def manifestctx(self): | |
174 | return self._manifestctx |
|
174 | return self._manifestctx | |
175 | def repo(self): |
|
175 | def repo(self): | |
176 | return self._repo |
|
176 | return self._repo | |
177 | def phasestr(self): |
|
177 | def phasestr(self): | |
178 | return phases.phasenames[self.phase()] |
|
178 | return phases.phasenames[self.phase()] | |
179 | def mutable(self): |
|
179 | def mutable(self): | |
180 | return self.phase() > phases.public |
|
180 | return self.phase() > phases.public | |
181 |
|
181 | |||
182 | def matchfileset(self, expr, badfn=None): |
|
182 | def matchfileset(self, expr, badfn=None): | |
183 | return fileset.match(self, expr, badfn=badfn) |
|
183 | return fileset.match(self, expr, badfn=badfn) | |
184 |
|
184 | |||
185 | def obsolete(self): |
|
185 | def obsolete(self): | |
186 | """True if the changeset is obsolete""" |
|
186 | """True if the changeset is obsolete""" | |
187 | return self.rev() in obsmod.getrevs(self._repo, 'obsolete') |
|
187 | return self.rev() in obsmod.getrevs(self._repo, 'obsolete') | |
188 |
|
188 | |||
189 | def extinct(self): |
|
189 | def extinct(self): | |
190 | """True if the changeset is extinct""" |
|
190 | """True if the changeset is extinct""" | |
191 | return self.rev() in obsmod.getrevs(self._repo, 'extinct') |
|
191 | return self.rev() in obsmod.getrevs(self._repo, 'extinct') | |
192 |
|
192 | |||
193 | def orphan(self): |
|
193 | def orphan(self): | |
194 | """True if the changeset is not obsolete, but its ancestor is""" |
|
194 | """True if the changeset is not obsolete, but its ancestor is""" | |
195 | return self.rev() in obsmod.getrevs(self._repo, 'orphan') |
|
195 | return self.rev() in obsmod.getrevs(self._repo, 'orphan') | |
196 |
|
196 | |||
197 | def phasedivergent(self): |
|
197 | def phasedivergent(self): | |
198 | """True if the changeset tries to be a successor of a public changeset |
|
198 | """True if the changeset tries to be a successor of a public changeset | |
199 |
|
199 | |||
200 | Only non-public and non-obsolete changesets may be phase-divergent. |
|
200 | Only non-public and non-obsolete changesets may be phase-divergent. | |
201 | """ |
|
201 | """ | |
202 | return self.rev() in obsmod.getrevs(self._repo, 'phasedivergent') |
|
202 | return self.rev() in obsmod.getrevs(self._repo, 'phasedivergent') | |
203 |
|
203 | |||
204 | def contentdivergent(self): |
|
204 | def contentdivergent(self): | |
205 | """Is a successor of a changeset with multiple possible successor sets |
|
205 | """Is a successor of a changeset with multiple possible successor sets | |
206 |
|
206 | |||
207 | Only non-public and non-obsolete changesets may be content-divergent. |
|
207 | Only non-public and non-obsolete changesets may be content-divergent. | |
208 | """ |
|
208 | """ | |
209 | return self.rev() in obsmod.getrevs(self._repo, 'contentdivergent') |
|
209 | return self.rev() in obsmod.getrevs(self._repo, 'contentdivergent') | |
210 |
|
210 | |||
211 | def isunstable(self): |
|
211 | def isunstable(self): | |
212 | """True if the changeset is either orphan, phase-divergent or |
|
212 | """True if the changeset is either orphan, phase-divergent or | |
213 | content-divergent""" |
|
213 | content-divergent""" | |
214 | return self.orphan() or self.phasedivergent() or self.contentdivergent() |
|
214 | return self.orphan() or self.phasedivergent() or self.contentdivergent() | |
215 |
|
215 | |||
216 | def instabilities(self): |
|
216 | def instabilities(self): | |
217 | """return the list of instabilities affecting this changeset. |
|
217 | """return the list of instabilities affecting this changeset. | |
218 |
|
218 | |||
219 | Instabilities are returned as strings. possible values are: |
|
219 | Instabilities are returned as strings. possible values are: | |
220 | - orphan, |
|
220 | - orphan, | |
221 | - phase-divergent, |
|
221 | - phase-divergent, | |
222 | - content-divergent. |
|
222 | - content-divergent. | |
223 | """ |
|
223 | """ | |
224 | instabilities = [] |
|
224 | instabilities = [] | |
225 | if self.orphan(): |
|
225 | if self.orphan(): | |
226 | instabilities.append('orphan') |
|
226 | instabilities.append('orphan') | |
227 | if self.phasedivergent(): |
|
227 | if self.phasedivergent(): | |
228 | instabilities.append('phase-divergent') |
|
228 | instabilities.append('phase-divergent') | |
229 | if self.contentdivergent(): |
|
229 | if self.contentdivergent(): | |
230 | instabilities.append('content-divergent') |
|
230 | instabilities.append('content-divergent') | |
231 | return instabilities |
|
231 | return instabilities | |
232 |
|
232 | |||
233 | def parents(self): |
|
233 | def parents(self): | |
234 | """return contexts for each parent changeset""" |
|
234 | """return contexts for each parent changeset""" | |
235 | return self._parents |
|
235 | return self._parents | |
236 |
|
236 | |||
237 | def p1(self): |
|
237 | def p1(self): | |
238 | return self._parents[0] |
|
238 | return self._parents[0] | |
239 |
|
239 | |||
240 | def p2(self): |
|
240 | def p2(self): | |
241 | parents = self._parents |
|
241 | parents = self._parents | |
242 | if len(parents) == 2: |
|
242 | if len(parents) == 2: | |
243 | return parents[1] |
|
243 | return parents[1] | |
244 | return self._repo[nullrev] |
|
244 | return self._repo[nullrev] | |
245 |
|
245 | |||
246 | def _fileinfo(self, path): |
|
246 | def _fileinfo(self, path): | |
247 | if r'_manifest' in self.__dict__: |
|
247 | if r'_manifest' in self.__dict__: | |
248 | try: |
|
248 | try: | |
249 | return self._manifest[path], self._manifest.flags(path) |
|
249 | return self._manifest[path], self._manifest.flags(path) | |
250 | except KeyError: |
|
250 | except KeyError: | |
251 | raise error.ManifestLookupError(self._node, path, |
|
251 | raise error.ManifestLookupError(self._node, path, | |
252 | _('not found in manifest')) |
|
252 | _('not found in manifest')) | |
253 | if r'_manifestdelta' in self.__dict__ or path in self.files(): |
|
253 | if r'_manifestdelta' in self.__dict__ or path in self.files(): | |
254 | if path in self._manifestdelta: |
|
254 | if path in self._manifestdelta: | |
255 | return (self._manifestdelta[path], |
|
255 | return (self._manifestdelta[path], | |
256 | self._manifestdelta.flags(path)) |
|
256 | self._manifestdelta.flags(path)) | |
257 | mfl = self._repo.manifestlog |
|
257 | mfl = self._repo.manifestlog | |
258 | try: |
|
258 | try: | |
259 | node, flag = mfl[self._changeset.manifest].find(path) |
|
259 | node, flag = mfl[self._changeset.manifest].find(path) | |
260 | except KeyError: |
|
260 | except KeyError: | |
261 | raise error.ManifestLookupError(self._node, path, |
|
261 | raise error.ManifestLookupError(self._node, path, | |
262 | _('not found in manifest')) |
|
262 | _('not found in manifest')) | |
263 |
|
263 | |||
264 | return node, flag |
|
264 | return node, flag | |
265 |
|
265 | |||
266 | def filenode(self, path): |
|
266 | def filenode(self, path): | |
267 | return self._fileinfo(path)[0] |
|
267 | return self._fileinfo(path)[0] | |
268 |
|
268 | |||
269 | def flags(self, path): |
|
269 | def flags(self, path): | |
270 | try: |
|
270 | try: | |
271 | return self._fileinfo(path)[1] |
|
271 | return self._fileinfo(path)[1] | |
272 | except error.LookupError: |
|
272 | except error.LookupError: | |
273 | return '' |
|
273 | return '' | |
274 |
|
274 | |||
275 | def sub(self, path, allowcreate=True): |
|
275 | def sub(self, path, allowcreate=True): | |
276 | '''return a subrepo for the stored revision of path, never wdir()''' |
|
276 | '''return a subrepo for the stored revision of path, never wdir()''' | |
277 | return subrepo.subrepo(self, path, allowcreate=allowcreate) |
|
277 | return subrepo.subrepo(self, path, allowcreate=allowcreate) | |
278 |
|
278 | |||
279 | def nullsub(self, path, pctx): |
|
279 | def nullsub(self, path, pctx): | |
280 | return subrepo.nullsubrepo(self, path, pctx) |
|
280 | return subrepo.nullsubrepo(self, path, pctx) | |
281 |
|
281 | |||
282 | def workingsub(self, path): |
|
282 | def workingsub(self, path): | |
283 | '''return a subrepo for the stored revision, or wdir if this is a wdir |
|
283 | '''return a subrepo for the stored revision, or wdir if this is a wdir | |
284 | context. |
|
284 | context. | |
285 | ''' |
|
285 | ''' | |
286 | return subrepo.subrepo(self, path, allowwdir=True) |
|
286 | return subrepo.subrepo(self, path, allowwdir=True) | |
287 |
|
287 | |||
288 | def match(self, pats=None, include=None, exclude=None, default='glob', |
|
288 | def match(self, pats=None, include=None, exclude=None, default='glob', | |
289 | listsubrepos=False, badfn=None): |
|
289 | listsubrepos=False, badfn=None): | |
290 | r = self._repo |
|
290 | r = self._repo | |
291 | return matchmod.match(r.root, r.getcwd(), pats, |
|
291 | return matchmod.match(r.root, r.getcwd(), pats, | |
292 | include, exclude, default, |
|
292 | include, exclude, default, | |
293 | auditor=r.nofsauditor, ctx=self, |
|
293 | auditor=r.nofsauditor, ctx=self, | |
294 | listsubrepos=listsubrepos, badfn=badfn) |
|
294 | listsubrepos=listsubrepos, badfn=badfn) | |
295 |
|
295 | |||
296 | def diff(self, ctx2=None, match=None, changes=None, opts=None, |
|
296 | def diff(self, ctx2=None, match=None, changes=None, opts=None, | |
297 | losedatafn=None, pathfn=None, copy=None, |
|
297 | losedatafn=None, pathfn=None, copy=None, | |
298 | copysourcematch=None, hunksfilterfn=None): |
|
298 | copysourcematch=None, hunksfilterfn=None): | |
299 | """Returns a diff generator for the given contexts and matcher""" |
|
299 | """Returns a diff generator for the given contexts and matcher""" | |
300 | if ctx2 is None: |
|
300 | if ctx2 is None: | |
301 | ctx2 = self.p1() |
|
301 | ctx2 = self.p1() | |
302 | if ctx2 is not None: |
|
302 | if ctx2 is not None: | |
303 | ctx2 = self._repo[ctx2] |
|
303 | ctx2 = self._repo[ctx2] | |
304 | return patch.diff(self._repo, ctx2, self, match=match, changes=changes, |
|
304 | return patch.diff(self._repo, ctx2, self, match=match, changes=changes, | |
305 | opts=opts, losedatafn=losedatafn, pathfn=pathfn, |
|
305 | opts=opts, losedatafn=losedatafn, pathfn=pathfn, | |
306 | copy=copy, copysourcematch=copysourcematch, |
|
306 | copy=copy, copysourcematch=copysourcematch, | |
307 | hunksfilterfn=hunksfilterfn) |
|
307 | hunksfilterfn=hunksfilterfn) | |
308 |
|
308 | |||
309 | def dirs(self): |
|
309 | def dirs(self): | |
310 | return self._manifest.dirs() |
|
310 | return self._manifest.dirs() | |
311 |
|
311 | |||
312 | def hasdir(self, dir): |
|
312 | def hasdir(self, dir): | |
313 | return self._manifest.hasdir(dir) |
|
313 | return self._manifest.hasdir(dir) | |
314 |
|
314 | |||
315 | def status(self, other=None, match=None, listignored=False, |
|
315 | def status(self, other=None, match=None, listignored=False, | |
316 | listclean=False, listunknown=False, listsubrepos=False): |
|
316 | listclean=False, listunknown=False, listsubrepos=False): | |
317 | """return status of files between two nodes or node and working |
|
317 | """return status of files between two nodes or node and working | |
318 | directory. |
|
318 | directory. | |
319 |
|
319 | |||
320 | If other is None, compare this node with working directory. |
|
320 | If other is None, compare this node with working directory. | |
321 |
|
321 | |||
322 | returns (modified, added, removed, deleted, unknown, ignored, clean) |
|
322 | returns (modified, added, removed, deleted, unknown, ignored, clean) | |
323 | """ |
|
323 | """ | |
324 |
|
324 | |||
325 | ctx1 = self |
|
325 | ctx1 = self | |
326 | ctx2 = self._repo[other] |
|
326 | ctx2 = self._repo[other] | |
327 |
|
327 | |||
328 | # This next code block is, admittedly, fragile logic that tests for |
|
328 | # This next code block is, admittedly, fragile logic that tests for | |
329 | # reversing the contexts and wouldn't need to exist if it weren't for |
|
329 | # reversing the contexts and wouldn't need to exist if it weren't for | |
330 | # the fast (and common) code path of comparing the working directory |
|
330 | # the fast (and common) code path of comparing the working directory | |
331 | # with its first parent. |
|
331 | # with its first parent. | |
332 | # |
|
332 | # | |
333 | # What we're aiming for here is the ability to call: |
|
333 | # What we're aiming for here is the ability to call: | |
334 | # |
|
334 | # | |
335 | # workingctx.status(parentctx) |
|
335 | # workingctx.status(parentctx) | |
336 | # |
|
336 | # | |
337 | # If we always built the manifest for each context and compared those, |
|
337 | # If we always built the manifest for each context and compared those, | |
338 | # then we'd be done. But the special case of the above call means we |
|
338 | # then we'd be done. But the special case of the above call means we | |
339 | # just copy the manifest of the parent. |
|
339 | # just copy the manifest of the parent. | |
340 | reversed = False |
|
340 | reversed = False | |
341 | if (not isinstance(ctx1, changectx) |
|
341 | if (not isinstance(ctx1, changectx) | |
342 | and isinstance(ctx2, changectx)): |
|
342 | and isinstance(ctx2, changectx)): | |
343 | reversed = True |
|
343 | reversed = True | |
344 | ctx1, ctx2 = ctx2, ctx1 |
|
344 | ctx1, ctx2 = ctx2, ctx1 | |
345 |
|
345 | |||
346 | match = self._repo.narrowmatch(match) |
|
346 | match = self._repo.narrowmatch(match) | |
347 | match = ctx2._matchstatus(ctx1, match) |
|
347 | match = ctx2._matchstatus(ctx1, match) | |
348 | r = scmutil.status([], [], [], [], [], [], []) |
|
348 | r = scmutil.status([], [], [], [], [], [], []) | |
349 | r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, |
|
349 | r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, | |
350 | listunknown) |
|
350 | listunknown) | |
351 |
|
351 | |||
352 | if reversed: |
|
352 | if reversed: | |
353 | # Reverse added and removed. Clear deleted, unknown and ignored as |
|
353 | # Reverse added and removed. Clear deleted, unknown and ignored as | |
354 | # these make no sense to reverse. |
|
354 | # these make no sense to reverse. | |
355 | r = scmutil.status(r.modified, r.removed, r.added, [], [], [], |
|
355 | r = scmutil.status(r.modified, r.removed, r.added, [], [], [], | |
356 | r.clean) |
|
356 | r.clean) | |
357 |
|
357 | |||
358 | if listsubrepos: |
|
358 | if listsubrepos: | |
359 | for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): |
|
359 | for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): | |
360 | try: |
|
360 | try: | |
361 | rev2 = ctx2.subrev(subpath) |
|
361 | rev2 = ctx2.subrev(subpath) | |
362 | except KeyError: |
|
362 | except KeyError: | |
363 | # A subrepo that existed in node1 was deleted between |
|
363 | # A subrepo that existed in node1 was deleted between | |
364 | # node1 and node2 (inclusive). Thus, ctx2's substate |
|
364 | # node1 and node2 (inclusive). Thus, ctx2's substate | |
365 | # won't contain that subpath. The best we can do ignore it. |
|
365 | # won't contain that subpath. The best we can do ignore it. | |
366 | rev2 = None |
|
366 | rev2 = None | |
367 | submatch = matchmod.subdirmatcher(subpath, match) |
|
367 | submatch = matchmod.subdirmatcher(subpath, match) | |
368 | s = sub.status(rev2, match=submatch, ignored=listignored, |
|
368 | s = sub.status(rev2, match=submatch, ignored=listignored, | |
369 | clean=listclean, unknown=listunknown, |
|
369 | clean=listclean, unknown=listunknown, | |
370 | listsubrepos=True) |
|
370 | listsubrepos=True) | |
371 | for rfiles, sfiles in zip(r, s): |
|
371 | for rfiles, sfiles in zip(r, s): | |
372 | rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) |
|
372 | rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) | |
373 |
|
373 | |||
374 | for l in r: |
|
374 | for l in r: | |
375 | l.sort() |
|
375 | l.sort() | |
376 |
|
376 | |||
377 | return r |
|
377 | return r | |
378 |
|
378 | |||
379 | class changectx(basectx): |
|
379 | class changectx(basectx): | |
380 | """A changecontext object makes access to data related to a particular |
|
380 | """A changecontext object makes access to data related to a particular | |
381 | changeset convenient. It represents a read-only context already present in |
|
381 | changeset convenient. It represents a read-only context already present in | |
382 | the repo.""" |
|
382 | the repo.""" | |
383 | def __init__(self, repo, rev, node): |
|
383 | def __init__(self, repo, rev, node): | |
384 | super(changectx, self).__init__(repo) |
|
384 | super(changectx, self).__init__(repo) | |
385 | self._rev = rev |
|
385 | self._rev = rev | |
386 | self._node = node |
|
386 | self._node = node | |
387 |
|
387 | |||
388 | def __hash__(self): |
|
388 | def __hash__(self): | |
389 | try: |
|
389 | try: | |
390 | return hash(self._rev) |
|
390 | return hash(self._rev) | |
391 | except AttributeError: |
|
391 | except AttributeError: | |
392 | return id(self) |
|
392 | return id(self) | |
393 |
|
393 | |||
394 | def __nonzero__(self): |
|
394 | def __nonzero__(self): | |
395 | return self._rev != nullrev |
|
395 | return self._rev != nullrev | |
396 |
|
396 | |||
397 | __bool__ = __nonzero__ |
|
397 | __bool__ = __nonzero__ | |
398 |
|
398 | |||
399 | @propertycache |
|
399 | @propertycache | |
400 | def _changeset(self): |
|
400 | def _changeset(self): | |
401 | return self._repo.changelog.changelogrevision(self.rev()) |
|
401 | return self._repo.changelog.changelogrevision(self.rev()) | |
402 |
|
402 | |||
403 | @propertycache |
|
403 | @propertycache | |
404 | def _manifest(self): |
|
404 | def _manifest(self): | |
405 | return self._manifestctx.read() |
|
405 | return self._manifestctx.read() | |
406 |
|
406 | |||
407 | @property |
|
407 | @property | |
408 | def _manifestctx(self): |
|
408 | def _manifestctx(self): | |
409 | return self._repo.manifestlog[self._changeset.manifest] |
|
409 | return self._repo.manifestlog[self._changeset.manifest] | |
410 |
|
410 | |||
411 | @propertycache |
|
411 | @propertycache | |
412 | def _manifestdelta(self): |
|
412 | def _manifestdelta(self): | |
413 | return self._manifestctx.readdelta() |
|
413 | return self._manifestctx.readdelta() | |
414 |
|
414 | |||
415 | @propertycache |
|
415 | @propertycache | |
416 | def _parents(self): |
|
416 | def _parents(self): | |
417 | repo = self._repo |
|
417 | repo = self._repo | |
418 | p1, p2 = repo.changelog.parentrevs(self._rev) |
|
418 | p1, p2 = repo.changelog.parentrevs(self._rev) | |
419 | if p2 == nullrev: |
|
419 | if p2 == nullrev: | |
420 | return [repo[p1]] |
|
420 | return [repo[p1]] | |
421 | return [repo[p1], repo[p2]] |
|
421 | return [repo[p1], repo[p2]] | |
422 |
|
422 | |||
423 | def changeset(self): |
|
423 | def changeset(self): | |
424 | c = self._changeset |
|
424 | c = self._changeset | |
425 | return ( |
|
425 | return ( | |
426 | c.manifest, |
|
426 | c.manifest, | |
427 | c.user, |
|
427 | c.user, | |
428 | c.date, |
|
428 | c.date, | |
429 | c.files, |
|
429 | c.files, | |
430 | c.description, |
|
430 | c.description, | |
431 | c.extra, |
|
431 | c.extra, | |
432 | ) |
|
432 | ) | |
433 | def manifestnode(self): |
|
433 | def manifestnode(self): | |
434 | return self._changeset.manifest |
|
434 | return self._changeset.manifest | |
435 |
|
435 | |||
436 | def user(self): |
|
436 | def user(self): | |
437 | return self._changeset.user |
|
437 | return self._changeset.user | |
438 | def date(self): |
|
438 | def date(self): | |
439 | return self._changeset.date |
|
439 | return self._changeset.date | |
440 | def files(self): |
|
440 | def files(self): | |
441 | return self._changeset.files |
|
441 | return self._changeset.files | |
442 | @propertycache |
|
442 | @propertycache | |
443 | def _copies(self): |
|
443 | def _copies(self): | |
444 | source = self._repo.ui.config('experimental', 'copies.read-from') |
|
444 | source = self._repo.ui.config('experimental', 'copies.read-from') | |
445 | p1copies = self._changeset.p1copies |
|
445 | p1copies = self._changeset.p1copies | |
446 | p2copies = self._changeset.p2copies |
|
446 | p2copies = self._changeset.p2copies | |
447 | # If config says to get copy metadata only from changeset, then return |
|
447 | # If config says to get copy metadata only from changeset, then return | |
448 | # that, defaulting to {} if there was no copy metadata. |
|
448 | # that, defaulting to {} if there was no copy metadata. | |
449 | # In compatibility mode, we return copy data from the changeset if |
|
449 | # In compatibility mode, we return copy data from the changeset if | |
450 | # it was recorded there, and otherwise we fall back to getting it from |
|
450 | # it was recorded there, and otherwise we fall back to getting it from | |
451 | # the filelogs (below). |
|
451 | # the filelogs (below). | |
452 | if (source == 'changeset-only' or |
|
452 | if (source == 'changeset-only' or | |
453 | (source == 'compatibility' and p1copies is not None)): |
|
453 | (source == 'compatibility' and p1copies is not None)): | |
454 | return p1copies or {}, p2copies or {} |
|
454 | return p1copies or {}, p2copies or {} | |
455 |
|
455 | |||
456 | # Otherwise (config said to read only from filelog, or we are in |
|
456 | # Otherwise (config said to read only from filelog, or we are in | |
457 | # compatiblity mode and there is not data in the changeset), we get |
|
457 | # compatiblity mode and there is not data in the changeset), we get | |
458 | # the copy metadata from the filelogs. |
|
458 | # the copy metadata from the filelogs. | |
459 | p1copies = {} |
|
459 | p1copies = {} | |
460 | p2copies = {} |
|
460 | p2copies = {} | |
461 | p1 = self.p1() |
|
461 | p1 = self.p1() | |
462 | p2 = self.p2() |
|
462 | p2 = self.p2() | |
463 | narrowmatch = self._repo.narrowmatch() |
|
463 | narrowmatch = self._repo.narrowmatch() | |
464 | for dst in self.files(): |
|
464 | for dst in self.files(): | |
465 | if not narrowmatch(dst) or dst not in self: |
|
465 | if not narrowmatch(dst) or dst not in self: | |
466 | continue |
|
466 | continue | |
467 | copied = self[dst].renamed() |
|
467 | copied = self[dst].renamed() | |
468 | if not copied: |
|
468 | if not copied: | |
469 | continue |
|
469 | continue | |
470 | src, srcnode = copied |
|
470 | src, srcnode = copied | |
471 | if src in p1 and p1[src].filenode() == srcnode: |
|
471 | if src in p1 and p1[src].filenode() == srcnode: | |
472 | p1copies[dst] = src |
|
472 | p1copies[dst] = src | |
473 | elif src in p2 and p2[src].filenode() == srcnode: |
|
473 | elif src in p2 and p2[src].filenode() == srcnode: | |
474 | p2copies[dst] = src |
|
474 | p2copies[dst] = src | |
475 | return p1copies, p2copies |
|
475 | return p1copies, p2copies | |
476 | def p1copies(self): |
|
476 | def p1copies(self): | |
477 | return self._copies[0] |
|
477 | return self._copies[0] | |
478 | def p2copies(self): |
|
478 | def p2copies(self): | |
479 | return self._copies[1] |
|
479 | return self._copies[1] | |
480 | def description(self): |
|
480 | def description(self): | |
481 | return self._changeset.description |
|
481 | return self._changeset.description | |
482 | def branch(self): |
|
482 | def branch(self): | |
483 | return encoding.tolocal(self._changeset.extra.get("branch")) |
|
483 | return encoding.tolocal(self._changeset.extra.get("branch")) | |
484 | def closesbranch(self): |
|
484 | def closesbranch(self): | |
485 | return 'close' in self._changeset.extra |
|
485 | return 'close' in self._changeset.extra | |
486 | def extra(self): |
|
486 | def extra(self): | |
487 | """Return a dict of extra information.""" |
|
487 | """Return a dict of extra information.""" | |
488 | return self._changeset.extra |
|
488 | return self._changeset.extra | |
489 | def tags(self): |
|
489 | def tags(self): | |
490 | """Return a list of byte tag names""" |
|
490 | """Return a list of byte tag names""" | |
491 | return self._repo.nodetags(self._node) |
|
491 | return self._repo.nodetags(self._node) | |
492 | def bookmarks(self): |
|
492 | def bookmarks(self): | |
493 | """Return a list of byte bookmark names.""" |
|
493 | """Return a list of byte bookmark names.""" | |
494 | return self._repo.nodebookmarks(self._node) |
|
494 | return self._repo.nodebookmarks(self._node) | |
495 | def phase(self): |
|
495 | def phase(self): | |
496 | return self._repo._phasecache.phase(self._repo, self._rev) |
|
496 | return self._repo._phasecache.phase(self._repo, self._rev) | |
497 | def hidden(self): |
|
497 | def hidden(self): | |
498 | return self._rev in repoview.filterrevs(self._repo, 'visible') |
|
498 | return self._rev in repoview.filterrevs(self._repo, 'visible') | |
499 |
|
499 | |||
500 | def isinmemory(self): |
|
500 | def isinmemory(self): | |
501 | return False |
|
501 | return False | |
502 |
|
502 | |||
503 | def children(self): |
|
503 | def children(self): | |
504 | """return list of changectx contexts for each child changeset. |
|
504 | """return list of changectx contexts for each child changeset. | |
505 |
|
505 | |||
506 | This returns only the immediate child changesets. Use descendants() to |
|
506 | This returns only the immediate child changesets. Use descendants() to | |
507 | recursively walk children. |
|
507 | recursively walk children. | |
508 | """ |
|
508 | """ | |
509 | c = self._repo.changelog.children(self._node) |
|
509 | c = self._repo.changelog.children(self._node) | |
510 | return [self._repo[x] for x in c] |
|
510 | return [self._repo[x] for x in c] | |
511 |
|
511 | |||
512 | def ancestors(self): |
|
512 | def ancestors(self): | |
513 | for a in self._repo.changelog.ancestors([self._rev]): |
|
513 | for a in self._repo.changelog.ancestors([self._rev]): | |
514 | yield self._repo[a] |
|
514 | yield self._repo[a] | |
515 |
|
515 | |||
516 | def descendants(self): |
|
516 | def descendants(self): | |
517 | """Recursively yield all children of the changeset. |
|
517 | """Recursively yield all children of the changeset. | |
518 |
|
518 | |||
519 | For just the immediate children, use children() |
|
519 | For just the immediate children, use children() | |
520 | """ |
|
520 | """ | |
521 | for d in self._repo.changelog.descendants([self._rev]): |
|
521 | for d in self._repo.changelog.descendants([self._rev]): | |
522 | yield self._repo[d] |
|
522 | yield self._repo[d] | |
523 |
|
523 | |||
524 | def filectx(self, path, fileid=None, filelog=None): |
|
524 | def filectx(self, path, fileid=None, filelog=None): | |
525 | """get a file context from this changeset""" |
|
525 | """get a file context from this changeset""" | |
526 | if fileid is None: |
|
526 | if fileid is None: | |
527 | fileid = self.filenode(path) |
|
527 | fileid = self.filenode(path) | |
528 | return filectx(self._repo, path, fileid=fileid, |
|
528 | return filectx(self._repo, path, fileid=fileid, | |
529 | changectx=self, filelog=filelog) |
|
529 | changectx=self, filelog=filelog) | |
530 |
|
530 | |||
531 | def ancestor(self, c2, warn=False): |
|
531 | def ancestor(self, c2, warn=False): | |
532 | """return the "best" ancestor context of self and c2 |
|
532 | """return the "best" ancestor context of self and c2 | |
533 |
|
533 | |||
534 | If there are multiple candidates, it will show a message and check |
|
534 | If there are multiple candidates, it will show a message and check | |
535 | merge.preferancestor configuration before falling back to the |
|
535 | merge.preferancestor configuration before falling back to the | |
536 | revlog ancestor.""" |
|
536 | revlog ancestor.""" | |
537 | # deal with workingctxs |
|
537 | # deal with workingctxs | |
538 | n2 = c2._node |
|
538 | n2 = c2._node | |
539 | if n2 is None: |
|
539 | if n2 is None: | |
540 | n2 = c2._parents[0]._node |
|
540 | n2 = c2._parents[0]._node | |
541 | cahs = self._repo.changelog.commonancestorsheads(self._node, n2) |
|
541 | cahs = self._repo.changelog.commonancestorsheads(self._node, n2) | |
542 | if not cahs: |
|
542 | if not cahs: | |
543 | anc = nullid |
|
543 | anc = nullid | |
544 | elif len(cahs) == 1: |
|
544 | elif len(cahs) == 1: | |
545 | anc = cahs[0] |
|
545 | anc = cahs[0] | |
546 | else: |
|
546 | else: | |
547 | # experimental config: merge.preferancestor |
|
547 | # experimental config: merge.preferancestor | |
548 | for r in self._repo.ui.configlist('merge', 'preferancestor'): |
|
548 | for r in self._repo.ui.configlist('merge', 'preferancestor'): | |
549 | try: |
|
549 | try: | |
550 | ctx = scmutil.revsymbol(self._repo, r) |
|
550 | ctx = scmutil.revsymbol(self._repo, r) | |
551 | except error.RepoLookupError: |
|
551 | except error.RepoLookupError: | |
552 | continue |
|
552 | continue | |
553 | anc = ctx.node() |
|
553 | anc = ctx.node() | |
554 | if anc in cahs: |
|
554 | if anc in cahs: | |
555 | break |
|
555 | break | |
556 | else: |
|
556 | else: | |
557 | anc = self._repo.changelog.ancestor(self._node, n2) |
|
557 | anc = self._repo.changelog.ancestor(self._node, n2) | |
558 | if warn: |
|
558 | if warn: | |
559 | self._repo.ui.status( |
|
559 | self._repo.ui.status( | |
560 | (_("note: using %s as ancestor of %s and %s\n") % |
|
560 | (_("note: using %s as ancestor of %s and %s\n") % | |
561 | (short(anc), short(self._node), short(n2))) + |
|
561 | (short(anc), short(self._node), short(n2))) + | |
562 | ''.join(_(" alternatively, use --config " |
|
562 | ''.join(_(" alternatively, use --config " | |
563 | "merge.preferancestor=%s\n") % |
|
563 | "merge.preferancestor=%s\n") % | |
564 | short(n) for n in sorted(cahs) if n != anc)) |
|
564 | short(n) for n in sorted(cahs) if n != anc)) | |
565 | return self._repo[anc] |
|
565 | return self._repo[anc] | |
566 |
|
566 | |||
567 | def isancestorof(self, other): |
|
567 | def isancestorof(self, other): | |
568 | """True if this changeset is an ancestor of other""" |
|
568 | """True if this changeset is an ancestor of other""" | |
569 | return self._repo.changelog.isancestorrev(self._rev, other._rev) |
|
569 | return self._repo.changelog.isancestorrev(self._rev, other._rev) | |
570 |
|
570 | |||
571 | def walk(self, match): |
|
571 | def walk(self, match): | |
572 | '''Generates matching file names.''' |
|
572 | '''Generates matching file names.''' | |
573 |
|
573 | |||
574 | # Wrap match.bad method to have message with nodeid |
|
574 | # Wrap match.bad method to have message with nodeid | |
575 | def bad(fn, msg): |
|
575 | def bad(fn, msg): | |
576 | # The manifest doesn't know about subrepos, so don't complain about |
|
576 | # The manifest doesn't know about subrepos, so don't complain about | |
577 | # paths into valid subrepos. |
|
577 | # paths into valid subrepos. | |
578 | if any(fn == s or fn.startswith(s + '/') |
|
578 | if any(fn == s or fn.startswith(s + '/') | |
579 | for s in self.substate): |
|
579 | for s in self.substate): | |
580 | return |
|
580 | return | |
581 | match.bad(fn, _('no such file in rev %s') % self) |
|
581 | match.bad(fn, _('no such file in rev %s') % self) | |
582 |
|
582 | |||
583 | m = matchmod.badmatch(self._repo.narrowmatch(match), bad) |
|
583 | m = matchmod.badmatch(self._repo.narrowmatch(match), bad) | |
584 | return self._manifest.walk(m) |
|
584 | return self._manifest.walk(m) | |
585 |
|
585 | |||
586 | def matches(self, match): |
|
586 | def matches(self, match): | |
587 | return self.walk(match) |
|
587 | return self.walk(match) | |
588 |
|
588 | |||
589 | class basefilectx(object): |
|
589 | class basefilectx(object): | |
590 | """A filecontext object represents the common logic for its children: |
|
590 | """A filecontext object represents the common logic for its children: | |
591 | filectx: read-only access to a filerevision that is already present |
|
591 | filectx: read-only access to a filerevision that is already present | |
592 | in the repo, |
|
592 | in the repo, | |
593 | workingfilectx: a filecontext that represents files from the working |
|
593 | workingfilectx: a filecontext that represents files from the working | |
594 | directory, |
|
594 | directory, | |
595 | memfilectx: a filecontext that represents files in-memory, |
|
595 | memfilectx: a filecontext that represents files in-memory, | |
596 | """ |
|
596 | """ | |
597 | @propertycache |
|
597 | @propertycache | |
598 | def _filelog(self): |
|
598 | def _filelog(self): | |
599 | return self._repo.file(self._path) |
|
599 | return self._repo.file(self._path) | |
600 |
|
600 | |||
601 | @propertycache |
|
601 | @propertycache | |
602 | def _changeid(self): |
|
602 | def _changeid(self): | |
603 | if r'_changectx' in self.__dict__: |
|
603 | if r'_changectx' in self.__dict__: | |
604 | return self._changectx.rev() |
|
604 | return self._changectx.rev() | |
605 | elif r'_descendantrev' in self.__dict__: |
|
605 | elif r'_descendantrev' in self.__dict__: | |
606 | # this file context was created from a revision with a known |
|
606 | # this file context was created from a revision with a known | |
607 | # descendant, we can (lazily) correct for linkrev aliases |
|
607 | # descendant, we can (lazily) correct for linkrev aliases | |
608 | return self._adjustlinkrev(self._descendantrev) |
|
608 | return self._adjustlinkrev(self._descendantrev) | |
609 | else: |
|
609 | else: | |
610 | return self._filelog.linkrev(self._filerev) |
|
610 | return self._filelog.linkrev(self._filerev) | |
611 |
|
611 | |||
612 | @propertycache |
|
612 | @propertycache | |
613 | def _filenode(self): |
|
613 | def _filenode(self): | |
614 | if r'_fileid' in self.__dict__: |
|
614 | if r'_fileid' in self.__dict__: | |
615 | return self._filelog.lookup(self._fileid) |
|
615 | return self._filelog.lookup(self._fileid) | |
616 | else: |
|
616 | else: | |
617 | return self._changectx.filenode(self._path) |
|
617 | return self._changectx.filenode(self._path) | |
618 |
|
618 | |||
619 | @propertycache |
|
619 | @propertycache | |
620 | def _filerev(self): |
|
620 | def _filerev(self): | |
621 | return self._filelog.rev(self._filenode) |
|
621 | return self._filelog.rev(self._filenode) | |
622 |
|
622 | |||
623 | @propertycache |
|
623 | @propertycache | |
624 | def _repopath(self): |
|
624 | def _repopath(self): | |
625 | return self._path |
|
625 | return self._path | |
626 |
|
626 | |||
627 | def __nonzero__(self): |
|
627 | def __nonzero__(self): | |
628 | try: |
|
628 | try: | |
629 | self._filenode |
|
629 | self._filenode | |
630 | return True |
|
630 | return True | |
631 | except error.LookupError: |
|
631 | except error.LookupError: | |
632 | # file is missing |
|
632 | # file is missing | |
633 | return False |
|
633 | return False | |
634 |
|
634 | |||
635 | __bool__ = __nonzero__ |
|
635 | __bool__ = __nonzero__ | |
636 |
|
636 | |||
637 | def __bytes__(self): |
|
637 | def __bytes__(self): | |
638 | try: |
|
638 | try: | |
639 | return "%s@%s" % (self.path(), self._changectx) |
|
639 | return "%s@%s" % (self.path(), self._changectx) | |
640 | except error.LookupError: |
|
640 | except error.LookupError: | |
641 | return "%s@???" % self.path() |
|
641 | return "%s@???" % self.path() | |
642 |
|
642 | |||
643 | __str__ = encoding.strmethod(__bytes__) |
|
643 | __str__ = encoding.strmethod(__bytes__) | |
644 |
|
644 | |||
645 | def __repr__(self): |
|
645 | def __repr__(self): | |
646 | return r"<%s %s>" % (type(self).__name__, str(self)) |
|
646 | return r"<%s %s>" % (type(self).__name__, str(self)) | |
647 |
|
647 | |||
648 | def __hash__(self): |
|
648 | def __hash__(self): | |
649 | try: |
|
649 | try: | |
650 | return hash((self._path, self._filenode)) |
|
650 | return hash((self._path, self._filenode)) | |
651 | except AttributeError: |
|
651 | except AttributeError: | |
652 | return id(self) |
|
652 | return id(self) | |
653 |
|
653 | |||
654 | def __eq__(self, other): |
|
654 | def __eq__(self, other): | |
655 | try: |
|
655 | try: | |
656 | return (type(self) == type(other) and self._path == other._path |
|
656 | return (type(self) == type(other) and self._path == other._path | |
657 | and self._filenode == other._filenode) |
|
657 | and self._filenode == other._filenode) | |
658 | except AttributeError: |
|
658 | except AttributeError: | |
659 | return False |
|
659 | return False | |
660 |
|
660 | |||
661 | def __ne__(self, other): |
|
661 | def __ne__(self, other): | |
662 | return not (self == other) |
|
662 | return not (self == other) | |
663 |
|
663 | |||
664 | def filerev(self): |
|
664 | def filerev(self): | |
665 | return self._filerev |
|
665 | return self._filerev | |
666 | def filenode(self): |
|
666 | def filenode(self): | |
667 | return self._filenode |
|
667 | return self._filenode | |
668 | @propertycache |
|
668 | @propertycache | |
669 | def _flags(self): |
|
669 | def _flags(self): | |
670 | return self._changectx.flags(self._path) |
|
670 | return self._changectx.flags(self._path) | |
671 | def flags(self): |
|
671 | def flags(self): | |
672 | return self._flags |
|
672 | return self._flags | |
673 | def filelog(self): |
|
673 | def filelog(self): | |
674 | return self._filelog |
|
674 | return self._filelog | |
675 | def rev(self): |
|
675 | def rev(self): | |
676 | return self._changeid |
|
676 | return self._changeid | |
677 | def linkrev(self): |
|
677 | def linkrev(self): | |
678 | return self._filelog.linkrev(self._filerev) |
|
678 | return self._filelog.linkrev(self._filerev) | |
679 | def node(self): |
|
679 | def node(self): | |
680 | return self._changectx.node() |
|
680 | return self._changectx.node() | |
681 | def hex(self): |
|
681 | def hex(self): | |
682 | return self._changectx.hex() |
|
682 | return self._changectx.hex() | |
683 | def user(self): |
|
683 | def user(self): | |
684 | return self._changectx.user() |
|
684 | return self._changectx.user() | |
685 | def date(self): |
|
685 | def date(self): | |
686 | return self._changectx.date() |
|
686 | return self._changectx.date() | |
687 | def files(self): |
|
687 | def files(self): | |
688 | return self._changectx.files() |
|
688 | return self._changectx.files() | |
689 | def description(self): |
|
689 | def description(self): | |
690 | return self._changectx.description() |
|
690 | return self._changectx.description() | |
691 | def branch(self): |
|
691 | def branch(self): | |
692 | return self._changectx.branch() |
|
692 | return self._changectx.branch() | |
693 | def extra(self): |
|
693 | def extra(self): | |
694 | return self._changectx.extra() |
|
694 | return self._changectx.extra() | |
695 | def phase(self): |
|
695 | def phase(self): | |
696 | return self._changectx.phase() |
|
696 | return self._changectx.phase() | |
697 | def phasestr(self): |
|
697 | def phasestr(self): | |
698 | return self._changectx.phasestr() |
|
698 | return self._changectx.phasestr() | |
699 | def obsolete(self): |
|
699 | def obsolete(self): | |
700 | return self._changectx.obsolete() |
|
700 | return self._changectx.obsolete() | |
701 | def instabilities(self): |
|
701 | def instabilities(self): | |
702 | return self._changectx.instabilities() |
|
702 | return self._changectx.instabilities() | |
703 | def manifest(self): |
|
703 | def manifest(self): | |
704 | return self._changectx.manifest() |
|
704 | return self._changectx.manifest() | |
705 | def changectx(self): |
|
705 | def changectx(self): | |
706 | return self._changectx |
|
706 | return self._changectx | |
707 | def renamed(self): |
|
707 | def renamed(self): | |
708 | return self._copied |
|
708 | return self._copied | |
709 | def copysource(self): |
|
709 | def copysource(self): | |
710 | return self._copied and self._copied[0] |
|
710 | return self._copied and self._copied[0] | |
711 | def repo(self): |
|
711 | def repo(self): | |
712 | return self._repo |
|
712 | return self._repo | |
713 | def size(self): |
|
713 | def size(self): | |
714 | return len(self.data()) |
|
714 | return len(self.data()) | |
715 |
|
715 | |||
716 | def path(self): |
|
716 | def path(self): | |
717 | return self._path |
|
717 | return self._path | |
718 |
|
718 | |||
719 | def isbinary(self): |
|
719 | def isbinary(self): | |
720 | try: |
|
720 | try: | |
721 | return stringutil.binary(self.data()) |
|
721 | return stringutil.binary(self.data()) | |
722 | except IOError: |
|
722 | except IOError: | |
723 | return False |
|
723 | return False | |
724 | def isexec(self): |
|
724 | def isexec(self): | |
725 | return 'x' in self.flags() |
|
725 | return 'x' in self.flags() | |
726 | def islink(self): |
|
726 | def islink(self): | |
727 | return 'l' in self.flags() |
|
727 | return 'l' in self.flags() | |
728 |
|
728 | |||
729 | def isabsent(self): |
|
729 | def isabsent(self): | |
730 | """whether this filectx represents a file not in self._changectx |
|
730 | """whether this filectx represents a file not in self._changectx | |
731 |
|
731 | |||
732 | This is mainly for merge code to detect change/delete conflicts. This is |
|
732 | This is mainly for merge code to detect change/delete conflicts. This is | |
733 | expected to be True for all subclasses of basectx.""" |
|
733 | expected to be True for all subclasses of basectx.""" | |
734 | return False |
|
734 | return False | |
735 |
|
735 | |||
736 | _customcmp = False |
|
736 | _customcmp = False | |
737 | def cmp(self, fctx): |
|
737 | def cmp(self, fctx): | |
738 | """compare with other file context |
|
738 | """compare with other file context | |
739 |
|
739 | |||
740 | returns True if different than fctx. |
|
740 | returns True if different than fctx. | |
741 | """ |
|
741 | """ | |
742 | if fctx._customcmp: |
|
742 | if fctx._customcmp: | |
743 | return fctx.cmp(self) |
|
743 | return fctx.cmp(self) | |
744 |
|
744 | |||
745 | if self._filenode is None: |
|
745 | if self._filenode is None: | |
746 | raise error.ProgrammingError( |
|
746 | raise error.ProgrammingError( | |
747 | 'filectx.cmp() must be reimplemented if not backed by revlog') |
|
747 | 'filectx.cmp() must be reimplemented if not backed by revlog') | |
748 |
|
748 | |||
749 | if fctx._filenode is None: |
|
749 | if fctx._filenode is None: | |
750 | if self._repo._encodefilterpats: |
|
750 | if self._repo._encodefilterpats: | |
751 | # can't rely on size() because wdir content may be decoded |
|
751 | # can't rely on size() because wdir content may be decoded | |
752 | return self._filelog.cmp(self._filenode, fctx.data()) |
|
752 | return self._filelog.cmp(self._filenode, fctx.data()) | |
753 | if self.size() - 4 == fctx.size(): |
|
753 | if self.size() - 4 == fctx.size(): | |
754 | # size() can match: |
|
754 | # size() can match: | |
755 | # if file data starts with '\1\n', empty metadata block is |
|
755 | # if file data starts with '\1\n', empty metadata block is | |
756 | # prepended, which adds 4 bytes to filelog.size(). |
|
756 | # prepended, which adds 4 bytes to filelog.size(). | |
757 | return self._filelog.cmp(self._filenode, fctx.data()) |
|
757 | return self._filelog.cmp(self._filenode, fctx.data()) | |
758 | if self.size() == fctx.size(): |
|
758 | if self.size() == fctx.size(): | |
759 | # size() matches: need to compare content |
|
759 | # size() matches: need to compare content | |
760 | return self._filelog.cmp(self._filenode, fctx.data()) |
|
760 | return self._filelog.cmp(self._filenode, fctx.data()) | |
761 |
|
761 | |||
762 | # size() differs |
|
762 | # size() differs | |
763 | return True |
|
763 | return True | |
764 |
|
764 | |||
765 | def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None): |
|
765 | def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None): | |
766 | """return the first ancestor of <srcrev> introducing <fnode> |
|
766 | """return the first ancestor of <srcrev> introducing <fnode> | |
767 |
|
767 | |||
768 | If the linkrev of the file revision does not point to an ancestor of |
|
768 | If the linkrev of the file revision does not point to an ancestor of | |
769 | srcrev, we'll walk down the ancestors until we find one introducing |
|
769 | srcrev, we'll walk down the ancestors until we find one introducing | |
770 | this file revision. |
|
770 | this file revision. | |
771 |
|
771 | |||
772 | :srcrev: the changeset revision we search ancestors from |
|
772 | :srcrev: the changeset revision we search ancestors from | |
773 | :inclusive: if true, the src revision will also be checked |
|
773 | :inclusive: if true, the src revision will also be checked | |
774 | :stoprev: an optional revision to stop the walk at. If no introduction |
|
774 | :stoprev: an optional revision to stop the walk at. If no introduction | |
775 | of this file content could be found before this floor |
|
775 | of this file content could be found before this floor | |
776 | revision, the function will returns "None" and stops its |
|
776 | revision, the function will returns "None" and stops its | |
777 | iteration. |
|
777 | iteration. | |
778 | """ |
|
778 | """ | |
779 | repo = self._repo |
|
779 | repo = self._repo | |
780 | cl = repo.unfiltered().changelog |
|
780 | cl = repo.unfiltered().changelog | |
781 | mfl = repo.manifestlog |
|
781 | mfl = repo.manifestlog | |
782 | # fetch the linkrev |
|
782 | # fetch the linkrev | |
783 | lkr = self.linkrev() |
|
783 | lkr = self.linkrev() | |
784 | if srcrev == lkr: |
|
784 | if srcrev == lkr: | |
785 | return lkr |
|
785 | return lkr | |
786 | # hack to reuse ancestor computation when searching for renames |
|
786 | # hack to reuse ancestor computation when searching for renames | |
787 | memberanc = getattr(self, '_ancestrycontext', None) |
|
787 | memberanc = getattr(self, '_ancestrycontext', None) | |
788 | iteranc = None |
|
788 | iteranc = None | |
789 | if srcrev is None: |
|
789 | if srcrev is None: | |
790 | # wctx case, used by workingfilectx during mergecopy |
|
790 | # wctx case, used by workingfilectx during mergecopy | |
791 | revs = [p.rev() for p in self._repo[None].parents()] |
|
791 | revs = [p.rev() for p in self._repo[None].parents()] | |
792 | inclusive = True # we skipped the real (revless) source |
|
792 | inclusive = True # we skipped the real (revless) source | |
793 | else: |
|
793 | else: | |
794 | revs = [srcrev] |
|
794 | revs = [srcrev] | |
795 | if memberanc is None: |
|
795 | if memberanc is None: | |
796 | memberanc = iteranc = cl.ancestors(revs, lkr, |
|
796 | memberanc = iteranc = cl.ancestors(revs, lkr, | |
797 | inclusive=inclusive) |
|
797 | inclusive=inclusive) | |
798 | # check if this linkrev is an ancestor of srcrev |
|
798 | # check if this linkrev is an ancestor of srcrev | |
799 | if lkr not in memberanc: |
|
799 | if lkr not in memberanc: | |
800 | if iteranc is None: |
|
800 | if iteranc is None: | |
801 | iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) |
|
801 | iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) | |
802 | fnode = self._filenode |
|
802 | fnode = self._filenode | |
803 | path = self._path |
|
803 | path = self._path | |
804 | for a in iteranc: |
|
804 | for a in iteranc: | |
805 | if stoprev is not None and a < stoprev: |
|
805 | if stoprev is not None and a < stoprev: | |
806 | return None |
|
806 | return None | |
807 | ac = cl.read(a) # get changeset data (we avoid object creation) |
|
807 | ac = cl.read(a) # get changeset data (we avoid object creation) | |
808 | if path in ac[3]: # checking the 'files' field. |
|
808 | if path in ac[3]: # checking the 'files' field. | |
809 | # The file has been touched, check if the content is |
|
809 | # The file has been touched, check if the content is | |
810 | # similar to the one we search for. |
|
810 | # similar to the one we search for. | |
811 | if fnode == mfl[ac[0]].readfast().get(path): |
|
811 | if fnode == mfl[ac[0]].readfast().get(path): | |
812 | return a |
|
812 | return a | |
813 | # In theory, we should never get out of that loop without a result. |
|
813 | # In theory, we should never get out of that loop without a result. | |
814 | # But if manifest uses a buggy file revision (not children of the |
|
814 | # But if manifest uses a buggy file revision (not children of the | |
815 | # one it replaces) we could. Such a buggy situation will likely |
|
815 | # one it replaces) we could. Such a buggy situation will likely | |
816 | # result is crash somewhere else at to some point. |
|
816 | # result is crash somewhere else at to some point. | |
817 | return lkr |
|
817 | return lkr | |
818 |
|
818 | |||
819 | def isintroducedafter(self, changelogrev): |
|
819 | def isintroducedafter(self, changelogrev): | |
820 | """True if a filectx has been introduced after a given floor revision |
|
820 | """True if a filectx has been introduced after a given floor revision | |
821 | """ |
|
821 | """ | |
822 | if self.linkrev() >= changelogrev: |
|
822 | if self.linkrev() >= changelogrev: | |
823 | return True |
|
823 | return True | |
824 | introrev = self._introrev(stoprev=changelogrev) |
|
824 | introrev = self._introrev(stoprev=changelogrev) | |
825 | if introrev is None: |
|
825 | if introrev is None: | |
826 | return False |
|
826 | return False | |
827 | return introrev >= changelogrev |
|
827 | return introrev >= changelogrev | |
828 |
|
828 | |||
829 | def introrev(self): |
|
829 | def introrev(self): | |
830 | """return the rev of the changeset which introduced this file revision |
|
830 | """return the rev of the changeset which introduced this file revision | |
831 |
|
831 | |||
832 | This method is different from linkrev because it take into account the |
|
832 | This method is different from linkrev because it take into account the | |
833 | changeset the filectx was created from. It ensures the returned |
|
833 | changeset the filectx was created from. It ensures the returned | |
834 | revision is one of its ancestors. This prevents bugs from |
|
834 | revision is one of its ancestors. This prevents bugs from | |
835 | 'linkrev-shadowing' when a file revision is used by multiple |
|
835 | 'linkrev-shadowing' when a file revision is used by multiple | |
836 | changesets. |
|
836 | changesets. | |
837 | """ |
|
837 | """ | |
838 | return self._introrev() |
|
838 | return self._introrev() | |
839 |
|
839 | |||
840 | def _introrev(self, stoprev=None): |
|
840 | def _introrev(self, stoprev=None): | |
841 | """ |
|
841 | """ | |
842 | Same as `introrev` but, with an extra argument to limit changelog |
|
842 | Same as `introrev` but, with an extra argument to limit changelog | |
843 | iteration range in some internal usecase. |
|
843 | iteration range in some internal usecase. | |
844 |
|
844 | |||
845 | If `stoprev` is set, the `introrev` will not be searched past that |
|
845 | If `stoprev` is set, the `introrev` will not be searched past that | |
846 | `stoprev` revision and "None" might be returned. This is useful to |
|
846 | `stoprev` revision and "None" might be returned. This is useful to | |
847 | limit the iteration range. |
|
847 | limit the iteration range. | |
848 | """ |
|
848 | """ | |
849 | toprev = None |
|
849 | toprev = None | |
850 | attrs = vars(self) |
|
850 | attrs = vars(self) | |
851 | if r'_changeid' in attrs: |
|
851 | if r'_changeid' in attrs: | |
852 | # We have a cached value already |
|
852 | # We have a cached value already | |
853 | toprev = self._changeid |
|
853 | toprev = self._changeid | |
854 | elif r'_changectx' in attrs: |
|
854 | elif r'_changectx' in attrs: | |
855 | # We know which changelog entry we are coming from |
|
855 | # We know which changelog entry we are coming from | |
856 | toprev = self._changectx.rev() |
|
856 | toprev = self._changectx.rev() | |
857 |
|
857 | |||
858 | if toprev is not None: |
|
858 | if toprev is not None: | |
859 | return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev) |
|
859 | return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev) | |
860 | elif r'_descendantrev' in attrs: |
|
860 | elif r'_descendantrev' in attrs: | |
861 | introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev) |
|
861 | introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev) | |
862 | # be nice and cache the result of the computation |
|
862 | # be nice and cache the result of the computation | |
863 | if introrev is not None: |
|
863 | if introrev is not None: | |
864 | self._changeid = introrev |
|
864 | self._changeid = introrev | |
865 | return introrev |
|
865 | return introrev | |
866 | else: |
|
866 | else: | |
867 | return self.linkrev() |
|
867 | return self.linkrev() | |
868 |
|
868 | |||
869 | def introfilectx(self): |
|
869 | def introfilectx(self): | |
870 | """Return filectx having identical contents, but pointing to the |
|
870 | """Return filectx having identical contents, but pointing to the | |
871 | changeset revision where this filectx was introduced""" |
|
871 | changeset revision where this filectx was introduced""" | |
872 | introrev = self.introrev() |
|
872 | introrev = self.introrev() | |
873 | if self.rev() == introrev: |
|
873 | if self.rev() == introrev: | |
874 | return self |
|
874 | return self | |
875 | return self.filectx(self.filenode(), changeid=introrev) |
|
875 | return self.filectx(self.filenode(), changeid=introrev) | |
876 |
|
876 | |||
877 | def _parentfilectx(self, path, fileid, filelog): |
|
877 | def _parentfilectx(self, path, fileid, filelog): | |
878 | """create parent filectx keeping ancestry info for _adjustlinkrev()""" |
|
878 | """create parent filectx keeping ancestry info for _adjustlinkrev()""" | |
879 | fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
|
879 | fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) | |
880 | if r'_changeid' in vars(self) or r'_changectx' in vars(self): |
|
880 | if r'_changeid' in vars(self) or r'_changectx' in vars(self): | |
881 | # If self is associated with a changeset (probably explicitly |
|
881 | # If self is associated with a changeset (probably explicitly | |
882 | # fed), ensure the created filectx is associated with a |
|
882 | # fed), ensure the created filectx is associated with a | |
883 | # changeset that is an ancestor of self.changectx. |
|
883 | # changeset that is an ancestor of self.changectx. | |
884 | # This lets us later use _adjustlinkrev to get a correct link. |
|
884 | # This lets us later use _adjustlinkrev to get a correct link. | |
885 | fctx._descendantrev = self.rev() |
|
885 | fctx._descendantrev = self.rev() | |
886 | fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
|
886 | fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) | |
887 | elif r'_descendantrev' in vars(self): |
|
887 | elif r'_descendantrev' in vars(self): | |
888 | # Otherwise propagate _descendantrev if we have one associated. |
|
888 | # Otherwise propagate _descendantrev if we have one associated. | |
889 | fctx._descendantrev = self._descendantrev |
|
889 | fctx._descendantrev = self._descendantrev | |
890 | fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
|
890 | fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) | |
891 | return fctx |
|
891 | return fctx | |
892 |
|
892 | |||
893 | def parents(self): |
|
893 | def parents(self): | |
894 | _path = self._path |
|
894 | _path = self._path | |
895 | fl = self._filelog |
|
895 | fl = self._filelog | |
896 | parents = self._filelog.parents(self._filenode) |
|
896 | parents = self._filelog.parents(self._filenode) | |
897 | pl = [(_path, node, fl) for node in parents if node != nullid] |
|
897 | pl = [(_path, node, fl) for node in parents if node != nullid] | |
898 |
|
898 | |||
899 | r = fl.renamed(self._filenode) |
|
899 | r = fl.renamed(self._filenode) | |
900 | if r: |
|
900 | if r: | |
901 | # - In the simple rename case, both parent are nullid, pl is empty. |
|
901 | # - In the simple rename case, both parent are nullid, pl is empty. | |
902 | # - In case of merge, only one of the parent is null id and should |
|
902 | # - In case of merge, only one of the parent is null id and should | |
903 | # be replaced with the rename information. This parent is -always- |
|
903 | # be replaced with the rename information. This parent is -always- | |
904 | # the first one. |
|
904 | # the first one. | |
905 | # |
|
905 | # | |
906 | # As null id have always been filtered out in the previous list |
|
906 | # As null id have always been filtered out in the previous list | |
907 | # comprehension, inserting to 0 will always result in "replacing |
|
907 | # comprehension, inserting to 0 will always result in "replacing | |
908 | # first nullid parent with rename information. |
|
908 | # first nullid parent with rename information. | |
909 | pl.insert(0, (r[0], r[1], self._repo.file(r[0]))) |
|
909 | pl.insert(0, (r[0], r[1], self._repo.file(r[0]))) | |
910 |
|
910 | |||
911 | return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl] |
|
911 | return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl] | |
912 |
|
912 | |||
913 | def p1(self): |
|
913 | def p1(self): | |
914 | return self.parents()[0] |
|
914 | return self.parents()[0] | |
915 |
|
915 | |||
916 | def p2(self): |
|
916 | def p2(self): | |
917 | p = self.parents() |
|
917 | p = self.parents() | |
918 | if len(p) == 2: |
|
918 | if len(p) == 2: | |
919 | return p[1] |
|
919 | return p[1] | |
920 | return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) |
|
920 | return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) | |
921 |
|
921 | |||
922 | def annotate(self, follow=False, skiprevs=None, diffopts=None): |
|
922 | def annotate(self, follow=False, skiprevs=None, diffopts=None): | |
923 | """Returns a list of annotateline objects for each line in the file |
|
923 | """Returns a list of annotateline objects for each line in the file | |
924 |
|
924 | |||
925 | - line.fctx is the filectx of the node where that line was last changed |
|
925 | - line.fctx is the filectx of the node where that line was last changed | |
926 | - line.lineno is the line number at the first appearance in the managed |
|
926 | - line.lineno is the line number at the first appearance in the managed | |
927 | file |
|
927 | file | |
928 | - line.text is the data on that line (including newline character) |
|
928 | - line.text is the data on that line (including newline character) | |
929 | """ |
|
929 | """ | |
930 | getlog = util.lrucachefunc(lambda x: self._repo.file(x)) |
|
930 | getlog = util.lrucachefunc(lambda x: self._repo.file(x)) | |
931 |
|
931 | |||
932 | def parents(f): |
|
932 | def parents(f): | |
933 | # Cut _descendantrev here to mitigate the penalty of lazy linkrev |
|
933 | # Cut _descendantrev here to mitigate the penalty of lazy linkrev | |
934 | # adjustment. Otherwise, p._adjustlinkrev() would walk changelog |
|
934 | # adjustment. Otherwise, p._adjustlinkrev() would walk changelog | |
935 | # from the topmost introrev (= srcrev) down to p.linkrev() if it |
|
935 | # from the topmost introrev (= srcrev) down to p.linkrev() if it | |
936 | # isn't an ancestor of the srcrev. |
|
936 | # isn't an ancestor of the srcrev. | |
937 | f._changeid |
|
937 | f._changeid | |
938 | pl = f.parents() |
|
938 | pl = f.parents() | |
939 |
|
939 | |||
940 | # Don't return renamed parents if we aren't following. |
|
940 | # Don't return renamed parents if we aren't following. | |
941 | if not follow: |
|
941 | if not follow: | |
942 | pl = [p for p in pl if p.path() == f.path()] |
|
942 | pl = [p for p in pl if p.path() == f.path()] | |
943 |
|
943 | |||
944 | # renamed filectx won't have a filelog yet, so set it |
|
944 | # renamed filectx won't have a filelog yet, so set it | |
945 | # from the cache to save time |
|
945 | # from the cache to save time | |
946 | for p in pl: |
|
946 | for p in pl: | |
947 | if not r'_filelog' in p.__dict__: |
|
947 | if not r'_filelog' in p.__dict__: | |
948 | p._filelog = getlog(p.path()) |
|
948 | p._filelog = getlog(p.path()) | |
949 |
|
949 | |||
950 | return pl |
|
950 | return pl | |
951 |
|
951 | |||
952 | # use linkrev to find the first changeset where self appeared |
|
952 | # use linkrev to find the first changeset where self appeared | |
953 | base = self.introfilectx() |
|
953 | base = self.introfilectx() | |
954 | if getattr(base, '_ancestrycontext', None) is None: |
|
954 | if getattr(base, '_ancestrycontext', None) is None: | |
955 | cl = self._repo.changelog |
|
955 | cl = self._repo.changelog | |
956 | if base.rev() is None: |
|
956 | if base.rev() is None: | |
957 | # wctx is not inclusive, but works because _ancestrycontext |
|
957 | # wctx is not inclusive, but works because _ancestrycontext | |
958 | # is used to test filelog revisions |
|
958 | # is used to test filelog revisions | |
959 | ac = cl.ancestors([p.rev() for p in base.parents()], |
|
959 | ac = cl.ancestors([p.rev() for p in base.parents()], | |
960 | inclusive=True) |
|
960 | inclusive=True) | |
961 | else: |
|
961 | else: | |
962 | ac = cl.ancestors([base.rev()], inclusive=True) |
|
962 | ac = cl.ancestors([base.rev()], inclusive=True) | |
963 | base._ancestrycontext = ac |
|
963 | base._ancestrycontext = ac | |
964 |
|
964 | |||
965 | return dagop.annotate(base, parents, skiprevs=skiprevs, |
|
965 | return dagop.annotate(base, parents, skiprevs=skiprevs, | |
966 | diffopts=diffopts) |
|
966 | diffopts=diffopts) | |
967 |
|
967 | |||
968 | def ancestors(self, followfirst=False): |
|
968 | def ancestors(self, followfirst=False): | |
969 | visit = {} |
|
969 | visit = {} | |
970 | c = self |
|
970 | c = self | |
971 | if followfirst: |
|
971 | if followfirst: | |
972 | cut = 1 |
|
972 | cut = 1 | |
973 | else: |
|
973 | else: | |
974 | cut = None |
|
974 | cut = None | |
975 |
|
975 | |||
976 | while True: |
|
976 | while True: | |
977 | for parent in c.parents()[:cut]: |
|
977 | for parent in c.parents()[:cut]: | |
978 | visit[(parent.linkrev(), parent.filenode())] = parent |
|
978 | visit[(parent.linkrev(), parent.filenode())] = parent | |
979 | if not visit: |
|
979 | if not visit: | |
980 | break |
|
980 | break | |
981 | c = visit.pop(max(visit)) |
|
981 | c = visit.pop(max(visit)) | |
982 | yield c |
|
982 | yield c | |
983 |
|
983 | |||
984 | def decodeddata(self): |
|
984 | def decodeddata(self): | |
985 | """Returns `data()` after running repository decoding filters. |
|
985 | """Returns `data()` after running repository decoding filters. | |
986 |
|
986 | |||
987 | This is often equivalent to how the data would be expressed on disk. |
|
987 | This is often equivalent to how the data would be expressed on disk. | |
988 | """ |
|
988 | """ | |
989 | return self._repo.wwritedata(self.path(), self.data()) |
|
989 | return self._repo.wwritedata(self.path(), self.data()) | |
990 |
|
990 | |||
991 | class filectx(basefilectx): |
|
991 | class filectx(basefilectx): | |
992 | """A filecontext object makes access to data related to a particular |
|
992 | """A filecontext object makes access to data related to a particular | |
993 | filerevision convenient.""" |
|
993 | filerevision convenient.""" | |
994 | def __init__(self, repo, path, changeid=None, fileid=None, |
|
994 | def __init__(self, repo, path, changeid=None, fileid=None, | |
995 | filelog=None, changectx=None): |
|
995 | filelog=None, changectx=None): | |
996 | """changeid must be a revision number, if specified. |
|
996 | """changeid must be a revision number, if specified. | |
997 | fileid can be a file revision or node.""" |
|
997 | fileid can be a file revision or node.""" | |
998 | self._repo = repo |
|
998 | self._repo = repo | |
999 | self._path = path |
|
999 | self._path = path | |
1000 |
|
1000 | |||
1001 | assert (changeid is not None |
|
1001 | assert (changeid is not None | |
1002 | or fileid is not None |
|
1002 | or fileid is not None | |
1003 | or changectx is not None), ( |
|
1003 | or changectx is not None), ( | |
1004 | "bad args: changeid=%r, fileid=%r, changectx=%r" |
|
1004 | "bad args: changeid=%r, fileid=%r, changectx=%r" | |
1005 | % (changeid, fileid, changectx)) |
|
1005 | % (changeid, fileid, changectx)) | |
1006 |
|
1006 | |||
1007 | if filelog is not None: |
|
1007 | if filelog is not None: | |
1008 | self._filelog = filelog |
|
1008 | self._filelog = filelog | |
1009 |
|
1009 | |||
1010 | if changeid is not None: |
|
1010 | if changeid is not None: | |
1011 | self._changeid = changeid |
|
1011 | self._changeid = changeid | |
1012 | if changectx is not None: |
|
1012 | if changectx is not None: | |
1013 | self._changectx = changectx |
|
1013 | self._changectx = changectx | |
1014 | if fileid is not None: |
|
1014 | if fileid is not None: | |
1015 | self._fileid = fileid |
|
1015 | self._fileid = fileid | |
1016 |
|
1016 | |||
1017 | @propertycache |
|
1017 | @propertycache | |
1018 | def _changectx(self): |
|
1018 | def _changectx(self): | |
1019 | try: |
|
1019 | try: | |
1020 | return self._repo[self._changeid] |
|
1020 | return self._repo[self._changeid] | |
1021 | except error.FilteredRepoLookupError: |
|
1021 | except error.FilteredRepoLookupError: | |
1022 | # Linkrev may point to any revision in the repository. When the |
|
1022 | # Linkrev may point to any revision in the repository. When the | |
1023 | # repository is filtered this may lead to `filectx` trying to build |
|
1023 | # repository is filtered this may lead to `filectx` trying to build | |
1024 | # `changectx` for filtered revision. In such case we fallback to |
|
1024 | # `changectx` for filtered revision. In such case we fallback to | |
1025 | # creating `changectx` on the unfiltered version of the reposition. |
|
1025 | # creating `changectx` on the unfiltered version of the reposition. | |
1026 | # This fallback should not be an issue because `changectx` from |
|
1026 | # This fallback should not be an issue because `changectx` from | |
1027 | # `filectx` are not used in complex operations that care about |
|
1027 | # `filectx` are not used in complex operations that care about | |
1028 | # filtering. |
|
1028 | # filtering. | |
1029 | # |
|
1029 | # | |
1030 | # This fallback is a cheap and dirty fix that prevent several |
|
1030 | # This fallback is a cheap and dirty fix that prevent several | |
1031 | # crashes. It does not ensure the behavior is correct. However the |
|
1031 | # crashes. It does not ensure the behavior is correct. However the | |
1032 | # behavior was not correct before filtering either and "incorrect |
|
1032 | # behavior was not correct before filtering either and "incorrect | |
1033 | # behavior" is seen as better as "crash" |
|
1033 | # behavior" is seen as better as "crash" | |
1034 | # |
|
1034 | # | |
1035 | # Linkrevs have several serious troubles with filtering that are |
|
1035 | # Linkrevs have several serious troubles with filtering that are | |
1036 | # complicated to solve. Proper handling of the issue here should be |
|
1036 | # complicated to solve. Proper handling of the issue here should be | |
1037 | # considered when solving linkrev issue are on the table. |
|
1037 | # considered when solving linkrev issue are on the table. | |
1038 | return self._repo.unfiltered()[self._changeid] |
|
1038 | return self._repo.unfiltered()[self._changeid] | |
1039 |
|
1039 | |||
1040 | def filectx(self, fileid, changeid=None): |
|
1040 | def filectx(self, fileid, changeid=None): | |
1041 | '''opens an arbitrary revision of the file without |
|
1041 | '''opens an arbitrary revision of the file without | |
1042 | opening a new filelog''' |
|
1042 | opening a new filelog''' | |
1043 | return filectx(self._repo, self._path, fileid=fileid, |
|
1043 | return filectx(self._repo, self._path, fileid=fileid, | |
1044 | filelog=self._filelog, changeid=changeid) |
|
1044 | filelog=self._filelog, changeid=changeid) | |
1045 |
|
1045 | |||
1046 | def rawdata(self): |
|
1046 | def rawdata(self): | |
1047 | return self._filelog.revision(self._filenode, raw=True) |
|
1047 | return self._filelog.revision(self._filenode, raw=True) | |
1048 |
|
1048 | |||
1049 | def rawflags(self): |
|
1049 | def rawflags(self): | |
1050 | """low-level revlog flags""" |
|
1050 | """low-level revlog flags""" | |
1051 | return self._filelog.flags(self._filerev) |
|
1051 | return self._filelog.flags(self._filerev) | |
1052 |
|
1052 | |||
1053 | def data(self): |
|
1053 | def data(self): | |
1054 | try: |
|
1054 | try: | |
1055 | return self._filelog.read(self._filenode) |
|
1055 | return self._filelog.read(self._filenode) | |
1056 | except error.CensoredNodeError: |
|
1056 | except error.CensoredNodeError: | |
1057 | if self._repo.ui.config("censor", "policy") == "ignore": |
|
1057 | if self._repo.ui.config("censor", "policy") == "ignore": | |
1058 | return "" |
|
1058 | return "" | |
1059 | raise error.Abort(_("censored node: %s") % short(self._filenode), |
|
1059 | raise error.Abort(_("censored node: %s") % short(self._filenode), | |
1060 | hint=_("set censor.policy to ignore errors")) |
|
1060 | hint=_("set censor.policy to ignore errors")) | |
1061 |
|
1061 | |||
1062 | def size(self): |
|
1062 | def size(self): | |
1063 | return self._filelog.size(self._filerev) |
|
1063 | return self._filelog.size(self._filerev) | |
1064 |
|
1064 | |||
1065 | @propertycache |
|
1065 | @propertycache | |
1066 | def _copied(self): |
|
1066 | def _copied(self): | |
1067 | """check if file was actually renamed in this changeset revision |
|
1067 | """check if file was actually renamed in this changeset revision | |
1068 |
|
1068 | |||
1069 | If rename logged in file revision, we report copy for changeset only |
|
1069 | If rename logged in file revision, we report copy for changeset only | |
1070 | if file revisions linkrev points back to the changeset in question |
|
1070 | if file revisions linkrev points back to the changeset in question | |
1071 | or both changeset parents contain different file revisions. |
|
1071 | or both changeset parents contain different file revisions. | |
1072 | """ |
|
1072 | """ | |
1073 |
|
1073 | |||
1074 | renamed = self._filelog.renamed(self._filenode) |
|
1074 | renamed = self._filelog.renamed(self._filenode) | |
1075 | if not renamed: |
|
1075 | if not renamed: | |
1076 | return None |
|
1076 | return None | |
1077 |
|
1077 | |||
1078 | if self.rev() == self.linkrev(): |
|
1078 | if self.rev() == self.linkrev(): | |
1079 | return renamed |
|
1079 | return renamed | |
1080 |
|
1080 | |||
1081 | name = self.path() |
|
1081 | name = self.path() | |
1082 | fnode = self._filenode |
|
1082 | fnode = self._filenode | |
1083 | for p in self._changectx.parents(): |
|
1083 | for p in self._changectx.parents(): | |
1084 | try: |
|
1084 | try: | |
1085 | if fnode == p.filenode(name): |
|
1085 | if fnode == p.filenode(name): | |
1086 | return None |
|
1086 | return None | |
1087 | except error.LookupError: |
|
1087 | except error.LookupError: | |
1088 | pass |
|
1088 | pass | |
1089 | return renamed |
|
1089 | return renamed | |
1090 |
|
1090 | |||
1091 | def children(self): |
|
1091 | def children(self): | |
1092 | # hard for renames |
|
1092 | # hard for renames | |
1093 | c = self._filelog.children(self._filenode) |
|
1093 | c = self._filelog.children(self._filenode) | |
1094 | return [filectx(self._repo, self._path, fileid=x, |
|
1094 | return [filectx(self._repo, self._path, fileid=x, | |
1095 | filelog=self._filelog) for x in c] |
|
1095 | filelog=self._filelog) for x in c] | |
1096 |
|
1096 | |||
1097 | class committablectx(basectx): |
|
1097 | class committablectx(basectx): | |
1098 | """A committablectx object provides common functionality for a context that |
|
1098 | """A committablectx object provides common functionality for a context that | |
1099 | wants the ability to commit, e.g. workingctx or memctx.""" |
|
1099 | wants the ability to commit, e.g. workingctx or memctx.""" | |
1100 | def __init__(self, repo, text="", user=None, date=None, extra=None, |
|
1100 | def __init__(self, repo, text="", user=None, date=None, extra=None, | |
1101 | changes=None): |
|
1101 | changes=None): | |
1102 | super(committablectx, self).__init__(repo) |
|
1102 | super(committablectx, self).__init__(repo) | |
1103 | self._rev = None |
|
1103 | self._rev = None | |
1104 | self._node = None |
|
1104 | self._node = None | |
1105 | self._text = text |
|
1105 | self._text = text | |
1106 | if date: |
|
1106 | if date: | |
1107 | self._date = dateutil.parsedate(date) |
|
1107 | self._date = dateutil.parsedate(date) | |
1108 | if user: |
|
1108 | if user: | |
1109 | self._user = user |
|
1109 | self._user = user | |
1110 | if changes: |
|
1110 | if changes: | |
1111 | self._status = changes |
|
1111 | self._status = changes | |
1112 |
|
1112 | |||
1113 | self._extra = {} |
|
1113 | self._extra = {} | |
1114 | if extra: |
|
1114 | if extra: | |
1115 | self._extra = extra.copy() |
|
1115 | self._extra = extra.copy() | |
1116 | if 'branch' not in self._extra: |
|
1116 | if 'branch' not in self._extra: | |
1117 | try: |
|
1117 | try: | |
1118 | branch = encoding.fromlocal(self._repo.dirstate.branch()) |
|
1118 | branch = encoding.fromlocal(self._repo.dirstate.branch()) | |
1119 | except UnicodeDecodeError: |
|
1119 | except UnicodeDecodeError: | |
1120 | raise error.Abort(_('branch name not in UTF-8!')) |
|
1120 | raise error.Abort(_('branch name not in UTF-8!')) | |
1121 | self._extra['branch'] = branch |
|
1121 | self._extra['branch'] = branch | |
1122 | if self._extra['branch'] == '': |
|
1122 | if self._extra['branch'] == '': | |
1123 | self._extra['branch'] = 'default' |
|
1123 | self._extra['branch'] = 'default' | |
1124 |
|
1124 | |||
1125 | def __bytes__(self): |
|
1125 | def __bytes__(self): | |
1126 | return bytes(self._parents[0]) + "+" |
|
1126 | return bytes(self._parents[0]) + "+" | |
1127 |
|
1127 | |||
1128 | __str__ = encoding.strmethod(__bytes__) |
|
1128 | __str__ = encoding.strmethod(__bytes__) | |
1129 |
|
1129 | |||
1130 | def __nonzero__(self): |
|
1130 | def __nonzero__(self): | |
1131 | return True |
|
1131 | return True | |
1132 |
|
1132 | |||
1133 | __bool__ = __nonzero__ |
|
1133 | __bool__ = __nonzero__ | |
1134 |
|
1134 | |||
1135 | def _buildflagfunc(self): |
|
1135 | def _buildflagfunc(self): | |
1136 | # Create a fallback function for getting file flags when the |
|
1136 | # Create a fallback function for getting file flags when the | |
1137 | # filesystem doesn't support them |
|
1137 | # filesystem doesn't support them | |
1138 |
|
1138 | |||
1139 | copiesget = self._repo.dirstate.copies().get |
|
1139 | copiesget = self._repo.dirstate.copies().get | |
1140 | parents = self.parents() |
|
1140 | parents = self.parents() | |
1141 | if len(parents) < 2: |
|
1141 | if len(parents) < 2: | |
1142 | # when we have one parent, it's easy: copy from parent |
|
1142 | # when we have one parent, it's easy: copy from parent | |
1143 | man = parents[0].manifest() |
|
1143 | man = parents[0].manifest() | |
1144 | def func(f): |
|
1144 | def func(f): | |
1145 | f = copiesget(f, f) |
|
1145 | f = copiesget(f, f) | |
1146 | return man.flags(f) |
|
1146 | return man.flags(f) | |
1147 | else: |
|
1147 | else: | |
1148 | # merges are tricky: we try to reconstruct the unstored |
|
1148 | # merges are tricky: we try to reconstruct the unstored | |
1149 | # result from the merge (issue1802) |
|
1149 | # result from the merge (issue1802) | |
1150 | p1, p2 = parents |
|
1150 | p1, p2 = parents | |
1151 | pa = p1.ancestor(p2) |
|
1151 | pa = p1.ancestor(p2) | |
1152 | m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest() |
|
1152 | m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest() | |
1153 |
|
1153 | |||
1154 | def func(f): |
|
1154 | def func(f): | |
1155 | f = copiesget(f, f) # may be wrong for merges with copies |
|
1155 | f = copiesget(f, f) # may be wrong for merges with copies | |
1156 | fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f) |
|
1156 | fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f) | |
1157 | if fl1 == fl2: |
|
1157 | if fl1 == fl2: | |
1158 | return fl1 |
|
1158 | return fl1 | |
1159 | if fl1 == fla: |
|
1159 | if fl1 == fla: | |
1160 | return fl2 |
|
1160 | return fl2 | |
1161 | if fl2 == fla: |
|
1161 | if fl2 == fla: | |
1162 | return fl1 |
|
1162 | return fl1 | |
1163 | return '' # punt for conflicts |
|
1163 | return '' # punt for conflicts | |
1164 |
|
1164 | |||
1165 | return func |
|
1165 | return func | |
1166 |
|
1166 | |||
1167 | @propertycache |
|
1167 | @propertycache | |
1168 | def _flagfunc(self): |
|
1168 | def _flagfunc(self): | |
1169 | return self._repo.dirstate.flagfunc(self._buildflagfunc) |
|
1169 | return self._repo.dirstate.flagfunc(self._buildflagfunc) | |
1170 |
|
1170 | |||
1171 | @propertycache |
|
1171 | @propertycache | |
1172 | def _status(self): |
|
1172 | def _status(self): | |
1173 | return self._repo.status() |
|
1173 | return self._repo.status() | |
1174 |
|
1174 | |||
1175 | @propertycache |
|
1175 | @propertycache | |
1176 | def _user(self): |
|
1176 | def _user(self): | |
1177 | return self._repo.ui.username() |
|
1177 | return self._repo.ui.username() | |
1178 |
|
1178 | |||
1179 | @propertycache |
|
1179 | @propertycache | |
1180 | def _date(self): |
|
1180 | def _date(self): | |
1181 | ui = self._repo.ui |
|
1181 | ui = self._repo.ui | |
1182 | date = ui.configdate('devel', 'default-date') |
|
1182 | date = ui.configdate('devel', 'default-date') | |
1183 | if date is None: |
|
1183 | if date is None: | |
1184 | date = dateutil.makedate() |
|
1184 | date = dateutil.makedate() | |
1185 | return date |
|
1185 | return date | |
1186 |
|
1186 | |||
1187 | def subrev(self, subpath): |
|
1187 | def subrev(self, subpath): | |
1188 | return None |
|
1188 | return None | |
1189 |
|
1189 | |||
1190 | def manifestnode(self): |
|
1190 | def manifestnode(self): | |
1191 | return None |
|
1191 | return None | |
1192 | def user(self): |
|
1192 | def user(self): | |
1193 | return self._user or self._repo.ui.username() |
|
1193 | return self._user or self._repo.ui.username() | |
1194 | def date(self): |
|
1194 | def date(self): | |
1195 | return self._date |
|
1195 | return self._date | |
1196 | def description(self): |
|
1196 | def description(self): | |
1197 | return self._text |
|
1197 | return self._text | |
1198 | def files(self): |
|
1198 | def files(self): | |
1199 | return sorted(self._status.modified + self._status.added + |
|
1199 | return sorted(self._status.modified + self._status.added + | |
1200 | self._status.removed) |
|
1200 | self._status.removed) | |
1201 | def modified(self): |
|
1201 | def modified(self): | |
1202 | return self._status.modified |
|
1202 | return self._status.modified | |
1203 | def added(self): |
|
1203 | def added(self): | |
1204 | return self._status.added |
|
1204 | return self._status.added | |
1205 | def removed(self): |
|
1205 | def removed(self): | |
1206 | return self._status.removed |
|
1206 | return self._status.removed | |
1207 | def deleted(self): |
|
1207 | def deleted(self): | |
1208 | return self._status.deleted |
|
1208 | return self._status.deleted | |
1209 | @propertycache |
|
1209 | @propertycache | |
1210 | def _copies(self): |
|
1210 | def _copies(self): | |
1211 | p1copies = {} |
|
1211 | p1copies = {} | |
1212 | p2copies = {} |
|
1212 | p2copies = {} | |
1213 | parents = self._repo.dirstate.parents() |
|
1213 | parents = self._repo.dirstate.parents() | |
1214 | p1manifest = self._repo[parents[0]].manifest() |
|
1214 | p1manifest = self._repo[parents[0]].manifest() | |
1215 | p2manifest = self._repo[parents[1]].manifest() |
|
1215 | p2manifest = self._repo[parents[1]].manifest() | |
1216 | narrowmatch = self._repo.narrowmatch() |
|
1216 | narrowmatch = self._repo.narrowmatch() | |
1217 | for dst, src in self._repo.dirstate.copies().items(): |
|
1217 | for dst, src in self._repo.dirstate.copies().items(): | |
1218 | if not narrowmatch(dst): |
|
1218 | if not narrowmatch(dst): | |
1219 | continue |
|
1219 | continue | |
1220 | if src in p1manifest: |
|
1220 | if src in p1manifest: | |
1221 | p1copies[dst] = src |
|
1221 | p1copies[dst] = src | |
1222 | elif src in p2manifest: |
|
1222 | elif src in p2manifest: | |
1223 | p2copies[dst] = src |
|
1223 | p2copies[dst] = src | |
1224 | return p1copies, p2copies |
|
1224 | return p1copies, p2copies | |
1225 | def p1copies(self): |
|
1225 | def p1copies(self): | |
1226 | return self._copies[0] |
|
1226 | return self._copies[0] | |
1227 | def p2copies(self): |
|
1227 | def p2copies(self): | |
1228 | return self._copies[1] |
|
1228 | return self._copies[1] | |
1229 | def branch(self): |
|
1229 | def branch(self): | |
1230 | return encoding.tolocal(self._extra['branch']) |
|
1230 | return encoding.tolocal(self._extra['branch']) | |
1231 | def closesbranch(self): |
|
1231 | def closesbranch(self): | |
1232 | return 'close' in self._extra |
|
1232 | return 'close' in self._extra | |
1233 | def extra(self): |
|
1233 | def extra(self): | |
1234 | return self._extra |
|
1234 | return self._extra | |
1235 |
|
1235 | |||
1236 | def isinmemory(self): |
|
1236 | def isinmemory(self): | |
1237 | return False |
|
1237 | return False | |
1238 |
|
1238 | |||
1239 | def tags(self): |
|
1239 | def tags(self): | |
1240 | return [] |
|
1240 | return [] | |
1241 |
|
1241 | |||
1242 | def bookmarks(self): |
|
1242 | def bookmarks(self): | |
1243 | b = [] |
|
1243 | b = [] | |
1244 | for p in self.parents(): |
|
1244 | for p in self.parents(): | |
1245 | b.extend(p.bookmarks()) |
|
1245 | b.extend(p.bookmarks()) | |
1246 | return b |
|
1246 | return b | |
1247 |
|
1247 | |||
1248 | def phase(self): |
|
1248 | def phase(self): | |
1249 | phase = phases.draft # default phase to draft |
|
1249 | phase = phases.draft # default phase to draft | |
1250 | for p in self.parents(): |
|
1250 | for p in self.parents(): | |
1251 | phase = max(phase, p.phase()) |
|
1251 | phase = max(phase, p.phase()) | |
1252 | return phase |
|
1252 | return phase | |
1253 |
|
1253 | |||
1254 | def hidden(self): |
|
1254 | def hidden(self): | |
1255 | return False |
|
1255 | return False | |
1256 |
|
1256 | |||
1257 | def children(self): |
|
1257 | def children(self): | |
1258 | return [] |
|
1258 | return [] | |
1259 |
|
1259 | |||
1260 | def flags(self, path): |
|
1260 | def flags(self, path): | |
1261 | if r'_manifest' in self.__dict__: |
|
1261 | if r'_manifest' in self.__dict__: | |
1262 | try: |
|
1262 | try: | |
1263 | return self._manifest.flags(path) |
|
1263 | return self._manifest.flags(path) | |
1264 | except KeyError: |
|
1264 | except KeyError: | |
1265 | return '' |
|
1265 | return '' | |
1266 |
|
1266 | |||
1267 | try: |
|
1267 | try: | |
1268 | return self._flagfunc(path) |
|
1268 | return self._flagfunc(path) | |
1269 | except OSError: |
|
1269 | except OSError: | |
1270 | return '' |
|
1270 | return '' | |
1271 |
|
1271 | |||
1272 | def ancestor(self, c2): |
|
1272 | def ancestor(self, c2): | |
1273 | """return the "best" ancestor context of self and c2""" |
|
1273 | """return the "best" ancestor context of self and c2""" | |
1274 | return self._parents[0].ancestor(c2) # punt on two parents for now |
|
1274 | return self._parents[0].ancestor(c2) # punt on two parents for now | |
1275 |
|
1275 | |||
1276 | def walk(self, match): |
|
1276 | def walk(self, match): | |
1277 | '''Generates matching file names.''' |
|
1277 | '''Generates matching file names.''' | |
1278 | return sorted(self._repo.dirstate.walk(self._repo.narrowmatch(match), |
|
1278 | return sorted(self._repo.dirstate.walk(self._repo.narrowmatch(match), | |
1279 | subrepos=sorted(self.substate), |
|
1279 | subrepos=sorted(self.substate), | |
1280 | unknown=True, ignored=False)) |
|
1280 | unknown=True, ignored=False)) | |
1281 |
|
1281 | |||
1282 | def matches(self, match): |
|
1282 | def matches(self, match): | |
1283 | match = self._repo.narrowmatch(match) |
|
1283 | match = self._repo.narrowmatch(match) | |
1284 | ds = self._repo.dirstate |
|
1284 | ds = self._repo.dirstate | |
1285 | return sorted(f for f in ds.matches(match) if ds[f] != 'r') |
|
1285 | return sorted(f for f in ds.matches(match) if ds[f] != 'r') | |
1286 |
|
1286 | |||
1287 | def ancestors(self): |
|
1287 | def ancestors(self): | |
1288 | for p in self._parents: |
|
1288 | for p in self._parents: | |
1289 | yield p |
|
1289 | yield p | |
1290 | for a in self._repo.changelog.ancestors( |
|
1290 | for a in self._repo.changelog.ancestors( | |
1291 | [p.rev() for p in self._parents]): |
|
1291 | [p.rev() for p in self._parents]): | |
1292 | yield self._repo[a] |
|
1292 | yield self._repo[a] | |
1293 |
|
1293 | |||
1294 | def markcommitted(self, node): |
|
1294 | def markcommitted(self, node): | |
1295 | """Perform post-commit cleanup necessary after committing this ctx |
|
1295 | """Perform post-commit cleanup necessary after committing this ctx | |
1296 |
|
1296 | |||
1297 | Specifically, this updates backing stores this working context |
|
1297 | Specifically, this updates backing stores this working context | |
1298 | wraps to reflect the fact that the changes reflected by this |
|
1298 | wraps to reflect the fact that the changes reflected by this | |
1299 | workingctx have been committed. For example, it marks |
|
1299 | workingctx have been committed. For example, it marks | |
1300 | modified and added files as normal in the dirstate. |
|
1300 | modified and added files as normal in the dirstate. | |
1301 |
|
1301 | |||
1302 | """ |
|
1302 | """ | |
1303 |
|
1303 | |||
1304 | with self._repo.dirstate.parentchange(): |
|
1304 | with self._repo.dirstate.parentchange(): | |
1305 | for f in self.modified() + self.added(): |
|
1305 | for f in self.modified() + self.added(): | |
1306 | self._repo.dirstate.normal(f) |
|
1306 | self._repo.dirstate.normal(f) | |
1307 | for f in self.removed(): |
|
1307 | for f in self.removed(): | |
1308 | self._repo.dirstate.drop(f) |
|
1308 | self._repo.dirstate.drop(f) | |
1309 | self._repo.dirstate.setparents(node) |
|
1309 | self._repo.dirstate.setparents(node) | |
1310 |
|
1310 | |||
1311 | # write changes out explicitly, because nesting wlock at |
|
1311 | # write changes out explicitly, because nesting wlock at | |
1312 | # runtime may prevent 'wlock.release()' in 'repo.commit()' |
|
1312 | # runtime may prevent 'wlock.release()' in 'repo.commit()' | |
1313 | # from immediately doing so for subsequent changing files |
|
1313 | # from immediately doing so for subsequent changing files | |
1314 | self._repo.dirstate.write(self._repo.currenttransaction()) |
|
1314 | self._repo.dirstate.write(self._repo.currenttransaction()) | |
1315 |
|
1315 | |||
1316 | def dirty(self, missing=False, merge=True, branch=True): |
|
1316 | def dirty(self, missing=False, merge=True, branch=True): | |
1317 | return False |
|
1317 | return False | |
1318 |
|
1318 | |||
1319 | class workingctx(committablectx): |
|
1319 | class workingctx(committablectx): | |
1320 | """A workingctx object makes access to data related to |
|
1320 | """A workingctx object makes access to data related to | |
1321 | the current working directory convenient. |
|
1321 | the current working directory convenient. | |
1322 | date - any valid date string or (unixtime, offset), or None. |
|
1322 | date - any valid date string or (unixtime, offset), or None. | |
1323 | user - username string, or None. |
|
1323 | user - username string, or None. | |
1324 | extra - a dictionary of extra values, or None. |
|
1324 | extra - a dictionary of extra values, or None. | |
1325 | changes - a list of file lists as returned by localrepo.status() |
|
1325 | changes - a list of file lists as returned by localrepo.status() | |
1326 | or None to use the repository status. |
|
1326 | or None to use the repository status. | |
1327 | """ |
|
1327 | """ | |
1328 | def __init__(self, repo, text="", user=None, date=None, extra=None, |
|
1328 | def __init__(self, repo, text="", user=None, date=None, extra=None, | |
1329 | changes=None): |
|
1329 | changes=None): | |
1330 | super(workingctx, self).__init__(repo, text, user, date, extra, changes) |
|
1330 | super(workingctx, self).__init__(repo, text, user, date, extra, changes) | |
1331 |
|
1331 | |||
1332 | def __iter__(self): |
|
1332 | def __iter__(self): | |
1333 | d = self._repo.dirstate |
|
1333 | d = self._repo.dirstate | |
1334 | for f in d: |
|
1334 | for f in d: | |
1335 | if d[f] != 'r': |
|
1335 | if d[f] != 'r': | |
1336 | yield f |
|
1336 | yield f | |
1337 |
|
1337 | |||
1338 | def __contains__(self, key): |
|
1338 | def __contains__(self, key): | |
1339 | return self._repo.dirstate[key] not in "?r" |
|
1339 | return self._repo.dirstate[key] not in "?r" | |
1340 |
|
1340 | |||
1341 | def hex(self): |
|
1341 | def hex(self): | |
1342 | return wdirhex |
|
1342 | return wdirhex | |
1343 |
|
1343 | |||
1344 | @propertycache |
|
1344 | @propertycache | |
1345 | def _parents(self): |
|
1345 | def _parents(self): | |
1346 | p = self._repo.dirstate.parents() |
|
1346 | p = self._repo.dirstate.parents() | |
1347 | if p[1] == nullid: |
|
1347 | if p[1] == nullid: | |
1348 | p = p[:-1] |
|
1348 | p = p[:-1] | |
1349 | # use unfiltered repo to delay/avoid loading obsmarkers |
|
1349 | # use unfiltered repo to delay/avoid loading obsmarkers | |
1350 | unfi = self._repo.unfiltered() |
|
1350 | unfi = self._repo.unfiltered() | |
1351 | return [changectx(self._repo, unfi.changelog.rev(n), n) for n in p] |
|
1351 | return [changectx(self._repo, unfi.changelog.rev(n), n) for n in p] | |
1352 |
|
1352 | |||
1353 | def _fileinfo(self, path): |
|
1353 | def _fileinfo(self, path): | |
1354 | # populate __dict__['_manifest'] as workingctx has no _manifestdelta |
|
1354 | # populate __dict__['_manifest'] as workingctx has no _manifestdelta | |
1355 | self._manifest |
|
1355 | self._manifest | |
1356 | return super(workingctx, self)._fileinfo(path) |
|
1356 | return super(workingctx, self)._fileinfo(path) | |
1357 |
|
1357 | |||
1358 | def filectx(self, path, filelog=None): |
|
1358 | def filectx(self, path, filelog=None): | |
1359 | """get a file context from the working directory""" |
|
1359 | """get a file context from the working directory""" | |
1360 | return workingfilectx(self._repo, path, workingctx=self, |
|
1360 | return workingfilectx(self._repo, path, workingctx=self, | |
1361 | filelog=filelog) |
|
1361 | filelog=filelog) | |
1362 |
|
1362 | |||
1363 | def dirty(self, missing=False, merge=True, branch=True): |
|
1363 | def dirty(self, missing=False, merge=True, branch=True): | |
1364 | "check whether a working directory is modified" |
|
1364 | "check whether a working directory is modified" | |
1365 | # check subrepos first |
|
1365 | # check subrepos first | |
1366 | for s in sorted(self.substate): |
|
1366 | for s in sorted(self.substate): | |
1367 | if self.sub(s).dirty(missing=missing): |
|
1367 | if self.sub(s).dirty(missing=missing): | |
1368 | return True |
|
1368 | return True | |
1369 | # check current working dir |
|
1369 | # check current working dir | |
1370 | return ((merge and self.p2()) or |
|
1370 | return ((merge and self.p2()) or | |
1371 | (branch and self.branch() != self.p1().branch()) or |
|
1371 | (branch and self.branch() != self.p1().branch()) or | |
1372 | self.modified() or self.added() or self.removed() or |
|
1372 | self.modified() or self.added() or self.removed() or | |
1373 | (missing and self.deleted())) |
|
1373 | (missing and self.deleted())) | |
1374 |
|
1374 | |||
1375 | def add(self, list, prefix=""): |
|
1375 | def add(self, list, prefix=""): | |
1376 | with self._repo.wlock(): |
|
1376 | with self._repo.wlock(): | |
1377 | ui, ds = self._repo.ui, self._repo.dirstate |
|
1377 | ui, ds = self._repo.ui, self._repo.dirstate | |
1378 | uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) |
|
1378 | uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) | |
1379 | rejected = [] |
|
1379 | rejected = [] | |
1380 | lstat = self._repo.wvfs.lstat |
|
1380 | lstat = self._repo.wvfs.lstat | |
1381 | for f in list: |
|
1381 | for f in list: | |
1382 | # ds.pathto() returns an absolute file when this is invoked from |
|
1382 | # ds.pathto() returns an absolute file when this is invoked from | |
1383 | # the keyword extension. That gets flagged as non-portable on |
|
1383 | # the keyword extension. That gets flagged as non-portable on | |
1384 | # Windows, since it contains the drive letter and colon. |
|
1384 | # Windows, since it contains the drive letter and colon. | |
1385 | scmutil.checkportable(ui, os.path.join(prefix, f)) |
|
1385 | scmutil.checkportable(ui, os.path.join(prefix, f)) | |
1386 | try: |
|
1386 | try: | |
1387 | st = lstat(f) |
|
1387 | st = lstat(f) | |
1388 | except OSError: |
|
1388 | except OSError: | |
1389 | ui.warn(_("%s does not exist!\n") % uipath(f)) |
|
1389 | ui.warn(_("%s does not exist!\n") % uipath(f)) | |
1390 | rejected.append(f) |
|
1390 | rejected.append(f) | |
1391 | continue |
|
1391 | continue | |
1392 | limit = ui.configbytes('ui', 'large-file-limit') |
|
1392 | limit = ui.configbytes('ui', 'large-file-limit') | |
1393 | if limit != 0 and st.st_size > limit: |
|
1393 | if limit != 0 and st.st_size > limit: | |
1394 | ui.warn(_("%s: up to %d MB of RAM may be required " |
|
1394 | ui.warn(_("%s: up to %d MB of RAM may be required " | |
1395 | "to manage this file\n" |
|
1395 | "to manage this file\n" | |
1396 | "(use 'hg revert %s' to cancel the " |
|
1396 | "(use 'hg revert %s' to cancel the " | |
1397 | "pending addition)\n") |
|
1397 | "pending addition)\n") | |
1398 | % (f, 3 * st.st_size // 1000000, uipath(f))) |
|
1398 | % (f, 3 * st.st_size // 1000000, uipath(f))) | |
1399 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
|
1399 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): | |
1400 | ui.warn(_("%s not added: only files and symlinks " |
|
1400 | ui.warn(_("%s not added: only files and symlinks " | |
1401 | "supported currently\n") % uipath(f)) |
|
1401 | "supported currently\n") % uipath(f)) | |
1402 | rejected.append(f) |
|
1402 | rejected.append(f) | |
1403 | elif ds[f] in 'amn': |
|
1403 | elif ds[f] in 'amn': | |
1404 | ui.warn(_("%s already tracked!\n") % uipath(f)) |
|
1404 | ui.warn(_("%s already tracked!\n") % uipath(f)) | |
1405 | elif ds[f] == 'r': |
|
1405 | elif ds[f] == 'r': | |
1406 | ds.normallookup(f) |
|
1406 | ds.normallookup(f) | |
1407 | else: |
|
1407 | else: | |
1408 | ds.add(f) |
|
1408 | ds.add(f) | |
1409 | return rejected |
|
1409 | return rejected | |
1410 |
|
1410 | |||
1411 | def forget(self, files, prefix=""): |
|
1411 | def forget(self, files, prefix=""): | |
1412 | with self._repo.wlock(): |
|
1412 | with self._repo.wlock(): | |
1413 | ds = self._repo.dirstate |
|
1413 | ds = self._repo.dirstate | |
1414 | uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) |
|
1414 | uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) | |
1415 | rejected = [] |
|
1415 | rejected = [] | |
1416 | for f in files: |
|
1416 | for f in files: | |
1417 | if f not in ds: |
|
1417 | if f not in ds: | |
1418 | self._repo.ui.warn(_("%s not tracked!\n") % uipath(f)) |
|
1418 | self._repo.ui.warn(_("%s not tracked!\n") % uipath(f)) | |
1419 | rejected.append(f) |
|
1419 | rejected.append(f) | |
1420 | elif ds[f] != 'a': |
|
1420 | elif ds[f] != 'a': | |
1421 | ds.remove(f) |
|
1421 | ds.remove(f) | |
1422 | else: |
|
1422 | else: | |
1423 | ds.drop(f) |
|
1423 | ds.drop(f) | |
1424 | return rejected |
|
1424 | return rejected | |
1425 |
|
1425 | |||
1426 | def copy(self, source, dest): |
|
1426 | def copy(self, source, dest): | |
1427 | try: |
|
1427 | try: | |
1428 | st = self._repo.wvfs.lstat(dest) |
|
1428 | st = self._repo.wvfs.lstat(dest) | |
1429 | except OSError as err: |
|
1429 | except OSError as err: | |
1430 | if err.errno != errno.ENOENT: |
|
1430 | if err.errno != errno.ENOENT: | |
1431 | raise |
|
1431 | raise | |
1432 | self._repo.ui.warn(_("%s does not exist!\n") |
|
1432 | self._repo.ui.warn(_("%s does not exist!\n") | |
1433 | % self._repo.dirstate.pathto(dest)) |
|
1433 | % self._repo.dirstate.pathto(dest)) | |
1434 | return |
|
1434 | return | |
1435 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
|
1435 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): | |
1436 | self._repo.ui.warn(_("copy failed: %s is not a file or a " |
|
1436 | self._repo.ui.warn(_("copy failed: %s is not a file or a " | |
1437 | "symbolic link\n") |
|
1437 | "symbolic link\n") | |
1438 | % self._repo.dirstate.pathto(dest)) |
|
1438 | % self._repo.dirstate.pathto(dest)) | |
1439 | else: |
|
1439 | else: | |
1440 | with self._repo.wlock(): |
|
1440 | with self._repo.wlock(): | |
1441 | ds = self._repo.dirstate |
|
1441 | ds = self._repo.dirstate | |
1442 | if ds[dest] in '?': |
|
1442 | if ds[dest] in '?': | |
1443 | ds.add(dest) |
|
1443 | ds.add(dest) | |
1444 | elif ds[dest] in 'r': |
|
1444 | elif ds[dest] in 'r': | |
1445 | ds.normallookup(dest) |
|
1445 | ds.normallookup(dest) | |
1446 | ds.copy(source, dest) |
|
1446 | ds.copy(source, dest) | |
1447 |
|
1447 | |||
1448 | def match(self, pats=None, include=None, exclude=None, default='glob', |
|
1448 | def match(self, pats=None, include=None, exclude=None, default='glob', | |
1449 | listsubrepos=False, badfn=None): |
|
1449 | listsubrepos=False, badfn=None): | |
1450 | r = self._repo |
|
1450 | r = self._repo | |
1451 |
|
1451 | |||
1452 | # Only a case insensitive filesystem needs magic to translate user input |
|
1452 | # Only a case insensitive filesystem needs magic to translate user input | |
1453 | # to actual case in the filesystem. |
|
1453 | # to actual case in the filesystem. | |
1454 | icasefs = not util.fscasesensitive(r.root) |
|
1454 | icasefs = not util.fscasesensitive(r.root) | |
1455 | return matchmod.match(r.root, r.getcwd(), pats, include, exclude, |
|
1455 | return matchmod.match(r.root, r.getcwd(), pats, include, exclude, | |
1456 | default, auditor=r.auditor, ctx=self, |
|
1456 | default, auditor=r.auditor, ctx=self, | |
1457 | listsubrepos=listsubrepos, badfn=badfn, |
|
1457 | listsubrepos=listsubrepos, badfn=badfn, | |
1458 | icasefs=icasefs) |
|
1458 | icasefs=icasefs) | |
1459 |
|
1459 | |||
1460 | def _filtersuspectsymlink(self, files): |
|
1460 | def _filtersuspectsymlink(self, files): | |
1461 | if not files or self._repo.dirstate._checklink: |
|
1461 | if not files or self._repo.dirstate._checklink: | |
1462 | return files |
|
1462 | return files | |
1463 |
|
1463 | |||
1464 | # Symlink placeholders may get non-symlink-like contents |
|
1464 | # Symlink placeholders may get non-symlink-like contents | |
1465 | # via user error or dereferencing by NFS or Samba servers, |
|
1465 | # via user error or dereferencing by NFS or Samba servers, | |
1466 | # so we filter out any placeholders that don't look like a |
|
1466 | # so we filter out any placeholders that don't look like a | |
1467 | # symlink |
|
1467 | # symlink | |
1468 | sane = [] |
|
1468 | sane = [] | |
1469 | for f in files: |
|
1469 | for f in files: | |
1470 | if self.flags(f) == 'l': |
|
1470 | if self.flags(f) == 'l': | |
1471 | d = self[f].data() |
|
1471 | d = self[f].data() | |
1472 | if (d == '' or len(d) >= 1024 or '\n' in d |
|
1472 | if (d == '' or len(d) >= 1024 or '\n' in d | |
1473 | or stringutil.binary(d)): |
|
1473 | or stringutil.binary(d)): | |
1474 | self._repo.ui.debug('ignoring suspect symlink placeholder' |
|
1474 | self._repo.ui.debug('ignoring suspect symlink placeholder' | |
1475 | ' "%s"\n' % f) |
|
1475 | ' "%s"\n' % f) | |
1476 | continue |
|
1476 | continue | |
1477 | sane.append(f) |
|
1477 | sane.append(f) | |
1478 | return sane |
|
1478 | return sane | |
1479 |
|
1479 | |||
1480 | def _checklookup(self, files): |
|
1480 | def _checklookup(self, files): | |
1481 | # check for any possibly clean files |
|
1481 | # check for any possibly clean files | |
1482 | if not files: |
|
1482 | if not files: | |
1483 | return [], [], [] |
|
1483 | return [], [], [] | |
1484 |
|
1484 | |||
1485 | modified = [] |
|
1485 | modified = [] | |
1486 | deleted = [] |
|
1486 | deleted = [] | |
1487 | fixup = [] |
|
1487 | fixup = [] | |
1488 | pctx = self._parents[0] |
|
1488 | pctx = self._parents[0] | |
1489 | # do a full compare of any files that might have changed |
|
1489 | # do a full compare of any files that might have changed | |
1490 | for f in sorted(files): |
|
1490 | for f in sorted(files): | |
1491 | try: |
|
1491 | try: | |
1492 | # This will return True for a file that got replaced by a |
|
1492 | # This will return True for a file that got replaced by a | |
1493 | # directory in the interim, but fixing that is pretty hard. |
|
1493 | # directory in the interim, but fixing that is pretty hard. | |
1494 | if (f not in pctx or self.flags(f) != pctx.flags(f) |
|
1494 | if (f not in pctx or self.flags(f) != pctx.flags(f) | |
1495 | or pctx[f].cmp(self[f])): |
|
1495 | or pctx[f].cmp(self[f])): | |
1496 | modified.append(f) |
|
1496 | modified.append(f) | |
1497 | else: |
|
1497 | else: | |
1498 | fixup.append(f) |
|
1498 | fixup.append(f) | |
1499 | except (IOError, OSError): |
|
1499 | except (IOError, OSError): | |
1500 | # A file become inaccessible in between? Mark it as deleted, |
|
1500 | # A file become inaccessible in between? Mark it as deleted, | |
1501 | # matching dirstate behavior (issue5584). |
|
1501 | # matching dirstate behavior (issue5584). | |
1502 | # The dirstate has more complex behavior around whether a |
|
1502 | # The dirstate has more complex behavior around whether a | |
1503 | # missing file matches a directory, etc, but we don't need to |
|
1503 | # missing file matches a directory, etc, but we don't need to | |
1504 | # bother with that: if f has made it to this point, we're sure |
|
1504 | # bother with that: if f has made it to this point, we're sure | |
1505 | # it's in the dirstate. |
|
1505 | # it's in the dirstate. | |
1506 | deleted.append(f) |
|
1506 | deleted.append(f) | |
1507 |
|
1507 | |||
1508 | return modified, deleted, fixup |
|
1508 | return modified, deleted, fixup | |
1509 |
|
1509 | |||
1510 | def _poststatusfixup(self, status, fixup): |
|
1510 | def _poststatusfixup(self, status, fixup): | |
1511 | """update dirstate for files that are actually clean""" |
|
1511 | """update dirstate for files that are actually clean""" | |
1512 | poststatus = self._repo.postdsstatus() |
|
1512 | poststatus = self._repo.postdsstatus() | |
1513 | if fixup or poststatus: |
|
1513 | if fixup or poststatus: | |
1514 | try: |
|
1514 | try: | |
1515 | oldid = self._repo.dirstate.identity() |
|
1515 | oldid = self._repo.dirstate.identity() | |
1516 |
|
1516 | |||
1517 | # updating the dirstate is optional |
|
1517 | # updating the dirstate is optional | |
1518 | # so we don't wait on the lock |
|
1518 | # so we don't wait on the lock | |
1519 | # wlock can invalidate the dirstate, so cache normal _after_ |
|
1519 | # wlock can invalidate the dirstate, so cache normal _after_ | |
1520 | # taking the lock |
|
1520 | # taking the lock | |
1521 | with self._repo.wlock(False): |
|
1521 | with self._repo.wlock(False): | |
1522 | if self._repo.dirstate.identity() == oldid: |
|
1522 | if self._repo.dirstate.identity() == oldid: | |
1523 | if fixup: |
|
1523 | if fixup: | |
1524 | normal = self._repo.dirstate.normal |
|
1524 | normal = self._repo.dirstate.normal | |
1525 | for f in fixup: |
|
1525 | for f in fixup: | |
1526 | normal(f) |
|
1526 | normal(f) | |
1527 | # write changes out explicitly, because nesting |
|
1527 | # write changes out explicitly, because nesting | |
1528 | # wlock at runtime may prevent 'wlock.release()' |
|
1528 | # wlock at runtime may prevent 'wlock.release()' | |
1529 | # after this block from doing so for subsequent |
|
1529 | # after this block from doing so for subsequent | |
1530 | # changing files |
|
1530 | # changing files | |
1531 | tr = self._repo.currenttransaction() |
|
1531 | tr = self._repo.currenttransaction() | |
1532 | self._repo.dirstate.write(tr) |
|
1532 | self._repo.dirstate.write(tr) | |
1533 |
|
1533 | |||
1534 | if poststatus: |
|
1534 | if poststatus: | |
1535 | for ps in poststatus: |
|
1535 | for ps in poststatus: | |
1536 | ps(self, status) |
|
1536 | ps(self, status) | |
1537 | else: |
|
1537 | else: | |
1538 | # in this case, writing changes out breaks |
|
1538 | # in this case, writing changes out breaks | |
1539 | # consistency, because .hg/dirstate was |
|
1539 | # consistency, because .hg/dirstate was | |
1540 | # already changed simultaneously after last |
|
1540 | # already changed simultaneously after last | |
1541 | # caching (see also issue5584 for detail) |
|
1541 | # caching (see also issue5584 for detail) | |
1542 | self._repo.ui.debug('skip updating dirstate: ' |
|
1542 | self._repo.ui.debug('skip updating dirstate: ' | |
1543 | 'identity mismatch\n') |
|
1543 | 'identity mismatch\n') | |
1544 | except error.LockError: |
|
1544 | except error.LockError: | |
1545 | pass |
|
1545 | pass | |
1546 | finally: |
|
1546 | finally: | |
1547 | # Even if the wlock couldn't be grabbed, clear out the list. |
|
1547 | # Even if the wlock couldn't be grabbed, clear out the list. | |
1548 | self._repo.clearpostdsstatus() |
|
1548 | self._repo.clearpostdsstatus() | |
1549 |
|
1549 | |||
1550 | def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): |
|
1550 | def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): | |
1551 | '''Gets the status from the dirstate -- internal use only.''' |
|
1551 | '''Gets the status from the dirstate -- internal use only.''' | |
1552 | subrepos = [] |
|
1552 | subrepos = [] | |
1553 | if '.hgsub' in self: |
|
1553 | if '.hgsub' in self: | |
1554 | subrepos = sorted(self.substate) |
|
1554 | subrepos = sorted(self.substate) | |
1555 | cmp, s = self._repo.dirstate.status(match, subrepos, ignored=ignored, |
|
1555 | cmp, s = self._repo.dirstate.status(match, subrepos, ignored=ignored, | |
1556 | clean=clean, unknown=unknown) |
|
1556 | clean=clean, unknown=unknown) | |
1557 |
|
1557 | |||
1558 | # check for any possibly clean files |
|
1558 | # check for any possibly clean files | |
1559 | fixup = [] |
|
1559 | fixup = [] | |
1560 | if cmp: |
|
1560 | if cmp: | |
1561 | modified2, deleted2, fixup = self._checklookup(cmp) |
|
1561 | modified2, deleted2, fixup = self._checklookup(cmp) | |
1562 | s.modified.extend(modified2) |
|
1562 | s.modified.extend(modified2) | |
1563 | s.deleted.extend(deleted2) |
|
1563 | s.deleted.extend(deleted2) | |
1564 |
|
1564 | |||
1565 | if fixup and clean: |
|
1565 | if fixup and clean: | |
1566 | s.clean.extend(fixup) |
|
1566 | s.clean.extend(fixup) | |
1567 |
|
1567 | |||
1568 | self._poststatusfixup(s, fixup) |
|
1568 | self._poststatusfixup(s, fixup) | |
1569 |
|
1569 | |||
1570 | if match.always(): |
|
1570 | if match.always(): | |
1571 | # cache for performance |
|
1571 | # cache for performance | |
1572 | if s.unknown or s.ignored or s.clean: |
|
1572 | if s.unknown or s.ignored or s.clean: | |
1573 | # "_status" is cached with list*=False in the normal route |
|
1573 | # "_status" is cached with list*=False in the normal route | |
1574 | self._status = scmutil.status(s.modified, s.added, s.removed, |
|
1574 | self._status = scmutil.status(s.modified, s.added, s.removed, | |
1575 | s.deleted, [], [], []) |
|
1575 | s.deleted, [], [], []) | |
1576 | else: |
|
1576 | else: | |
1577 | self._status = s |
|
1577 | self._status = s | |
1578 |
|
1578 | |||
1579 | return s |
|
1579 | return s | |
1580 |
|
1580 | |||
1581 | @propertycache |
|
1581 | @propertycache | |
1582 | def _manifest(self): |
|
1582 | def _manifest(self): | |
1583 | """generate a manifest corresponding to the values in self._status |
|
1583 | """generate a manifest corresponding to the values in self._status | |
1584 |
|
1584 | |||
1585 | This reuse the file nodeid from parent, but we use special node |
|
1585 | This reuse the file nodeid from parent, but we use special node | |
1586 | identifiers for added and modified files. This is used by manifests |
|
1586 | identifiers for added and modified files. This is used by manifests | |
1587 | merge to see that files are different and by update logic to avoid |
|
1587 | merge to see that files are different and by update logic to avoid | |
1588 | deleting newly added files. |
|
1588 | deleting newly added files. | |
1589 | """ |
|
1589 | """ | |
1590 | return self._buildstatusmanifest(self._status) |
|
1590 | return self._buildstatusmanifest(self._status) | |
1591 |
|
1591 | |||
1592 | def _buildstatusmanifest(self, status): |
|
1592 | def _buildstatusmanifest(self, status): | |
1593 | """Builds a manifest that includes the given status results.""" |
|
1593 | """Builds a manifest that includes the given status results.""" | |
1594 | parents = self.parents() |
|
1594 | parents = self.parents() | |
1595 |
|
1595 | |||
1596 | man = parents[0].manifest().copy() |
|
1596 | man = parents[0].manifest().copy() | |
1597 |
|
1597 | |||
1598 | ff = self._flagfunc |
|
1598 | ff = self._flagfunc | |
1599 | for i, l in ((addednodeid, status.added), |
|
1599 | for i, l in ((addednodeid, status.added), | |
1600 | (modifiednodeid, status.modified)): |
|
1600 | (modifiednodeid, status.modified)): | |
1601 | for f in l: |
|
1601 | for f in l: | |
1602 | man[f] = i |
|
1602 | man[f] = i | |
1603 | try: |
|
1603 | try: | |
1604 | man.setflag(f, ff(f)) |
|
1604 | man.setflag(f, ff(f)) | |
1605 | except OSError: |
|
1605 | except OSError: | |
1606 | pass |
|
1606 | pass | |
1607 |
|
1607 | |||
1608 | for f in status.deleted + status.removed: |
|
1608 | for f in status.deleted + status.removed: | |
1609 | if f in man: |
|
1609 | if f in man: | |
1610 | del man[f] |
|
1610 | del man[f] | |
1611 |
|
1611 | |||
1612 | return man |
|
1612 | return man | |
1613 |
|
1613 | |||
1614 | def _buildstatus(self, other, s, match, listignored, listclean, |
|
1614 | def _buildstatus(self, other, s, match, listignored, listclean, | |
1615 | listunknown): |
|
1615 | listunknown): | |
1616 | """build a status with respect to another context |
|
1616 | """build a status with respect to another context | |
1617 |
|
1617 | |||
1618 | This includes logic for maintaining the fast path of status when |
|
1618 | This includes logic for maintaining the fast path of status when | |
1619 | comparing the working directory against its parent, which is to skip |
|
1619 | comparing the working directory against its parent, which is to skip | |
1620 | building a new manifest if self (working directory) is not comparing |
|
1620 | building a new manifest if self (working directory) is not comparing | |
1621 | against its parent (repo['.']). |
|
1621 | against its parent (repo['.']). | |
1622 | """ |
|
1622 | """ | |
1623 | s = self._dirstatestatus(match, listignored, listclean, listunknown) |
|
1623 | s = self._dirstatestatus(match, listignored, listclean, listunknown) | |
1624 | # Filter out symlinks that, in the case of FAT32 and NTFS filesystems, |
|
1624 | # Filter out symlinks that, in the case of FAT32 and NTFS filesystems, | |
1625 | # might have accidentally ended up with the entire contents of the file |
|
1625 | # might have accidentally ended up with the entire contents of the file | |
1626 | # they are supposed to be linking to. |
|
1626 | # they are supposed to be linking to. | |
1627 | s.modified[:] = self._filtersuspectsymlink(s.modified) |
|
1627 | s.modified[:] = self._filtersuspectsymlink(s.modified) | |
1628 | if other != self._repo['.']: |
|
1628 | if other != self._repo['.']: | |
1629 | s = super(workingctx, self)._buildstatus(other, s, match, |
|
1629 | s = super(workingctx, self)._buildstatus(other, s, match, | |
1630 | listignored, listclean, |
|
1630 | listignored, listclean, | |
1631 | listunknown) |
|
1631 | listunknown) | |
1632 | return s |
|
1632 | return s | |
1633 |
|
1633 | |||
1634 | def _matchstatus(self, other, match): |
|
1634 | def _matchstatus(self, other, match): | |
1635 | """override the match method with a filter for directory patterns |
|
1635 | """override the match method with a filter for directory patterns | |
1636 |
|
1636 | |||
1637 | We use inheritance to customize the match.bad method only in cases of |
|
1637 | We use inheritance to customize the match.bad method only in cases of | |
1638 | workingctx since it belongs only to the working directory when |
|
1638 | workingctx since it belongs only to the working directory when | |
1639 | comparing against the parent changeset. |
|
1639 | comparing against the parent changeset. | |
1640 |
|
1640 | |||
1641 | If we aren't comparing against the working directory's parent, then we |
|
1641 | If we aren't comparing against the working directory's parent, then we | |
1642 | just use the default match object sent to us. |
|
1642 | just use the default match object sent to us. | |
1643 | """ |
|
1643 | """ | |
1644 | if other != self._repo['.']: |
|
1644 | if other != self._repo['.']: | |
1645 | def bad(f, msg): |
|
1645 | def bad(f, msg): | |
1646 | # 'f' may be a directory pattern from 'match.files()', |
|
1646 | # 'f' may be a directory pattern from 'match.files()', | |
1647 | # so 'f not in ctx1' is not enough |
|
1647 | # so 'f not in ctx1' is not enough | |
1648 | if f not in other and not other.hasdir(f): |
|
1648 | if f not in other and not other.hasdir(f): | |
1649 | self._repo.ui.warn('%s: %s\n' % |
|
1649 | self._repo.ui.warn('%s: %s\n' % | |
1650 | (self._repo.dirstate.pathto(f), msg)) |
|
1650 | (self._repo.dirstate.pathto(f), msg)) | |
1651 | match.bad = bad |
|
1651 | match.bad = bad | |
1652 | return match |
|
1652 | return match | |
1653 |
|
1653 | |||
1654 | def markcommitted(self, node): |
|
1654 | def markcommitted(self, node): | |
1655 | super(workingctx, self).markcommitted(node) |
|
1655 | super(workingctx, self).markcommitted(node) | |
1656 |
|
1656 | |||
1657 | sparse.aftercommit(self._repo, node) |
|
1657 | sparse.aftercommit(self._repo, node) | |
1658 |
|
1658 | |||
1659 | class committablefilectx(basefilectx): |
|
1659 | class committablefilectx(basefilectx): | |
1660 | """A committablefilectx provides common functionality for a file context |
|
1660 | """A committablefilectx provides common functionality for a file context | |
1661 | that wants the ability to commit, e.g. workingfilectx or memfilectx.""" |
|
1661 | that wants the ability to commit, e.g. workingfilectx or memfilectx.""" | |
1662 | def __init__(self, repo, path, filelog=None, ctx=None): |
|
1662 | def __init__(self, repo, path, filelog=None, ctx=None): | |
1663 | self._repo = repo |
|
1663 | self._repo = repo | |
1664 | self._path = path |
|
1664 | self._path = path | |
1665 | self._changeid = None |
|
1665 | self._changeid = None | |
1666 | self._filerev = self._filenode = None |
|
1666 | self._filerev = self._filenode = None | |
1667 |
|
1667 | |||
1668 | if filelog is not None: |
|
1668 | if filelog is not None: | |
1669 | self._filelog = filelog |
|
1669 | self._filelog = filelog | |
1670 | if ctx: |
|
1670 | if ctx: | |
1671 | self._changectx = ctx |
|
1671 | self._changectx = ctx | |
1672 |
|
1672 | |||
1673 | def __nonzero__(self): |
|
1673 | def __nonzero__(self): | |
1674 | return True |
|
1674 | return True | |
1675 |
|
1675 | |||
1676 | __bool__ = __nonzero__ |
|
1676 | __bool__ = __nonzero__ | |
1677 |
|
1677 | |||
1678 | def linkrev(self): |
|
1678 | def linkrev(self): | |
1679 | # linked to self._changectx no matter if file is modified or not |
|
1679 | # linked to self._changectx no matter if file is modified or not | |
1680 | return self.rev() |
|
1680 | return self.rev() | |
1681 |
|
1681 | |||
1682 | def renamed(self): |
|
1682 | def renamed(self): | |
1683 | path = self.copysource() |
|
1683 | path = self.copysource() | |
1684 | if not path: |
|
1684 | if not path: | |
1685 | return None |
|
1685 | return None | |
1686 | return path, self._changectx._parents[0]._manifest.get(path, nullid) |
|
1686 | return path, self._changectx._parents[0]._manifest.get(path, nullid) | |
1687 |
|
1687 | |||
1688 | def parents(self): |
|
1688 | def parents(self): | |
1689 | '''return parent filectxs, following copies if necessary''' |
|
1689 | '''return parent filectxs, following copies if necessary''' | |
1690 | def filenode(ctx, path): |
|
1690 | def filenode(ctx, path): | |
1691 | return ctx._manifest.get(path, nullid) |
|
1691 | return ctx._manifest.get(path, nullid) | |
1692 |
|
1692 | |||
1693 | path = self._path |
|
1693 | path = self._path | |
1694 | fl = self._filelog |
|
1694 | fl = self._filelog | |
1695 | pcl = self._changectx._parents |
|
1695 | pcl = self._changectx._parents | |
1696 | renamed = self.renamed() |
|
1696 | renamed = self.renamed() | |
1697 |
|
1697 | |||
1698 | if renamed: |
|
1698 | if renamed: | |
1699 | pl = [renamed + (None,)] |
|
1699 | pl = [renamed + (None,)] | |
1700 | else: |
|
1700 | else: | |
1701 | pl = [(path, filenode(pcl[0], path), fl)] |
|
1701 | pl = [(path, filenode(pcl[0], path), fl)] | |
1702 |
|
1702 | |||
1703 | for pc in pcl[1:]: |
|
1703 | for pc in pcl[1:]: | |
1704 | pl.append((path, filenode(pc, path), fl)) |
|
1704 | pl.append((path, filenode(pc, path), fl)) | |
1705 |
|
1705 | |||
1706 | return [self._parentfilectx(p, fileid=n, filelog=l) |
|
1706 | return [self._parentfilectx(p, fileid=n, filelog=l) | |
1707 | for p, n, l in pl if n != nullid] |
|
1707 | for p, n, l in pl if n != nullid] | |
1708 |
|
1708 | |||
1709 | def children(self): |
|
1709 | def children(self): | |
1710 | return [] |
|
1710 | return [] | |
1711 |
|
1711 | |||
1712 | class workingfilectx(committablefilectx): |
|
1712 | class workingfilectx(committablefilectx): | |
1713 | """A workingfilectx object makes access to data related to a particular |
|
1713 | """A workingfilectx object makes access to data related to a particular | |
1714 | file in the working directory convenient.""" |
|
1714 | file in the working directory convenient.""" | |
1715 | def __init__(self, repo, path, filelog=None, workingctx=None): |
|
1715 | def __init__(self, repo, path, filelog=None, workingctx=None): | |
1716 | super(workingfilectx, self).__init__(repo, path, filelog, workingctx) |
|
1716 | super(workingfilectx, self).__init__(repo, path, filelog, workingctx) | |
1717 |
|
1717 | |||
1718 | @propertycache |
|
1718 | @propertycache | |
1719 | def _changectx(self): |
|
1719 | def _changectx(self): | |
1720 | return workingctx(self._repo) |
|
1720 | return workingctx(self._repo) | |
1721 |
|
1721 | |||
1722 | def data(self): |
|
1722 | def data(self): | |
1723 | return self._repo.wread(self._path) |
|
1723 | return self._repo.wread(self._path) | |
1724 | def copysource(self): |
|
1724 | def copysource(self): | |
1725 | return self._repo.dirstate.copied(self._path) |
|
1725 | return self._repo.dirstate.copied(self._path) | |
1726 |
|
1726 | |||
1727 | def size(self): |
|
1727 | def size(self): | |
1728 | return self._repo.wvfs.lstat(self._path).st_size |
|
1728 | return self._repo.wvfs.lstat(self._path).st_size | |
1729 | def date(self): |
|
1729 | def date(self): | |
1730 | t, tz = self._changectx.date() |
|
1730 | t, tz = self._changectx.date() | |
1731 | try: |
|
1731 | try: | |
1732 | return (self._repo.wvfs.lstat(self._path)[stat.ST_MTIME], tz) |
|
1732 | return (self._repo.wvfs.lstat(self._path)[stat.ST_MTIME], tz) | |
1733 | except OSError as err: |
|
1733 | except OSError as err: | |
1734 | if err.errno != errno.ENOENT: |
|
1734 | if err.errno != errno.ENOENT: | |
1735 | raise |
|
1735 | raise | |
1736 | return (t, tz) |
|
1736 | return (t, tz) | |
1737 |
|
1737 | |||
1738 | def exists(self): |
|
1738 | def exists(self): | |
1739 | return self._repo.wvfs.exists(self._path) |
|
1739 | return self._repo.wvfs.exists(self._path) | |
1740 |
|
1740 | |||
1741 | def lexists(self): |
|
1741 | def lexists(self): | |
1742 | return self._repo.wvfs.lexists(self._path) |
|
1742 | return self._repo.wvfs.lexists(self._path) | |
1743 |
|
1743 | |||
1744 | def audit(self): |
|
1744 | def audit(self): | |
1745 | return self._repo.wvfs.audit(self._path) |
|
1745 | return self._repo.wvfs.audit(self._path) | |
1746 |
|
1746 | |||
1747 | def cmp(self, fctx): |
|
1747 | def cmp(self, fctx): | |
1748 | """compare with other file context |
|
1748 | """compare with other file context | |
1749 |
|
1749 | |||
1750 | returns True if different than fctx. |
|
1750 | returns True if different than fctx. | |
1751 | """ |
|
1751 | """ | |
1752 | # fctx should be a filectx (not a workingfilectx) |
|
1752 | # fctx should be a filectx (not a workingfilectx) | |
1753 | # invert comparison to reuse the same code path |
|
1753 | # invert comparison to reuse the same code path | |
1754 | return fctx.cmp(self) |
|
1754 | return fctx.cmp(self) | |
1755 |
|
1755 | |||
1756 | def remove(self, ignoremissing=False): |
|
1756 | def remove(self, ignoremissing=False): | |
1757 | """wraps unlink for a repo's working directory""" |
|
1757 | """wraps unlink for a repo's working directory""" | |
1758 | rmdir = self._repo.ui.configbool('experimental', 'removeemptydirs') |
|
1758 | rmdir = self._repo.ui.configbool('experimental', 'removeemptydirs') | |
1759 | self._repo.wvfs.unlinkpath(self._path, ignoremissing=ignoremissing, |
|
1759 | self._repo.wvfs.unlinkpath(self._path, ignoremissing=ignoremissing, | |
1760 | rmdir=rmdir) |
|
1760 | rmdir=rmdir) | |
1761 |
|
1761 | |||
1762 | def write(self, data, flags, backgroundclose=False, **kwargs): |
|
1762 | def write(self, data, flags, backgroundclose=False, **kwargs): | |
1763 | """wraps repo.wwrite""" |
|
1763 | """wraps repo.wwrite""" | |
1764 | self._repo.wwrite(self._path, data, flags, |
|
1764 | self._repo.wwrite(self._path, data, flags, | |
1765 | backgroundclose=backgroundclose, |
|
1765 | backgroundclose=backgroundclose, | |
1766 | **kwargs) |
|
1766 | **kwargs) | |
1767 |
|
1767 | |||
1768 | def markcopied(self, src): |
|
1768 | def markcopied(self, src): | |
1769 | """marks this file a copy of `src`""" |
|
1769 | """marks this file a copy of `src`""" | |
1770 | if self._repo.dirstate[self._path] in "nma": |
|
1770 | if self._repo.dirstate[self._path] in "nma": | |
1771 | self._repo.dirstate.copy(src, self._path) |
|
1771 | self._repo.dirstate.copy(src, self._path) | |
1772 |
|
1772 | |||
1773 | def clearunknown(self): |
|
1773 | def clearunknown(self): | |
1774 | """Removes conflicting items in the working directory so that |
|
1774 | """Removes conflicting items in the working directory so that | |
1775 | ``write()`` can be called successfully. |
|
1775 | ``write()`` can be called successfully. | |
1776 | """ |
|
1776 | """ | |
1777 | wvfs = self._repo.wvfs |
|
1777 | wvfs = self._repo.wvfs | |
1778 | f = self._path |
|
1778 | f = self._path | |
1779 | wvfs.audit(f) |
|
1779 | wvfs.audit(f) | |
1780 | if self._repo.ui.configbool('experimental', 'merge.checkpathconflicts'): |
|
1780 | if self._repo.ui.configbool('experimental', 'merge.checkpathconflicts'): | |
1781 | # remove files under the directory as they should already be |
|
1781 | # remove files under the directory as they should already be | |
1782 | # warned and backed up |
|
1782 | # warned and backed up | |
1783 | if wvfs.isdir(f) and not wvfs.islink(f): |
|
1783 | if wvfs.isdir(f) and not wvfs.islink(f): | |
1784 | wvfs.rmtree(f, forcibly=True) |
|
1784 | wvfs.rmtree(f, forcibly=True) | |
1785 | for p in reversed(list(util.finddirs(f))): |
|
1785 | for p in reversed(list(util.finddirs(f))): | |
1786 | if wvfs.isfileorlink(p): |
|
1786 | if wvfs.isfileorlink(p): | |
1787 | wvfs.unlink(p) |
|
1787 | wvfs.unlink(p) | |
1788 | break |
|
1788 | break | |
1789 | else: |
|
1789 | else: | |
1790 | # don't remove files if path conflicts are not processed |
|
1790 | # don't remove files if path conflicts are not processed | |
1791 | if wvfs.isdir(f) and not wvfs.islink(f): |
|
1791 | if wvfs.isdir(f) and not wvfs.islink(f): | |
1792 | wvfs.removedirs(f) |
|
1792 | wvfs.removedirs(f) | |
1793 |
|
1793 | |||
1794 | def setflags(self, l, x): |
|
1794 | def setflags(self, l, x): | |
1795 | self._repo.wvfs.setflags(self._path, l, x) |
|
1795 | self._repo.wvfs.setflags(self._path, l, x) | |
1796 |
|
1796 | |||
1797 | class overlayworkingctx(committablectx): |
|
1797 | class overlayworkingctx(committablectx): | |
1798 | """Wraps another mutable context with a write-back cache that can be |
|
1798 | """Wraps another mutable context with a write-back cache that can be | |
1799 | converted into a commit context. |
|
1799 | converted into a commit context. | |
1800 |
|
1800 | |||
1801 | self._cache[path] maps to a dict with keys: { |
|
1801 | self._cache[path] maps to a dict with keys: { | |
1802 | 'exists': bool? |
|
1802 | 'exists': bool? | |
1803 | 'date': date? |
|
1803 | 'date': date? | |
1804 | 'data': str? |
|
1804 | 'data': str? | |
1805 | 'flags': str? |
|
1805 | 'flags': str? | |
1806 | 'copied': str? (path or None) |
|
1806 | 'copied': str? (path or None) | |
1807 | } |
|
1807 | } | |
1808 | If `exists` is True, `flags` must be non-None and 'date' is non-None. If it |
|
1808 | If `exists` is True, `flags` must be non-None and 'date' is non-None. If it | |
1809 | is `False`, the file was deleted. |
|
1809 | is `False`, the file was deleted. | |
1810 | """ |
|
1810 | """ | |
1811 |
|
1811 | |||
1812 | def __init__(self, repo): |
|
1812 | def __init__(self, repo): | |
1813 | super(overlayworkingctx, self).__init__(repo) |
|
1813 | super(overlayworkingctx, self).__init__(repo) | |
1814 | self.clean() |
|
1814 | self.clean() | |
1815 |
|
1815 | |||
1816 | def setbase(self, wrappedctx): |
|
1816 | def setbase(self, wrappedctx): | |
1817 | self._wrappedctx = wrappedctx |
|
1817 | self._wrappedctx = wrappedctx | |
1818 | self._parents = [wrappedctx] |
|
1818 | self._parents = [wrappedctx] | |
1819 | # Drop old manifest cache as it is now out of date. |
|
1819 | # Drop old manifest cache as it is now out of date. | |
1820 | # This is necessary when, e.g., rebasing several nodes with one |
|
1820 | # This is necessary when, e.g., rebasing several nodes with one | |
1821 | # ``overlayworkingctx`` (e.g. with --collapse). |
|
1821 | # ``overlayworkingctx`` (e.g. with --collapse). | |
1822 | util.clearcachedproperty(self, '_manifest') |
|
1822 | util.clearcachedproperty(self, '_manifest') | |
1823 |
|
1823 | |||
1824 | def data(self, path): |
|
1824 | def data(self, path): | |
1825 | if self.isdirty(path): |
|
1825 | if self.isdirty(path): | |
1826 | if self._cache[path]['exists']: |
|
1826 | if self._cache[path]['exists']: | |
1827 | if self._cache[path]['data'] is not None: |
|
1827 | if self._cache[path]['data'] is not None: | |
1828 | return self._cache[path]['data'] |
|
1828 | return self._cache[path]['data'] | |
1829 | else: |
|
1829 | else: | |
1830 | # Must fallback here, too, because we only set flags. |
|
1830 | # Must fallback here, too, because we only set flags. | |
1831 | return self._wrappedctx[path].data() |
|
1831 | return self._wrappedctx[path].data() | |
1832 | else: |
|
1832 | else: | |
1833 | raise error.ProgrammingError("No such file or directory: %s" % |
|
1833 | raise error.ProgrammingError("No such file or directory: %s" % | |
1834 | path) |
|
1834 | path) | |
1835 | else: |
|
1835 | else: | |
1836 | return self._wrappedctx[path].data() |
|
1836 | return self._wrappedctx[path].data() | |
1837 |
|
1837 | |||
1838 | @propertycache |
|
1838 | @propertycache | |
1839 | def _manifest(self): |
|
1839 | def _manifest(self): | |
1840 | parents = self.parents() |
|
1840 | parents = self.parents() | |
1841 | man = parents[0].manifest().copy() |
|
1841 | man = parents[0].manifest().copy() | |
1842 |
|
1842 | |||
1843 | flag = self._flagfunc |
|
1843 | flag = self._flagfunc | |
1844 | for path in self.added(): |
|
1844 | for path in self.added(): | |
1845 | man[path] = addednodeid |
|
1845 | man[path] = addednodeid | |
1846 | man.setflag(path, flag(path)) |
|
1846 | man.setflag(path, flag(path)) | |
1847 | for path in self.modified(): |
|
1847 | for path in self.modified(): | |
1848 | man[path] = modifiednodeid |
|
1848 | man[path] = modifiednodeid | |
1849 | man.setflag(path, flag(path)) |
|
1849 | man.setflag(path, flag(path)) | |
1850 | for path in self.removed(): |
|
1850 | for path in self.removed(): | |
1851 | del man[path] |
|
1851 | del man[path] | |
1852 | return man |
|
1852 | return man | |
1853 |
|
1853 | |||
1854 | @propertycache |
|
1854 | @propertycache | |
1855 | def _flagfunc(self): |
|
1855 | def _flagfunc(self): | |
1856 | def f(path): |
|
1856 | def f(path): | |
1857 | return self._cache[path]['flags'] |
|
1857 | return self._cache[path]['flags'] | |
1858 | return f |
|
1858 | return f | |
1859 |
|
1859 | |||
1860 | def files(self): |
|
1860 | def files(self): | |
1861 | return sorted(self.added() + self.modified() + self.removed()) |
|
1861 | return sorted(self.added() + self.modified() + self.removed()) | |
1862 |
|
1862 | |||
1863 | def modified(self): |
|
1863 | def modified(self): | |
1864 | return [f for f in self._cache.keys() if self._cache[f]['exists'] and |
|
1864 | return [f for f in self._cache.keys() if self._cache[f]['exists'] and | |
1865 | self._existsinparent(f)] |
|
1865 | self._existsinparent(f)] | |
1866 |
|
1866 | |||
1867 | def added(self): |
|
1867 | def added(self): | |
1868 | return [f for f in self._cache.keys() if self._cache[f]['exists'] and |
|
1868 | return [f for f in self._cache.keys() if self._cache[f]['exists'] and | |
1869 | not self._existsinparent(f)] |
|
1869 | not self._existsinparent(f)] | |
1870 |
|
1870 | |||
1871 | def removed(self): |
|
1871 | def removed(self): | |
1872 | return [f for f in self._cache.keys() if |
|
1872 | return [f for f in self._cache.keys() if | |
1873 | not self._cache[f]['exists'] and self._existsinparent(f)] |
|
1873 | not self._cache[f]['exists'] and self._existsinparent(f)] | |
1874 |
|
1874 | |||
1875 | def p1copies(self): |
|
1875 | def p1copies(self): | |
1876 | copies = self._repo._wrappedctx.p1copies().copy() |
|
1876 | copies = self._repo._wrappedctx.p1copies().copy() | |
1877 | narrowmatch = self._repo.narrowmatch() |
|
1877 | narrowmatch = self._repo.narrowmatch() | |
1878 | for f in self._cache.keys(): |
|
1878 | for f in self._cache.keys(): | |
1879 | if not narrowmatch(f): |
|
1879 | if not narrowmatch(f): | |
1880 | continue |
|
1880 | continue | |
1881 | copies.pop(f, None) # delete if it exists |
|
1881 | copies.pop(f, None) # delete if it exists | |
1882 | source = self._cache[f]['copied'] |
|
1882 | source = self._cache[f]['copied'] | |
1883 | if source: |
|
1883 | if source: | |
1884 | copies[f] = source |
|
1884 | copies[f] = source | |
1885 | return copies |
|
1885 | return copies | |
1886 |
|
1886 | |||
1887 | def p2copies(self): |
|
1887 | def p2copies(self): | |
1888 | copies = self._repo._wrappedctx.p2copies().copy() |
|
1888 | copies = self._repo._wrappedctx.p2copies().copy() | |
1889 | narrowmatch = self._repo.narrowmatch() |
|
1889 | narrowmatch = self._repo.narrowmatch() | |
1890 | for f in self._cache.keys(): |
|
1890 | for f in self._cache.keys(): | |
1891 | if not narrowmatch(f): |
|
1891 | if not narrowmatch(f): | |
1892 | continue |
|
1892 | continue | |
1893 | copies.pop(f, None) # delete if it exists |
|
1893 | copies.pop(f, None) # delete if it exists | |
1894 | source = self._cache[f]['copied'] |
|
1894 | source = self._cache[f]['copied'] | |
1895 | if source: |
|
1895 | if source: | |
1896 | copies[f] = source |
|
1896 | copies[f] = source | |
1897 | return copies |
|
1897 | return copies | |
1898 |
|
1898 | |||
1899 | def isinmemory(self): |
|
1899 | def isinmemory(self): | |
1900 | return True |
|
1900 | return True | |
1901 |
|
1901 | |||
1902 | def filedate(self, path): |
|
1902 | def filedate(self, path): | |
1903 | if self.isdirty(path): |
|
1903 | if self.isdirty(path): | |
1904 | return self._cache[path]['date'] |
|
1904 | return self._cache[path]['date'] | |
1905 | else: |
|
1905 | else: | |
1906 | return self._wrappedctx[path].date() |
|
1906 | return self._wrappedctx[path].date() | |
1907 |
|
1907 | |||
1908 | def markcopied(self, path, origin): |
|
1908 | def markcopied(self, path, origin): | |
1909 | self._markdirty(path, exists=True, date=self.filedate(path), |
|
1909 | self._markdirty(path, exists=True, date=self.filedate(path), | |
1910 | flags=self.flags(path), copied=origin) |
|
1910 | flags=self.flags(path), copied=origin) | |
1911 |
|
1911 | |||
1912 | def copydata(self, path): |
|
1912 | def copydata(self, path): | |
1913 | if self.isdirty(path): |
|
1913 | if self.isdirty(path): | |
1914 | return self._cache[path]['copied'] |
|
1914 | return self._cache[path]['copied'] | |
1915 | else: |
|
1915 | else: | |
1916 | raise error.ProgrammingError('copydata() called on clean context') |
|
1916 | return None | |
1917 |
|
1917 | |||
1918 | def flags(self, path): |
|
1918 | def flags(self, path): | |
1919 | if self.isdirty(path): |
|
1919 | if self.isdirty(path): | |
1920 | if self._cache[path]['exists']: |
|
1920 | if self._cache[path]['exists']: | |
1921 | return self._cache[path]['flags'] |
|
1921 | return self._cache[path]['flags'] | |
1922 | else: |
|
1922 | else: | |
1923 | raise error.ProgrammingError("No such file or directory: %s" % |
|
1923 | raise error.ProgrammingError("No such file or directory: %s" % | |
1924 | self._path) |
|
1924 | self._path) | |
1925 | else: |
|
1925 | else: | |
1926 | return self._wrappedctx[path].flags() |
|
1926 | return self._wrappedctx[path].flags() | |
1927 |
|
1927 | |||
1928 | def __contains__(self, key): |
|
1928 | def __contains__(self, key): | |
1929 | if key in self._cache: |
|
1929 | if key in self._cache: | |
1930 | return self._cache[key]['exists'] |
|
1930 | return self._cache[key]['exists'] | |
1931 | return key in self.p1() |
|
1931 | return key in self.p1() | |
1932 |
|
1932 | |||
1933 | def _existsinparent(self, path): |
|
1933 | def _existsinparent(self, path): | |
1934 | try: |
|
1934 | try: | |
1935 | # ``commitctx` raises a ``ManifestLookupError`` if a path does not |
|
1935 | # ``commitctx` raises a ``ManifestLookupError`` if a path does not | |
1936 | # exist, unlike ``workingctx``, which returns a ``workingfilectx`` |
|
1936 | # exist, unlike ``workingctx``, which returns a ``workingfilectx`` | |
1937 | # with an ``exists()`` function. |
|
1937 | # with an ``exists()`` function. | |
1938 | self._wrappedctx[path] |
|
1938 | self._wrappedctx[path] | |
1939 | return True |
|
1939 | return True | |
1940 | except error.ManifestLookupError: |
|
1940 | except error.ManifestLookupError: | |
1941 | return False |
|
1941 | return False | |
1942 |
|
1942 | |||
1943 | def _auditconflicts(self, path): |
|
1943 | def _auditconflicts(self, path): | |
1944 | """Replicates conflict checks done by wvfs.write(). |
|
1944 | """Replicates conflict checks done by wvfs.write(). | |
1945 |
|
1945 | |||
1946 | Since we never write to the filesystem and never call `applyupdates` in |
|
1946 | Since we never write to the filesystem and never call `applyupdates` in | |
1947 | IMM, we'll never check that a path is actually writable -- e.g., because |
|
1947 | IMM, we'll never check that a path is actually writable -- e.g., because | |
1948 | it adds `a/foo`, but `a` is actually a file in the other commit. |
|
1948 | it adds `a/foo`, but `a` is actually a file in the other commit. | |
1949 | """ |
|
1949 | """ | |
1950 | def fail(path, component): |
|
1950 | def fail(path, component): | |
1951 | # p1() is the base and we're receiving "writes" for p2()'s |
|
1951 | # p1() is the base and we're receiving "writes" for p2()'s | |
1952 | # files. |
|
1952 | # files. | |
1953 | if 'l' in self.p1()[component].flags(): |
|
1953 | if 'l' in self.p1()[component].flags(): | |
1954 | raise error.Abort("error: %s conflicts with symlink %s " |
|
1954 | raise error.Abort("error: %s conflicts with symlink %s " | |
1955 | "in %d." % (path, component, |
|
1955 | "in %d." % (path, component, | |
1956 | self.p1().rev())) |
|
1956 | self.p1().rev())) | |
1957 | else: |
|
1957 | else: | |
1958 | raise error.Abort("error: '%s' conflicts with file '%s' in " |
|
1958 | raise error.Abort("error: '%s' conflicts with file '%s' in " | |
1959 | "%d." % (path, component, |
|
1959 | "%d." % (path, component, | |
1960 | self.p1().rev())) |
|
1960 | self.p1().rev())) | |
1961 |
|
1961 | |||
1962 | # Test that each new directory to be created to write this path from p2 |
|
1962 | # Test that each new directory to be created to write this path from p2 | |
1963 | # is not a file in p1. |
|
1963 | # is not a file in p1. | |
1964 | components = path.split('/') |
|
1964 | components = path.split('/') | |
1965 | for i in pycompat.xrange(len(components)): |
|
1965 | for i in pycompat.xrange(len(components)): | |
1966 | component = "/".join(components[0:i]) |
|
1966 | component = "/".join(components[0:i]) | |
1967 | if component in self: |
|
1967 | if component in self: | |
1968 | fail(path, component) |
|
1968 | fail(path, component) | |
1969 |
|
1969 | |||
1970 | # Test the other direction -- that this path from p2 isn't a directory |
|
1970 | # Test the other direction -- that this path from p2 isn't a directory | |
1971 | # in p1 (test that p1 doesn't have any paths matching `path/*`). |
|
1971 | # in p1 (test that p1 doesn't have any paths matching `path/*`). | |
1972 | match = self.match([path], default=b'path') |
|
1972 | match = self.match([path], default=b'path') | |
1973 | matches = self.p1().manifest().matches(match) |
|
1973 | matches = self.p1().manifest().matches(match) | |
1974 | mfiles = matches.keys() |
|
1974 | mfiles = matches.keys() | |
1975 | if len(mfiles) > 0: |
|
1975 | if len(mfiles) > 0: | |
1976 | if len(mfiles) == 1 and mfiles[0] == path: |
|
1976 | if len(mfiles) == 1 and mfiles[0] == path: | |
1977 | return |
|
1977 | return | |
1978 | # omit the files which are deleted in current IMM wctx |
|
1978 | # omit the files which are deleted in current IMM wctx | |
1979 | mfiles = [m for m in mfiles if m in self] |
|
1979 | mfiles = [m for m in mfiles if m in self] | |
1980 | if not mfiles: |
|
1980 | if not mfiles: | |
1981 | return |
|
1981 | return | |
1982 | raise error.Abort("error: file '%s' cannot be written because " |
|
1982 | raise error.Abort("error: file '%s' cannot be written because " | |
1983 | " '%s/' is a directory in %s (containing %d " |
|
1983 | " '%s/' is a directory in %s (containing %d " | |
1984 | "entries: %s)" |
|
1984 | "entries: %s)" | |
1985 | % (path, path, self.p1(), len(mfiles), |
|
1985 | % (path, path, self.p1(), len(mfiles), | |
1986 | ', '.join(mfiles))) |
|
1986 | ', '.join(mfiles))) | |
1987 |
|
1987 | |||
1988 | def write(self, path, data, flags='', **kwargs): |
|
1988 | def write(self, path, data, flags='', **kwargs): | |
1989 | if data is None: |
|
1989 | if data is None: | |
1990 | raise error.ProgrammingError("data must be non-None") |
|
1990 | raise error.ProgrammingError("data must be non-None") | |
1991 | self._auditconflicts(path) |
|
1991 | self._auditconflicts(path) | |
1992 | self._markdirty(path, exists=True, data=data, date=dateutil.makedate(), |
|
1992 | self._markdirty(path, exists=True, data=data, date=dateutil.makedate(), | |
1993 | flags=flags) |
|
1993 | flags=flags) | |
1994 |
|
1994 | |||
1995 | def setflags(self, path, l, x): |
|
1995 | def setflags(self, path, l, x): | |
1996 | flag = '' |
|
1996 | flag = '' | |
1997 | if l: |
|
1997 | if l: | |
1998 | flag = 'l' |
|
1998 | flag = 'l' | |
1999 | elif x: |
|
1999 | elif x: | |
2000 | flag = 'x' |
|
2000 | flag = 'x' | |
2001 | self._markdirty(path, exists=True, date=dateutil.makedate(), |
|
2001 | self._markdirty(path, exists=True, date=dateutil.makedate(), | |
2002 | flags=flag) |
|
2002 | flags=flag) | |
2003 |
|
2003 | |||
2004 | def remove(self, path): |
|
2004 | def remove(self, path): | |
2005 | self._markdirty(path, exists=False) |
|
2005 | self._markdirty(path, exists=False) | |
2006 |
|
2006 | |||
2007 | def exists(self, path): |
|
2007 | def exists(self, path): | |
2008 | """exists behaves like `lexists`, but needs to follow symlinks and |
|
2008 | """exists behaves like `lexists`, but needs to follow symlinks and | |
2009 | return False if they are broken. |
|
2009 | return False if they are broken. | |
2010 | """ |
|
2010 | """ | |
2011 | if self.isdirty(path): |
|
2011 | if self.isdirty(path): | |
2012 | # If this path exists and is a symlink, "follow" it by calling |
|
2012 | # If this path exists and is a symlink, "follow" it by calling | |
2013 | # exists on the destination path. |
|
2013 | # exists on the destination path. | |
2014 | if (self._cache[path]['exists'] and |
|
2014 | if (self._cache[path]['exists'] and | |
2015 | 'l' in self._cache[path]['flags']): |
|
2015 | 'l' in self._cache[path]['flags']): | |
2016 | return self.exists(self._cache[path]['data'].strip()) |
|
2016 | return self.exists(self._cache[path]['data'].strip()) | |
2017 | else: |
|
2017 | else: | |
2018 | return self._cache[path]['exists'] |
|
2018 | return self._cache[path]['exists'] | |
2019 |
|
2019 | |||
2020 | return self._existsinparent(path) |
|
2020 | return self._existsinparent(path) | |
2021 |
|
2021 | |||
2022 | def lexists(self, path): |
|
2022 | def lexists(self, path): | |
2023 | """lexists returns True if the path exists""" |
|
2023 | """lexists returns True if the path exists""" | |
2024 | if self.isdirty(path): |
|
2024 | if self.isdirty(path): | |
2025 | return self._cache[path]['exists'] |
|
2025 | return self._cache[path]['exists'] | |
2026 |
|
2026 | |||
2027 | return self._existsinparent(path) |
|
2027 | return self._existsinparent(path) | |
2028 |
|
2028 | |||
2029 | def size(self, path): |
|
2029 | def size(self, path): | |
2030 | if self.isdirty(path): |
|
2030 | if self.isdirty(path): | |
2031 | if self._cache[path]['exists']: |
|
2031 | if self._cache[path]['exists']: | |
2032 | return len(self._cache[path]['data']) |
|
2032 | return len(self._cache[path]['data']) | |
2033 | else: |
|
2033 | else: | |
2034 | raise error.ProgrammingError("No such file or directory: %s" % |
|
2034 | raise error.ProgrammingError("No such file or directory: %s" % | |
2035 | self._path) |
|
2035 | self._path) | |
2036 | return self._wrappedctx[path].size() |
|
2036 | return self._wrappedctx[path].size() | |
2037 |
|
2037 | |||
2038 | def tomemctx(self, text, branch=None, extra=None, date=None, parents=None, |
|
2038 | def tomemctx(self, text, branch=None, extra=None, date=None, parents=None, | |
2039 | user=None, editor=None): |
|
2039 | user=None, editor=None): | |
2040 | """Converts this ``overlayworkingctx`` into a ``memctx`` ready to be |
|
2040 | """Converts this ``overlayworkingctx`` into a ``memctx`` ready to be | |
2041 | committed. |
|
2041 | committed. | |
2042 |
|
2042 | |||
2043 | ``text`` is the commit message. |
|
2043 | ``text`` is the commit message. | |
2044 | ``parents`` (optional) are rev numbers. |
|
2044 | ``parents`` (optional) are rev numbers. | |
2045 | """ |
|
2045 | """ | |
2046 | # Default parents to the wrapped contexts' if not passed. |
|
2046 | # Default parents to the wrapped contexts' if not passed. | |
2047 | if parents is None: |
|
2047 | if parents is None: | |
2048 | parents = self._wrappedctx.parents() |
|
2048 | parents = self._wrappedctx.parents() | |
2049 | if len(parents) == 1: |
|
2049 | if len(parents) == 1: | |
2050 | parents = (parents[0], None) |
|
2050 | parents = (parents[0], None) | |
2051 |
|
2051 | |||
2052 | # ``parents`` is passed as rev numbers; convert to ``commitctxs``. |
|
2052 | # ``parents`` is passed as rev numbers; convert to ``commitctxs``. | |
2053 | if parents[1] is None: |
|
2053 | if parents[1] is None: | |
2054 | parents = (self._repo[parents[0]], None) |
|
2054 | parents = (self._repo[parents[0]], None) | |
2055 | else: |
|
2055 | else: | |
2056 | parents = (self._repo[parents[0]], self._repo[parents[1]]) |
|
2056 | parents = (self._repo[parents[0]], self._repo[parents[1]]) | |
2057 |
|
2057 | |||
2058 | files = self._cache.keys() |
|
2058 | files = self._cache.keys() | |
2059 | def getfile(repo, memctx, path): |
|
2059 | def getfile(repo, memctx, path): | |
2060 | if self._cache[path]['exists']: |
|
2060 | if self._cache[path]['exists']: | |
2061 | return memfilectx(repo, memctx, path, |
|
2061 | return memfilectx(repo, memctx, path, | |
2062 | self._cache[path]['data'], |
|
2062 | self._cache[path]['data'], | |
2063 | 'l' in self._cache[path]['flags'], |
|
2063 | 'l' in self._cache[path]['flags'], | |
2064 | 'x' in self._cache[path]['flags'], |
|
2064 | 'x' in self._cache[path]['flags'], | |
2065 | self._cache[path]['copied']) |
|
2065 | self._cache[path]['copied']) | |
2066 | else: |
|
2066 | else: | |
2067 | # Returning None, but including the path in `files`, is |
|
2067 | # Returning None, but including the path in `files`, is | |
2068 | # necessary for memctx to register a deletion. |
|
2068 | # necessary for memctx to register a deletion. | |
2069 | return None |
|
2069 | return None | |
2070 | return memctx(self._repo, parents, text, files, getfile, date=date, |
|
2070 | return memctx(self._repo, parents, text, files, getfile, date=date, | |
2071 | extra=extra, user=user, branch=branch, editor=editor) |
|
2071 | extra=extra, user=user, branch=branch, editor=editor) | |
2072 |
|
2072 | |||
2073 | def isdirty(self, path): |
|
2073 | def isdirty(self, path): | |
2074 | return path in self._cache |
|
2074 | return path in self._cache | |
2075 |
|
2075 | |||
2076 | def isempty(self): |
|
2076 | def isempty(self): | |
2077 | # We need to discard any keys that are actually clean before the empty |
|
2077 | # We need to discard any keys that are actually clean before the empty | |
2078 | # commit check. |
|
2078 | # commit check. | |
2079 | self._compact() |
|
2079 | self._compact() | |
2080 | return len(self._cache) == 0 |
|
2080 | return len(self._cache) == 0 | |
2081 |
|
2081 | |||
2082 | def clean(self): |
|
2082 | def clean(self): | |
2083 | self._cache = {} |
|
2083 | self._cache = {} | |
2084 |
|
2084 | |||
2085 | def _compact(self): |
|
2085 | def _compact(self): | |
2086 | """Removes keys from the cache that are actually clean, by comparing |
|
2086 | """Removes keys from the cache that are actually clean, by comparing | |
2087 | them with the underlying context. |
|
2087 | them with the underlying context. | |
2088 |
|
2088 | |||
2089 | This can occur during the merge process, e.g. by passing --tool :local |
|
2089 | This can occur during the merge process, e.g. by passing --tool :local | |
2090 | to resolve a conflict. |
|
2090 | to resolve a conflict. | |
2091 | """ |
|
2091 | """ | |
2092 | keys = [] |
|
2092 | keys = [] | |
2093 | # This won't be perfect, but can help performance significantly when |
|
2093 | # This won't be perfect, but can help performance significantly when | |
2094 | # using things like remotefilelog. |
|
2094 | # using things like remotefilelog. | |
2095 | scmutil.prefetchfiles( |
|
2095 | scmutil.prefetchfiles( | |
2096 | self.repo(), [self.p1().rev()], |
|
2096 | self.repo(), [self.p1().rev()], | |
2097 | scmutil.matchfiles(self.repo(), self._cache.keys())) |
|
2097 | scmutil.matchfiles(self.repo(), self._cache.keys())) | |
2098 |
|
2098 | |||
2099 | for path in self._cache.keys(): |
|
2099 | for path in self._cache.keys(): | |
2100 | cache = self._cache[path] |
|
2100 | cache = self._cache[path] | |
2101 | try: |
|
2101 | try: | |
2102 | underlying = self._wrappedctx[path] |
|
2102 | underlying = self._wrappedctx[path] | |
2103 | if (underlying.data() == cache['data'] and |
|
2103 | if (underlying.data() == cache['data'] and | |
2104 | underlying.flags() == cache['flags']): |
|
2104 | underlying.flags() == cache['flags']): | |
2105 | keys.append(path) |
|
2105 | keys.append(path) | |
2106 | except error.ManifestLookupError: |
|
2106 | except error.ManifestLookupError: | |
2107 | # Path not in the underlying manifest (created). |
|
2107 | # Path not in the underlying manifest (created). | |
2108 | continue |
|
2108 | continue | |
2109 |
|
2109 | |||
2110 | for path in keys: |
|
2110 | for path in keys: | |
2111 | del self._cache[path] |
|
2111 | del self._cache[path] | |
2112 | return keys |
|
2112 | return keys | |
2113 |
|
2113 | |||
2114 | def _markdirty(self, path, exists, data=None, date=None, flags='', |
|
2114 | def _markdirty(self, path, exists, data=None, date=None, flags='', | |
2115 | copied=None): |
|
2115 | copied=None): | |
2116 | # data not provided, let's see if we already have some; if not, let's |
|
2116 | # data not provided, let's see if we already have some; if not, let's | |
2117 | # grab it from our underlying context, so that we always have data if |
|
2117 | # grab it from our underlying context, so that we always have data if | |
2118 | # the file is marked as existing. |
|
2118 | # the file is marked as existing. | |
2119 | if exists and data is None: |
|
2119 | if exists and data is None: | |
2120 | oldentry = self._cache.get(path) or {} |
|
2120 | oldentry = self._cache.get(path) or {} | |
2121 | data = oldentry.get('data') or self._wrappedctx[path].data() |
|
2121 | data = oldentry.get('data') or self._wrappedctx[path].data() | |
2122 |
|
2122 | |||
2123 | self._cache[path] = { |
|
2123 | self._cache[path] = { | |
2124 | 'exists': exists, |
|
2124 | 'exists': exists, | |
2125 | 'data': data, |
|
2125 | 'data': data, | |
2126 | 'date': date, |
|
2126 | 'date': date, | |
2127 | 'flags': flags, |
|
2127 | 'flags': flags, | |
2128 | 'copied': copied, |
|
2128 | 'copied': copied, | |
2129 | } |
|
2129 | } | |
2130 |
|
2130 | |||
2131 | def filectx(self, path, filelog=None): |
|
2131 | def filectx(self, path, filelog=None): | |
2132 | return overlayworkingfilectx(self._repo, path, parent=self, |
|
2132 | return overlayworkingfilectx(self._repo, path, parent=self, | |
2133 | filelog=filelog) |
|
2133 | filelog=filelog) | |
2134 |
|
2134 | |||
2135 | class overlayworkingfilectx(committablefilectx): |
|
2135 | class overlayworkingfilectx(committablefilectx): | |
2136 | """Wrap a ``workingfilectx`` but intercepts all writes into an in-memory |
|
2136 | """Wrap a ``workingfilectx`` but intercepts all writes into an in-memory | |
2137 | cache, which can be flushed through later by calling ``flush()``.""" |
|
2137 | cache, which can be flushed through later by calling ``flush()``.""" | |
2138 |
|
2138 | |||
2139 | def __init__(self, repo, path, filelog=None, parent=None): |
|
2139 | def __init__(self, repo, path, filelog=None, parent=None): | |
2140 | super(overlayworkingfilectx, self).__init__(repo, path, filelog, |
|
2140 | super(overlayworkingfilectx, self).__init__(repo, path, filelog, | |
2141 | parent) |
|
2141 | parent) | |
2142 | self._repo = repo |
|
2142 | self._repo = repo | |
2143 | self._parent = parent |
|
2143 | self._parent = parent | |
2144 | self._path = path |
|
2144 | self._path = path | |
2145 |
|
2145 | |||
2146 | def cmp(self, fctx): |
|
2146 | def cmp(self, fctx): | |
2147 | return self.data() != fctx.data() |
|
2147 | return self.data() != fctx.data() | |
2148 |
|
2148 | |||
2149 | def changectx(self): |
|
2149 | def changectx(self): | |
2150 | return self._parent |
|
2150 | return self._parent | |
2151 |
|
2151 | |||
2152 | def data(self): |
|
2152 | def data(self): | |
2153 | return self._parent.data(self._path) |
|
2153 | return self._parent.data(self._path) | |
2154 |
|
2154 | |||
2155 | def date(self): |
|
2155 | def date(self): | |
2156 | return self._parent.filedate(self._path) |
|
2156 | return self._parent.filedate(self._path) | |
2157 |
|
2157 | |||
2158 | def exists(self): |
|
2158 | def exists(self): | |
2159 | return self.lexists() |
|
2159 | return self.lexists() | |
2160 |
|
2160 | |||
2161 | def lexists(self): |
|
2161 | def lexists(self): | |
2162 | return self._parent.exists(self._path) |
|
2162 | return self._parent.exists(self._path) | |
2163 |
|
2163 | |||
2164 | def copysource(self): |
|
2164 | def copysource(self): | |
2165 | return self._parent.copydata(self._path) |
|
2165 | return self._parent.copydata(self._path) | |
2166 |
|
2166 | |||
2167 | def size(self): |
|
2167 | def size(self): | |
2168 | return self._parent.size(self._path) |
|
2168 | return self._parent.size(self._path) | |
2169 |
|
2169 | |||
2170 | def markcopied(self, origin): |
|
2170 | def markcopied(self, origin): | |
2171 | self._parent.markcopied(self._path, origin) |
|
2171 | self._parent.markcopied(self._path, origin) | |
2172 |
|
2172 | |||
2173 | def audit(self): |
|
2173 | def audit(self): | |
2174 | pass |
|
2174 | pass | |
2175 |
|
2175 | |||
2176 | def flags(self): |
|
2176 | def flags(self): | |
2177 | return self._parent.flags(self._path) |
|
2177 | return self._parent.flags(self._path) | |
2178 |
|
2178 | |||
2179 | def setflags(self, islink, isexec): |
|
2179 | def setflags(self, islink, isexec): | |
2180 | return self._parent.setflags(self._path, islink, isexec) |
|
2180 | return self._parent.setflags(self._path, islink, isexec) | |
2181 |
|
2181 | |||
2182 | def write(self, data, flags, backgroundclose=False, **kwargs): |
|
2182 | def write(self, data, flags, backgroundclose=False, **kwargs): | |
2183 | return self._parent.write(self._path, data, flags, **kwargs) |
|
2183 | return self._parent.write(self._path, data, flags, **kwargs) | |
2184 |
|
2184 | |||
2185 | def remove(self, ignoremissing=False): |
|
2185 | def remove(self, ignoremissing=False): | |
2186 | return self._parent.remove(self._path) |
|
2186 | return self._parent.remove(self._path) | |
2187 |
|
2187 | |||
2188 | def clearunknown(self): |
|
2188 | def clearunknown(self): | |
2189 | pass |
|
2189 | pass | |
2190 |
|
2190 | |||
2191 | class workingcommitctx(workingctx): |
|
2191 | class workingcommitctx(workingctx): | |
2192 | """A workingcommitctx object makes access to data related to |
|
2192 | """A workingcommitctx object makes access to data related to | |
2193 | the revision being committed convenient. |
|
2193 | the revision being committed convenient. | |
2194 |
|
2194 | |||
2195 | This hides changes in the working directory, if they aren't |
|
2195 | This hides changes in the working directory, if they aren't | |
2196 | committed in this context. |
|
2196 | committed in this context. | |
2197 | """ |
|
2197 | """ | |
2198 | def __init__(self, repo, changes, |
|
2198 | def __init__(self, repo, changes, | |
2199 | text="", user=None, date=None, extra=None): |
|
2199 | text="", user=None, date=None, extra=None): | |
2200 | super(workingcommitctx, self).__init__(repo, text, user, date, extra, |
|
2200 | super(workingcommitctx, self).__init__(repo, text, user, date, extra, | |
2201 | changes) |
|
2201 | changes) | |
2202 |
|
2202 | |||
2203 | def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): |
|
2203 | def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): | |
2204 | """Return matched files only in ``self._status`` |
|
2204 | """Return matched files only in ``self._status`` | |
2205 |
|
2205 | |||
2206 | Uncommitted files appear "clean" via this context, even if |
|
2206 | Uncommitted files appear "clean" via this context, even if | |
2207 | they aren't actually so in the working directory. |
|
2207 | they aren't actually so in the working directory. | |
2208 | """ |
|
2208 | """ | |
2209 | if clean: |
|
2209 | if clean: | |
2210 | clean = [f for f in self._manifest if f not in self._changedset] |
|
2210 | clean = [f for f in self._manifest if f not in self._changedset] | |
2211 | else: |
|
2211 | else: | |
2212 | clean = [] |
|
2212 | clean = [] | |
2213 | return scmutil.status([f for f in self._status.modified if match(f)], |
|
2213 | return scmutil.status([f for f in self._status.modified if match(f)], | |
2214 | [f for f in self._status.added if match(f)], |
|
2214 | [f for f in self._status.added if match(f)], | |
2215 | [f for f in self._status.removed if match(f)], |
|
2215 | [f for f in self._status.removed if match(f)], | |
2216 | [], [], [], clean) |
|
2216 | [], [], [], clean) | |
2217 |
|
2217 | |||
2218 | @propertycache |
|
2218 | @propertycache | |
2219 | def _changedset(self): |
|
2219 | def _changedset(self): | |
2220 | """Return the set of files changed in this context |
|
2220 | """Return the set of files changed in this context | |
2221 | """ |
|
2221 | """ | |
2222 | changed = set(self._status.modified) |
|
2222 | changed = set(self._status.modified) | |
2223 | changed.update(self._status.added) |
|
2223 | changed.update(self._status.added) | |
2224 | changed.update(self._status.removed) |
|
2224 | changed.update(self._status.removed) | |
2225 | return changed |
|
2225 | return changed | |
2226 |
|
2226 | |||
2227 | def makecachingfilectxfn(func): |
|
2227 | def makecachingfilectxfn(func): | |
2228 | """Create a filectxfn that caches based on the path. |
|
2228 | """Create a filectxfn that caches based on the path. | |
2229 |
|
2229 | |||
2230 | We can't use util.cachefunc because it uses all arguments as the cache |
|
2230 | We can't use util.cachefunc because it uses all arguments as the cache | |
2231 | key and this creates a cycle since the arguments include the repo and |
|
2231 | key and this creates a cycle since the arguments include the repo and | |
2232 | memctx. |
|
2232 | memctx. | |
2233 | """ |
|
2233 | """ | |
2234 | cache = {} |
|
2234 | cache = {} | |
2235 |
|
2235 | |||
2236 | def getfilectx(repo, memctx, path): |
|
2236 | def getfilectx(repo, memctx, path): | |
2237 | if path not in cache: |
|
2237 | if path not in cache: | |
2238 | cache[path] = func(repo, memctx, path) |
|
2238 | cache[path] = func(repo, memctx, path) | |
2239 | return cache[path] |
|
2239 | return cache[path] | |
2240 |
|
2240 | |||
2241 | return getfilectx |
|
2241 | return getfilectx | |
2242 |
|
2242 | |||
2243 | def memfilefromctx(ctx): |
|
2243 | def memfilefromctx(ctx): | |
2244 | """Given a context return a memfilectx for ctx[path] |
|
2244 | """Given a context return a memfilectx for ctx[path] | |
2245 |
|
2245 | |||
2246 | This is a convenience method for building a memctx based on another |
|
2246 | This is a convenience method for building a memctx based on another | |
2247 | context. |
|
2247 | context. | |
2248 | """ |
|
2248 | """ | |
2249 | def getfilectx(repo, memctx, path): |
|
2249 | def getfilectx(repo, memctx, path): | |
2250 | fctx = ctx[path] |
|
2250 | fctx = ctx[path] | |
2251 | copysource = fctx.copysource() |
|
2251 | copysource = fctx.copysource() | |
2252 | return memfilectx(repo, memctx, path, fctx.data(), |
|
2252 | return memfilectx(repo, memctx, path, fctx.data(), | |
2253 | islink=fctx.islink(), isexec=fctx.isexec(), |
|
2253 | islink=fctx.islink(), isexec=fctx.isexec(), | |
2254 | copysource=copysource) |
|
2254 | copysource=copysource) | |
2255 |
|
2255 | |||
2256 | return getfilectx |
|
2256 | return getfilectx | |
2257 |
|
2257 | |||
2258 | def memfilefrompatch(patchstore): |
|
2258 | def memfilefrompatch(patchstore): | |
2259 | """Given a patch (e.g. patchstore object) return a memfilectx |
|
2259 | """Given a patch (e.g. patchstore object) return a memfilectx | |
2260 |
|
2260 | |||
2261 | This is a convenience method for building a memctx based on a patchstore. |
|
2261 | This is a convenience method for building a memctx based on a patchstore. | |
2262 | """ |
|
2262 | """ | |
2263 | def getfilectx(repo, memctx, path): |
|
2263 | def getfilectx(repo, memctx, path): | |
2264 | data, mode, copysource = patchstore.getfile(path) |
|
2264 | data, mode, copysource = patchstore.getfile(path) | |
2265 | if data is None: |
|
2265 | if data is None: | |
2266 | return None |
|
2266 | return None | |
2267 | islink, isexec = mode |
|
2267 | islink, isexec = mode | |
2268 | return memfilectx(repo, memctx, path, data, islink=islink, |
|
2268 | return memfilectx(repo, memctx, path, data, islink=islink, | |
2269 | isexec=isexec, copysource=copysource) |
|
2269 | isexec=isexec, copysource=copysource) | |
2270 |
|
2270 | |||
2271 | return getfilectx |
|
2271 | return getfilectx | |
2272 |
|
2272 | |||
2273 | class memctx(committablectx): |
|
2273 | class memctx(committablectx): | |
2274 | """Use memctx to perform in-memory commits via localrepo.commitctx(). |
|
2274 | """Use memctx to perform in-memory commits via localrepo.commitctx(). | |
2275 |
|
2275 | |||
2276 | Revision information is supplied at initialization time while |
|
2276 | Revision information is supplied at initialization time while | |
2277 | related files data and is made available through a callback |
|
2277 | related files data and is made available through a callback | |
2278 | mechanism. 'repo' is the current localrepo, 'parents' is a |
|
2278 | mechanism. 'repo' is the current localrepo, 'parents' is a | |
2279 | sequence of two parent revisions identifiers (pass None for every |
|
2279 | sequence of two parent revisions identifiers (pass None for every | |
2280 | missing parent), 'text' is the commit message and 'files' lists |
|
2280 | missing parent), 'text' is the commit message and 'files' lists | |
2281 | names of files touched by the revision (normalized and relative to |
|
2281 | names of files touched by the revision (normalized and relative to | |
2282 | repository root). |
|
2282 | repository root). | |
2283 |
|
2283 | |||
2284 | filectxfn(repo, memctx, path) is a callable receiving the |
|
2284 | filectxfn(repo, memctx, path) is a callable receiving the | |
2285 | repository, the current memctx object and the normalized path of |
|
2285 | repository, the current memctx object and the normalized path of | |
2286 | requested file, relative to repository root. It is fired by the |
|
2286 | requested file, relative to repository root. It is fired by the | |
2287 | commit function for every file in 'files', but calls order is |
|
2287 | commit function for every file in 'files', but calls order is | |
2288 | undefined. If the file is available in the revision being |
|
2288 | undefined. If the file is available in the revision being | |
2289 | committed (updated or added), filectxfn returns a memfilectx |
|
2289 | committed (updated or added), filectxfn returns a memfilectx | |
2290 | object. If the file was removed, filectxfn return None for recent |
|
2290 | object. If the file was removed, filectxfn return None for recent | |
2291 | Mercurial. Moved files are represented by marking the source file |
|
2291 | Mercurial. Moved files are represented by marking the source file | |
2292 | removed and the new file added with copy information (see |
|
2292 | removed and the new file added with copy information (see | |
2293 | memfilectx). |
|
2293 | memfilectx). | |
2294 |
|
2294 | |||
2295 | user receives the committer name and defaults to current |
|
2295 | user receives the committer name and defaults to current | |
2296 | repository username, date is the commit date in any format |
|
2296 | repository username, date is the commit date in any format | |
2297 | supported by dateutil.parsedate() and defaults to current date, extra |
|
2297 | supported by dateutil.parsedate() and defaults to current date, extra | |
2298 | is a dictionary of metadata or is left empty. |
|
2298 | is a dictionary of metadata or is left empty. | |
2299 | """ |
|
2299 | """ | |
2300 |
|
2300 | |||
2301 | # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files. |
|
2301 | # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files. | |
2302 | # Extensions that need to retain compatibility across Mercurial 3.1 can use |
|
2302 | # Extensions that need to retain compatibility across Mercurial 3.1 can use | |
2303 | # this field to determine what to do in filectxfn. |
|
2303 | # this field to determine what to do in filectxfn. | |
2304 | _returnnoneformissingfiles = True |
|
2304 | _returnnoneformissingfiles = True | |
2305 |
|
2305 | |||
2306 | def __init__(self, repo, parents, text, files, filectxfn, user=None, |
|
2306 | def __init__(self, repo, parents, text, files, filectxfn, user=None, | |
2307 | date=None, extra=None, branch=None, editor=False): |
|
2307 | date=None, extra=None, branch=None, editor=False): | |
2308 | super(memctx, self).__init__(repo, text, user, date, extra) |
|
2308 | super(memctx, self).__init__(repo, text, user, date, extra) | |
2309 | self._rev = None |
|
2309 | self._rev = None | |
2310 | self._node = None |
|
2310 | self._node = None | |
2311 | parents = [(p or nullid) for p in parents] |
|
2311 | parents = [(p or nullid) for p in parents] | |
2312 | p1, p2 = parents |
|
2312 | p1, p2 = parents | |
2313 | self._parents = [self._repo[p] for p in (p1, p2)] |
|
2313 | self._parents = [self._repo[p] for p in (p1, p2)] | |
2314 | files = sorted(set(files)) |
|
2314 | files = sorted(set(files)) | |
2315 | self._files = files |
|
2315 | self._files = files | |
2316 | if branch is not None: |
|
2316 | if branch is not None: | |
2317 | self._extra['branch'] = encoding.fromlocal(branch) |
|
2317 | self._extra['branch'] = encoding.fromlocal(branch) | |
2318 | self.substate = {} |
|
2318 | self.substate = {} | |
2319 |
|
2319 | |||
2320 | if isinstance(filectxfn, patch.filestore): |
|
2320 | if isinstance(filectxfn, patch.filestore): | |
2321 | filectxfn = memfilefrompatch(filectxfn) |
|
2321 | filectxfn = memfilefrompatch(filectxfn) | |
2322 | elif not callable(filectxfn): |
|
2322 | elif not callable(filectxfn): | |
2323 | # if store is not callable, wrap it in a function |
|
2323 | # if store is not callable, wrap it in a function | |
2324 | filectxfn = memfilefromctx(filectxfn) |
|
2324 | filectxfn = memfilefromctx(filectxfn) | |
2325 |
|
2325 | |||
2326 | # memoizing increases performance for e.g. vcs convert scenarios. |
|
2326 | # memoizing increases performance for e.g. vcs convert scenarios. | |
2327 | self._filectxfn = makecachingfilectxfn(filectxfn) |
|
2327 | self._filectxfn = makecachingfilectxfn(filectxfn) | |
2328 |
|
2328 | |||
2329 | if editor: |
|
2329 | if editor: | |
2330 | self._text = editor(self._repo, self, []) |
|
2330 | self._text = editor(self._repo, self, []) | |
2331 | self._repo.savecommitmessage(self._text) |
|
2331 | self._repo.savecommitmessage(self._text) | |
2332 |
|
2332 | |||
2333 | def filectx(self, path, filelog=None): |
|
2333 | def filectx(self, path, filelog=None): | |
2334 | """get a file context from the working directory |
|
2334 | """get a file context from the working directory | |
2335 |
|
2335 | |||
2336 | Returns None if file doesn't exist and should be removed.""" |
|
2336 | Returns None if file doesn't exist and should be removed.""" | |
2337 | return self._filectxfn(self._repo, self, path) |
|
2337 | return self._filectxfn(self._repo, self, path) | |
2338 |
|
2338 | |||
2339 | def commit(self): |
|
2339 | def commit(self): | |
2340 | """commit context to the repo""" |
|
2340 | """commit context to the repo""" | |
2341 | return self._repo.commitctx(self) |
|
2341 | return self._repo.commitctx(self) | |
2342 |
|
2342 | |||
2343 | @propertycache |
|
2343 | @propertycache | |
2344 | def _manifest(self): |
|
2344 | def _manifest(self): | |
2345 | """generate a manifest based on the return values of filectxfn""" |
|
2345 | """generate a manifest based on the return values of filectxfn""" | |
2346 |
|
2346 | |||
2347 | # keep this simple for now; just worry about p1 |
|
2347 | # keep this simple for now; just worry about p1 | |
2348 | pctx = self._parents[0] |
|
2348 | pctx = self._parents[0] | |
2349 | man = pctx.manifest().copy() |
|
2349 | man = pctx.manifest().copy() | |
2350 |
|
2350 | |||
2351 | for f in self._status.modified: |
|
2351 | for f in self._status.modified: | |
2352 | man[f] = modifiednodeid |
|
2352 | man[f] = modifiednodeid | |
2353 |
|
2353 | |||
2354 | for f in self._status.added: |
|
2354 | for f in self._status.added: | |
2355 | man[f] = addednodeid |
|
2355 | man[f] = addednodeid | |
2356 |
|
2356 | |||
2357 | for f in self._status.removed: |
|
2357 | for f in self._status.removed: | |
2358 | if f in man: |
|
2358 | if f in man: | |
2359 | del man[f] |
|
2359 | del man[f] | |
2360 |
|
2360 | |||
2361 | return man |
|
2361 | return man | |
2362 |
|
2362 | |||
2363 | @propertycache |
|
2363 | @propertycache | |
2364 | def _status(self): |
|
2364 | def _status(self): | |
2365 | """Calculate exact status from ``files`` specified at construction |
|
2365 | """Calculate exact status from ``files`` specified at construction | |
2366 | """ |
|
2366 | """ | |
2367 | man1 = self.p1().manifest() |
|
2367 | man1 = self.p1().manifest() | |
2368 | p2 = self._parents[1] |
|
2368 | p2 = self._parents[1] | |
2369 | # "1 < len(self._parents)" can't be used for checking |
|
2369 | # "1 < len(self._parents)" can't be used for checking | |
2370 | # existence of the 2nd parent, because "memctx._parents" is |
|
2370 | # existence of the 2nd parent, because "memctx._parents" is | |
2371 | # explicitly initialized by the list, of which length is 2. |
|
2371 | # explicitly initialized by the list, of which length is 2. | |
2372 | if p2.node() != nullid: |
|
2372 | if p2.node() != nullid: | |
2373 | man2 = p2.manifest() |
|
2373 | man2 = p2.manifest() | |
2374 | managing = lambda f: f in man1 or f in man2 |
|
2374 | managing = lambda f: f in man1 or f in man2 | |
2375 | else: |
|
2375 | else: | |
2376 | managing = lambda f: f in man1 |
|
2376 | managing = lambda f: f in man1 | |
2377 |
|
2377 | |||
2378 | modified, added, removed = [], [], [] |
|
2378 | modified, added, removed = [], [], [] | |
2379 | for f in self._files: |
|
2379 | for f in self._files: | |
2380 | if not managing(f): |
|
2380 | if not managing(f): | |
2381 | added.append(f) |
|
2381 | added.append(f) | |
2382 | elif self[f]: |
|
2382 | elif self[f]: | |
2383 | modified.append(f) |
|
2383 | modified.append(f) | |
2384 | else: |
|
2384 | else: | |
2385 | removed.append(f) |
|
2385 | removed.append(f) | |
2386 |
|
2386 | |||
2387 | return scmutil.status(modified, added, removed, [], [], [], []) |
|
2387 | return scmutil.status(modified, added, removed, [], [], [], []) | |
2388 |
|
2388 | |||
2389 | class memfilectx(committablefilectx): |
|
2389 | class memfilectx(committablefilectx): | |
2390 | """memfilectx represents an in-memory file to commit. |
|
2390 | """memfilectx represents an in-memory file to commit. | |
2391 |
|
2391 | |||
2392 | See memctx and committablefilectx for more details. |
|
2392 | See memctx and committablefilectx for more details. | |
2393 | """ |
|
2393 | """ | |
2394 | def __init__(self, repo, changectx, path, data, islink=False, |
|
2394 | def __init__(self, repo, changectx, path, data, islink=False, | |
2395 | isexec=False, copysource=None): |
|
2395 | isexec=False, copysource=None): | |
2396 | """ |
|
2396 | """ | |
2397 | path is the normalized file path relative to repository root. |
|
2397 | path is the normalized file path relative to repository root. | |
2398 | data is the file content as a string. |
|
2398 | data is the file content as a string. | |
2399 | islink is True if the file is a symbolic link. |
|
2399 | islink is True if the file is a symbolic link. | |
2400 | isexec is True if the file is executable. |
|
2400 | isexec is True if the file is executable. | |
2401 | copied is the source file path if current file was copied in the |
|
2401 | copied is the source file path if current file was copied in the | |
2402 | revision being committed, or None.""" |
|
2402 | revision being committed, or None.""" | |
2403 | super(memfilectx, self).__init__(repo, path, None, changectx) |
|
2403 | super(memfilectx, self).__init__(repo, path, None, changectx) | |
2404 | self._data = data |
|
2404 | self._data = data | |
2405 | if islink: |
|
2405 | if islink: | |
2406 | self._flags = 'l' |
|
2406 | self._flags = 'l' | |
2407 | elif isexec: |
|
2407 | elif isexec: | |
2408 | self._flags = 'x' |
|
2408 | self._flags = 'x' | |
2409 | else: |
|
2409 | else: | |
2410 | self._flags = '' |
|
2410 | self._flags = '' | |
2411 | self._copysource = copysource |
|
2411 | self._copysource = copysource | |
2412 |
|
2412 | |||
2413 | def copysource(self): |
|
2413 | def copysource(self): | |
2414 | return self._copysource |
|
2414 | return self._copysource | |
2415 |
|
2415 | |||
2416 | def cmp(self, fctx): |
|
2416 | def cmp(self, fctx): | |
2417 | return self.data() != fctx.data() |
|
2417 | return self.data() != fctx.data() | |
2418 |
|
2418 | |||
2419 | def data(self): |
|
2419 | def data(self): | |
2420 | return self._data |
|
2420 | return self._data | |
2421 |
|
2421 | |||
2422 | def remove(self, ignoremissing=False): |
|
2422 | def remove(self, ignoremissing=False): | |
2423 | """wraps unlink for a repo's working directory""" |
|
2423 | """wraps unlink for a repo's working directory""" | |
2424 | # need to figure out what to do here |
|
2424 | # need to figure out what to do here | |
2425 | del self._changectx[self._path] |
|
2425 | del self._changectx[self._path] | |
2426 |
|
2426 | |||
2427 | def write(self, data, flags, **kwargs): |
|
2427 | def write(self, data, flags, **kwargs): | |
2428 | """wraps repo.wwrite""" |
|
2428 | """wraps repo.wwrite""" | |
2429 | self._data = data |
|
2429 | self._data = data | |
2430 |
|
2430 | |||
2431 |
|
2431 | |||
2432 | class metadataonlyctx(committablectx): |
|
2432 | class metadataonlyctx(committablectx): | |
2433 | """Like memctx but it's reusing the manifest of different commit. |
|
2433 | """Like memctx but it's reusing the manifest of different commit. | |
2434 | Intended to be used by lightweight operations that are creating |
|
2434 | Intended to be used by lightweight operations that are creating | |
2435 | metadata-only changes. |
|
2435 | metadata-only changes. | |
2436 |
|
2436 | |||
2437 | Revision information is supplied at initialization time. 'repo' is the |
|
2437 | Revision information is supplied at initialization time. 'repo' is the | |
2438 | current localrepo, 'ctx' is original revision which manifest we're reuisng |
|
2438 | current localrepo, 'ctx' is original revision which manifest we're reuisng | |
2439 | 'parents' is a sequence of two parent revisions identifiers (pass None for |
|
2439 | 'parents' is a sequence of two parent revisions identifiers (pass None for | |
2440 | every missing parent), 'text' is the commit. |
|
2440 | every missing parent), 'text' is the commit. | |
2441 |
|
2441 | |||
2442 | user receives the committer name and defaults to current repository |
|
2442 | user receives the committer name and defaults to current repository | |
2443 | username, date is the commit date in any format supported by |
|
2443 | username, date is the commit date in any format supported by | |
2444 | dateutil.parsedate() and defaults to current date, extra is a dictionary of |
|
2444 | dateutil.parsedate() and defaults to current date, extra is a dictionary of | |
2445 | metadata or is left empty. |
|
2445 | metadata or is left empty. | |
2446 | """ |
|
2446 | """ | |
2447 | def __init__(self, repo, originalctx, parents=None, text=None, user=None, |
|
2447 | def __init__(self, repo, originalctx, parents=None, text=None, user=None, | |
2448 | date=None, extra=None, editor=False): |
|
2448 | date=None, extra=None, editor=False): | |
2449 | if text is None: |
|
2449 | if text is None: | |
2450 | text = originalctx.description() |
|
2450 | text = originalctx.description() | |
2451 | super(metadataonlyctx, self).__init__(repo, text, user, date, extra) |
|
2451 | super(metadataonlyctx, self).__init__(repo, text, user, date, extra) | |
2452 | self._rev = None |
|
2452 | self._rev = None | |
2453 | self._node = None |
|
2453 | self._node = None | |
2454 | self._originalctx = originalctx |
|
2454 | self._originalctx = originalctx | |
2455 | self._manifestnode = originalctx.manifestnode() |
|
2455 | self._manifestnode = originalctx.manifestnode() | |
2456 | if parents is None: |
|
2456 | if parents is None: | |
2457 | parents = originalctx.parents() |
|
2457 | parents = originalctx.parents() | |
2458 | else: |
|
2458 | else: | |
2459 | parents = [repo[p] for p in parents if p is not None] |
|
2459 | parents = [repo[p] for p in parents if p is not None] | |
2460 | parents = parents[:] |
|
2460 | parents = parents[:] | |
2461 | while len(parents) < 2: |
|
2461 | while len(parents) < 2: | |
2462 | parents.append(repo[nullid]) |
|
2462 | parents.append(repo[nullid]) | |
2463 | p1, p2 = self._parents = parents |
|
2463 | p1, p2 = self._parents = parents | |
2464 |
|
2464 | |||
2465 | # sanity check to ensure that the reused manifest parents are |
|
2465 | # sanity check to ensure that the reused manifest parents are | |
2466 | # manifests of our commit parents |
|
2466 | # manifests of our commit parents | |
2467 | mp1, mp2 = self.manifestctx().parents |
|
2467 | mp1, mp2 = self.manifestctx().parents | |
2468 | if p1 != nullid and p1.manifestnode() != mp1: |
|
2468 | if p1 != nullid and p1.manifestnode() != mp1: | |
2469 | raise RuntimeError(r"can't reuse the manifest: its p1 " |
|
2469 | raise RuntimeError(r"can't reuse the manifest: its p1 " | |
2470 | r"doesn't match the new ctx p1") |
|
2470 | r"doesn't match the new ctx p1") | |
2471 | if p2 != nullid and p2.manifestnode() != mp2: |
|
2471 | if p2 != nullid and p2.manifestnode() != mp2: | |
2472 | raise RuntimeError(r"can't reuse the manifest: " |
|
2472 | raise RuntimeError(r"can't reuse the manifest: " | |
2473 | r"its p2 doesn't match the new ctx p2") |
|
2473 | r"its p2 doesn't match the new ctx p2") | |
2474 |
|
2474 | |||
2475 | self._files = originalctx.files() |
|
2475 | self._files = originalctx.files() | |
2476 | self.substate = {} |
|
2476 | self.substate = {} | |
2477 |
|
2477 | |||
2478 | if editor: |
|
2478 | if editor: | |
2479 | self._text = editor(self._repo, self, []) |
|
2479 | self._text = editor(self._repo, self, []) | |
2480 | self._repo.savecommitmessage(self._text) |
|
2480 | self._repo.savecommitmessage(self._text) | |
2481 |
|
2481 | |||
2482 | def manifestnode(self): |
|
2482 | def manifestnode(self): | |
2483 | return self._manifestnode |
|
2483 | return self._manifestnode | |
2484 |
|
2484 | |||
2485 | @property |
|
2485 | @property | |
2486 | def _manifestctx(self): |
|
2486 | def _manifestctx(self): | |
2487 | return self._repo.manifestlog[self._manifestnode] |
|
2487 | return self._repo.manifestlog[self._manifestnode] | |
2488 |
|
2488 | |||
2489 | def filectx(self, path, filelog=None): |
|
2489 | def filectx(self, path, filelog=None): | |
2490 | return self._originalctx.filectx(path, filelog=filelog) |
|
2490 | return self._originalctx.filectx(path, filelog=filelog) | |
2491 |
|
2491 | |||
2492 | def commit(self): |
|
2492 | def commit(self): | |
2493 | """commit context to the repo""" |
|
2493 | """commit context to the repo""" | |
2494 | return self._repo.commitctx(self) |
|
2494 | return self._repo.commitctx(self) | |
2495 |
|
2495 | |||
2496 | @property |
|
2496 | @property | |
2497 | def _manifest(self): |
|
2497 | def _manifest(self): | |
2498 | return self._originalctx.manifest() |
|
2498 | return self._originalctx.manifest() | |
2499 |
|
2499 | |||
2500 | @propertycache |
|
2500 | @propertycache | |
2501 | def _status(self): |
|
2501 | def _status(self): | |
2502 | """Calculate exact status from ``files`` specified in the ``origctx`` |
|
2502 | """Calculate exact status from ``files`` specified in the ``origctx`` | |
2503 | and parents manifests. |
|
2503 | and parents manifests. | |
2504 | """ |
|
2504 | """ | |
2505 | man1 = self.p1().manifest() |
|
2505 | man1 = self.p1().manifest() | |
2506 | p2 = self._parents[1] |
|
2506 | p2 = self._parents[1] | |
2507 | # "1 < len(self._parents)" can't be used for checking |
|
2507 | # "1 < len(self._parents)" can't be used for checking | |
2508 | # existence of the 2nd parent, because "metadataonlyctx._parents" is |
|
2508 | # existence of the 2nd parent, because "metadataonlyctx._parents" is | |
2509 | # explicitly initialized by the list, of which length is 2. |
|
2509 | # explicitly initialized by the list, of which length is 2. | |
2510 | if p2.node() != nullid: |
|
2510 | if p2.node() != nullid: | |
2511 | man2 = p2.manifest() |
|
2511 | man2 = p2.manifest() | |
2512 | managing = lambda f: f in man1 or f in man2 |
|
2512 | managing = lambda f: f in man1 or f in man2 | |
2513 | else: |
|
2513 | else: | |
2514 | managing = lambda f: f in man1 |
|
2514 | managing = lambda f: f in man1 | |
2515 |
|
2515 | |||
2516 | modified, added, removed = [], [], [] |
|
2516 | modified, added, removed = [], [], [] | |
2517 | for f in self._files: |
|
2517 | for f in self._files: | |
2518 | if not managing(f): |
|
2518 | if not managing(f): | |
2519 | added.append(f) |
|
2519 | added.append(f) | |
2520 | elif f in self: |
|
2520 | elif f in self: | |
2521 | modified.append(f) |
|
2521 | modified.append(f) | |
2522 | else: |
|
2522 | else: | |
2523 | removed.append(f) |
|
2523 | removed.append(f) | |
2524 |
|
2524 | |||
2525 | return scmutil.status(modified, added, removed, [], [], [], []) |
|
2525 | return scmutil.status(modified, added, removed, [], [], [], []) | |
2526 |
|
2526 | |||
2527 | class arbitraryfilectx(object): |
|
2527 | class arbitraryfilectx(object): | |
2528 | """Allows you to use filectx-like functions on a file in an arbitrary |
|
2528 | """Allows you to use filectx-like functions on a file in an arbitrary | |
2529 | location on disk, possibly not in the working directory. |
|
2529 | location on disk, possibly not in the working directory. | |
2530 | """ |
|
2530 | """ | |
2531 | def __init__(self, path, repo=None): |
|
2531 | def __init__(self, path, repo=None): | |
2532 | # Repo is optional because contrib/simplemerge uses this class. |
|
2532 | # Repo is optional because contrib/simplemerge uses this class. | |
2533 | self._repo = repo |
|
2533 | self._repo = repo | |
2534 | self._path = path |
|
2534 | self._path = path | |
2535 |
|
2535 | |||
2536 | def cmp(self, fctx): |
|
2536 | def cmp(self, fctx): | |
2537 | # filecmp follows symlinks whereas `cmp` should not, so skip the fast |
|
2537 | # filecmp follows symlinks whereas `cmp` should not, so skip the fast | |
2538 | # path if either side is a symlink. |
|
2538 | # path if either side is a symlink. | |
2539 | symlinks = ('l' in self.flags() or 'l' in fctx.flags()) |
|
2539 | symlinks = ('l' in self.flags() or 'l' in fctx.flags()) | |
2540 | if not symlinks and isinstance(fctx, workingfilectx) and self._repo: |
|
2540 | if not symlinks and isinstance(fctx, workingfilectx) and self._repo: | |
2541 | # Add a fast-path for merge if both sides are disk-backed. |
|
2541 | # Add a fast-path for merge if both sides are disk-backed. | |
2542 | # Note that filecmp uses the opposite return values (True if same) |
|
2542 | # Note that filecmp uses the opposite return values (True if same) | |
2543 | # from our cmp functions (True if different). |
|
2543 | # from our cmp functions (True if different). | |
2544 | return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path())) |
|
2544 | return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path())) | |
2545 | return self.data() != fctx.data() |
|
2545 | return self.data() != fctx.data() | |
2546 |
|
2546 | |||
2547 | def path(self): |
|
2547 | def path(self): | |
2548 | return self._path |
|
2548 | return self._path | |
2549 |
|
2549 | |||
2550 | def flags(self): |
|
2550 | def flags(self): | |
2551 | return '' |
|
2551 | return '' | |
2552 |
|
2552 | |||
2553 | def data(self): |
|
2553 | def data(self): | |
2554 | return util.readfile(self._path) |
|
2554 | return util.readfile(self._path) | |
2555 |
|
2555 | |||
2556 | def decodeddata(self): |
|
2556 | def decodeddata(self): | |
2557 | with open(self._path, "rb") as f: |
|
2557 | with open(self._path, "rb") as f: | |
2558 | return f.read() |
|
2558 | return f.read() | |
2559 |
|
2559 | |||
2560 | def remove(self): |
|
2560 | def remove(self): | |
2561 | util.unlink(self._path) |
|
2561 | util.unlink(self._path) | |
2562 |
|
2562 | |||
2563 | def write(self, data, flags, **kwargs): |
|
2563 | def write(self, data, flags, **kwargs): | |
2564 | assert not flags |
|
2564 | assert not flags | |
2565 | with open(self._path, "wb") as f: |
|
2565 | with open(self._path, "wb") as f: | |
2566 | f.write(data) |
|
2566 | f.write(data) |
@@ -1,820 +1,826 b'' | |||||
1 | #require symlink execbit |
|
1 | #require symlink execbit | |
2 | $ cat << EOF >> $HGRCPATH |
|
2 | $ cat << EOF >> $HGRCPATH | |
3 | > [phases] |
|
3 | > [phases] | |
4 | > publish=False |
|
4 | > publish=False | |
5 | > [extensions] |
|
5 | > [extensions] | |
6 | > amend= |
|
6 | > amend= | |
7 | > rebase= |
|
7 | > rebase= | |
8 | > debugdrawdag=$TESTDIR/drawdag.py |
|
8 | > debugdrawdag=$TESTDIR/drawdag.py | |
9 | > strip= |
|
9 | > strip= | |
10 | > [rebase] |
|
10 | > [rebase] | |
11 | > experimental.inmemory=1 |
|
11 | > experimental.inmemory=1 | |
12 | > [diff] |
|
12 | > [diff] | |
13 | > git=1 |
|
13 | > git=1 | |
14 | > [alias] |
|
14 | > [alias] | |
15 | > tglog = log -G --template "{rev}: {node|short} '{desc}'\n" |
|
15 | > tglog = log -G --template "{rev}: {node|short} '{desc}'\n" | |
16 | > EOF |
|
16 | > EOF | |
17 |
|
17 | |||
18 | Rebase a simple DAG: |
|
18 | Rebase a simple DAG: | |
19 | $ hg init repo1 |
|
19 | $ hg init repo1 | |
20 | $ cd repo1 |
|
20 | $ cd repo1 | |
21 | $ hg debugdrawdag <<'EOS' |
|
21 | $ hg debugdrawdag <<'EOS' | |
22 | > c b |
|
22 | > c b | |
23 | > |/ |
|
23 | > |/ | |
24 | > d |
|
24 | > d | |
25 | > | |
|
25 | > | | |
26 | > a |
|
26 | > a | |
27 | > EOS |
|
27 | > EOS | |
28 | $ hg up -C a |
|
28 | $ hg up -C a | |
29 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
29 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
30 | $ hg tglog |
|
30 | $ hg tglog | |
31 | o 3: 814f6bd05178 'c' |
|
31 | o 3: 814f6bd05178 'c' | |
32 | | |
|
32 | | | |
33 | | o 2: db0e82a16a62 'b' |
|
33 | | o 2: db0e82a16a62 'b' | |
34 | |/ |
|
34 | |/ | |
35 | o 1: 02952614a83d 'd' |
|
35 | o 1: 02952614a83d 'd' | |
36 | | |
|
36 | | | |
37 | @ 0: b173517d0057 'a' |
|
37 | @ 0: b173517d0057 'a' | |
38 |
|
38 | |||
39 | $ hg cat -r 3 c |
|
39 | $ hg cat -r 3 c | |
40 | c (no-eol) |
|
40 | c (no-eol) | |
41 | $ hg cat -r 2 b |
|
41 | $ hg cat -r 2 b | |
42 | b (no-eol) |
|
42 | b (no-eol) | |
43 | $ hg rebase --debug -r b -d c | grep rebasing |
|
43 | $ hg rebase --debug -r b -d c | grep rebasing | |
44 | rebasing in-memory |
|
44 | rebasing in-memory | |
45 | rebasing 2:db0e82a16a62 "b" (b) |
|
45 | rebasing 2:db0e82a16a62 "b" (b) | |
46 | $ hg tglog |
|
46 | $ hg tglog | |
47 | o 3: ca58782ad1e4 'b' |
|
47 | o 3: ca58782ad1e4 'b' | |
48 | | |
|
48 | | | |
49 | o 2: 814f6bd05178 'c' |
|
49 | o 2: 814f6bd05178 'c' | |
50 | | |
|
50 | | | |
51 | o 1: 02952614a83d 'd' |
|
51 | o 1: 02952614a83d 'd' | |
52 | | |
|
52 | | | |
53 | @ 0: b173517d0057 'a' |
|
53 | @ 0: b173517d0057 'a' | |
54 |
|
54 | |||
55 | $ hg cat -r 3 b |
|
55 | $ hg cat -r 3 b | |
56 | b (no-eol) |
|
56 | b (no-eol) | |
57 | $ hg cat -r 2 c |
|
57 | $ hg cat -r 2 c | |
58 | c (no-eol) |
|
58 | c (no-eol) | |
59 | $ cd .. |
|
59 | $ cd .. | |
60 |
|
60 | |||
61 | Case 2: |
|
61 | Case 2: | |
62 | $ hg init repo2 |
|
62 | $ hg init repo2 | |
63 | $ cd repo2 |
|
63 | $ cd repo2 | |
64 | $ hg debugdrawdag <<'EOS' |
|
64 | $ hg debugdrawdag <<'EOS' | |
65 | > c b |
|
65 | > c b | |
66 | > |/ |
|
66 | > |/ | |
67 | > d |
|
67 | > d | |
68 | > | |
|
68 | > | | |
69 | > a |
|
69 | > a | |
70 | > EOS |
|
70 | > EOS | |
71 |
|
71 | |||
72 | Add a symlink and executable file: |
|
72 | Add a symlink and executable file: | |
73 | $ hg up -C c |
|
73 | $ hg up -C c | |
74 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
74 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
75 | $ ln -s somefile e |
|
75 | $ ln -s somefile e | |
76 | $ echo f > f |
|
76 | $ echo f > f | |
77 | $ chmod +x f |
|
77 | $ chmod +x f | |
78 | $ hg add e f |
|
78 | $ hg add e f | |
79 | $ hg amend -q |
|
79 | $ hg amend -q | |
80 | $ hg up -Cq a |
|
80 | $ hg up -Cq a | |
81 |
|
81 | |||
82 | Write files to the working copy, and ensure they're still there after the rebase |
|
82 | Write files to the working copy, and ensure they're still there after the rebase | |
83 | $ echo "abc" > a |
|
83 | $ echo "abc" > a | |
84 | $ ln -s def b |
|
84 | $ ln -s def b | |
85 | $ echo "ghi" > c |
|
85 | $ echo "ghi" > c | |
86 | $ echo "jkl" > d |
|
86 | $ echo "jkl" > d | |
87 | $ echo "mno" > e |
|
87 | $ echo "mno" > e | |
88 | $ hg tglog |
|
88 | $ hg tglog | |
89 | o 3: f56b71190a8f 'c' |
|
89 | o 3: f56b71190a8f 'c' | |
90 | | |
|
90 | | | |
91 | | o 2: db0e82a16a62 'b' |
|
91 | | o 2: db0e82a16a62 'b' | |
92 | |/ |
|
92 | |/ | |
93 | o 1: 02952614a83d 'd' |
|
93 | o 1: 02952614a83d 'd' | |
94 | | |
|
94 | | | |
95 | @ 0: b173517d0057 'a' |
|
95 | @ 0: b173517d0057 'a' | |
96 |
|
96 | |||
97 | $ hg cat -r 3 c |
|
97 | $ hg cat -r 3 c | |
98 | c (no-eol) |
|
98 | c (no-eol) | |
99 | $ hg cat -r 2 b |
|
99 | $ hg cat -r 2 b | |
100 | b (no-eol) |
|
100 | b (no-eol) | |
101 | $ hg cat -r 3 e |
|
101 | $ hg cat -r 3 e | |
102 | somefile (no-eol) |
|
102 | somefile (no-eol) | |
103 | $ hg rebase --debug -s b -d a | grep rebasing |
|
103 | $ hg rebase --debug -s b -d a | grep rebasing | |
104 | rebasing in-memory |
|
104 | rebasing in-memory | |
105 | rebasing 2:db0e82a16a62 "b" (b) |
|
105 | rebasing 2:db0e82a16a62 "b" (b) | |
106 | $ hg tglog |
|
106 | $ hg tglog | |
107 | o 3: fc055c3b4d33 'b' |
|
107 | o 3: fc055c3b4d33 'b' | |
108 | | |
|
108 | | | |
109 | | o 2: f56b71190a8f 'c' |
|
109 | | o 2: f56b71190a8f 'c' | |
110 | | | |
|
110 | | | | |
111 | | o 1: 02952614a83d 'd' |
|
111 | | o 1: 02952614a83d 'd' | |
112 | |/ |
|
112 | |/ | |
113 | @ 0: b173517d0057 'a' |
|
113 | @ 0: b173517d0057 'a' | |
114 |
|
114 | |||
115 | $ hg cat -r 2 c |
|
115 | $ hg cat -r 2 c | |
116 | c (no-eol) |
|
116 | c (no-eol) | |
117 | $ hg cat -r 3 b |
|
117 | $ hg cat -r 3 b | |
118 | b (no-eol) |
|
118 | b (no-eol) | |
119 | $ hg rebase --debug -s 1 -d 3 | grep rebasing |
|
119 | $ hg rebase --debug -s 1 -d 3 | grep rebasing | |
120 | rebasing in-memory |
|
120 | rebasing in-memory | |
121 | rebasing 1:02952614a83d "d" (d) |
|
121 | rebasing 1:02952614a83d "d" (d) | |
122 | rebasing 2:f56b71190a8f "c" |
|
122 | rebasing 2:f56b71190a8f "c" | |
123 | $ hg tglog |
|
123 | $ hg tglog | |
124 | o 3: 753feb6fd12a 'c' |
|
124 | o 3: 753feb6fd12a 'c' | |
125 | | |
|
125 | | | |
126 | o 2: 09c044d2cb43 'd' |
|
126 | o 2: 09c044d2cb43 'd' | |
127 | | |
|
127 | | | |
128 | o 1: fc055c3b4d33 'b' |
|
128 | o 1: fc055c3b4d33 'b' | |
129 | | |
|
129 | | | |
130 | @ 0: b173517d0057 'a' |
|
130 | @ 0: b173517d0057 'a' | |
131 |
|
131 | |||
132 | Ensure working copy files are still there: |
|
132 | Ensure working copy files are still there: | |
133 | $ cat a |
|
133 | $ cat a | |
134 | abc |
|
134 | abc | |
135 | $ readlink.py b |
|
135 | $ readlink.py b | |
136 | b -> def |
|
136 | b -> def | |
137 | $ cat e |
|
137 | $ cat e | |
138 | mno |
|
138 | mno | |
139 |
|
139 | |||
140 | Ensure symlink and executable files were rebased properly: |
|
140 | Ensure symlink and executable files were rebased properly: | |
141 | $ hg up -Cq 3 |
|
141 | $ hg up -Cq 3 | |
142 | $ readlink.py e |
|
142 | $ readlink.py e | |
143 | e -> somefile |
|
143 | e -> somefile | |
144 | $ ls -l f | cut -c -10 |
|
144 | $ ls -l f | cut -c -10 | |
145 | -rwxr-xr-x |
|
145 | -rwxr-xr-x | |
146 |
|
146 | |||
147 | Rebase the working copy parent |
|
147 | Rebase the working copy parent | |
148 | $ hg up -C 3 |
|
148 | $ hg up -C 3 | |
149 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
149 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
150 | $ hg rebase -r 3 -d 0 --debug | grep rebasing |
|
150 | $ hg rebase -r 3 -d 0 --debug | grep rebasing | |
151 | rebasing in-memory |
|
151 | rebasing in-memory | |
152 | rebasing 3:753feb6fd12a "c" (tip) |
|
152 | rebasing 3:753feb6fd12a "c" (tip) | |
153 | $ hg tglog |
|
153 | $ hg tglog | |
154 | @ 3: 844a7de3e617 'c' |
|
154 | @ 3: 844a7de3e617 'c' | |
155 | | |
|
155 | | | |
156 | | o 2: 09c044d2cb43 'd' |
|
156 | | o 2: 09c044d2cb43 'd' | |
157 | | | |
|
157 | | | | |
158 | | o 1: fc055c3b4d33 'b' |
|
158 | | o 1: fc055c3b4d33 'b' | |
159 | |/ |
|
159 | |/ | |
160 | o 0: b173517d0057 'a' |
|
160 | o 0: b173517d0057 'a' | |
161 |
|
161 | |||
162 |
|
162 | |||
163 | Test reporting of path conflicts |
|
163 | Test reporting of path conflicts | |
164 |
|
164 | |||
165 | $ hg rm a |
|
165 | $ hg rm a | |
166 | $ mkdir a |
|
166 | $ mkdir a | |
167 | $ touch a/a |
|
167 | $ touch a/a | |
168 | $ hg ci -Am "a/a" |
|
168 | $ hg ci -Am "a/a" | |
169 | adding a/a |
|
169 | adding a/a | |
170 | $ hg tglog |
|
170 | $ hg tglog | |
171 | @ 4: daf7dfc139cb 'a/a' |
|
171 | @ 4: daf7dfc139cb 'a/a' | |
172 | | |
|
172 | | | |
173 | o 3: 844a7de3e617 'c' |
|
173 | o 3: 844a7de3e617 'c' | |
174 | | |
|
174 | | | |
175 | | o 2: 09c044d2cb43 'd' |
|
175 | | o 2: 09c044d2cb43 'd' | |
176 | | | |
|
176 | | | | |
177 | | o 1: fc055c3b4d33 'b' |
|
177 | | o 1: fc055c3b4d33 'b' | |
178 | |/ |
|
178 | |/ | |
179 | o 0: b173517d0057 'a' |
|
179 | o 0: b173517d0057 'a' | |
180 |
|
180 | |||
181 | $ hg rebase -r . -d 2 |
|
181 | $ hg rebase -r . -d 2 | |
182 | rebasing 4:daf7dfc139cb "a/a" (tip) |
|
182 | rebasing 4:daf7dfc139cb "a/a" (tip) | |
183 | saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/daf7dfc139cb-fdbfcf4f-rebase.hg |
|
183 | saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/daf7dfc139cb-fdbfcf4f-rebase.hg | |
184 |
|
184 | |||
185 | $ hg tglog |
|
185 | $ hg tglog | |
186 | @ 4: c6ad37a4f250 'a/a' |
|
186 | @ 4: c6ad37a4f250 'a/a' | |
187 | | |
|
187 | | | |
188 | | o 3: 844a7de3e617 'c' |
|
188 | | o 3: 844a7de3e617 'c' | |
189 | | | |
|
189 | | | | |
190 | o | 2: 09c044d2cb43 'd' |
|
190 | o | 2: 09c044d2cb43 'd' | |
191 | | | |
|
191 | | | | |
192 | o | 1: fc055c3b4d33 'b' |
|
192 | o | 1: fc055c3b4d33 'b' | |
193 | |/ |
|
193 | |/ | |
194 | o 0: b173517d0057 'a' |
|
194 | o 0: b173517d0057 'a' | |
195 |
|
195 | |||
196 | $ echo foo > foo |
|
196 | $ echo foo > foo | |
197 | $ hg ci -Aqm "added foo" |
|
197 | $ hg ci -Aqm "added foo" | |
198 | $ hg up '.^' |
|
198 | $ hg up '.^' | |
199 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
199 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
200 | $ echo bar > bar |
|
200 | $ echo bar > bar | |
201 | $ hg ci -Aqm "added bar" |
|
201 | $ hg ci -Aqm "added bar" | |
202 | $ hg rm a/a |
|
202 | $ hg rm a/a | |
203 | $ echo a > a |
|
203 | $ echo a > a | |
204 | $ hg ci -Aqm "added a back!" |
|
204 | $ hg ci -Aqm "added a back!" | |
205 | $ hg tglog |
|
205 | $ hg tglog | |
206 | @ 7: 855e9797387e 'added a back!' |
|
206 | @ 7: 855e9797387e 'added a back!' | |
207 | | |
|
207 | | | |
208 | o 6: d14530e5e3e6 'added bar' |
|
208 | o 6: d14530e5e3e6 'added bar' | |
209 | | |
|
209 | | | |
210 | | o 5: 9b94b9373deb 'added foo' |
|
210 | | o 5: 9b94b9373deb 'added foo' | |
211 | |/ |
|
211 | |/ | |
212 | o 4: c6ad37a4f250 'a/a' |
|
212 | o 4: c6ad37a4f250 'a/a' | |
213 | | |
|
213 | | | |
214 | | o 3: 844a7de3e617 'c' |
|
214 | | o 3: 844a7de3e617 'c' | |
215 | | | |
|
215 | | | | |
216 | o | 2: 09c044d2cb43 'd' |
|
216 | o | 2: 09c044d2cb43 'd' | |
217 | | | |
|
217 | | | | |
218 | o | 1: fc055c3b4d33 'b' |
|
218 | o | 1: fc055c3b4d33 'b' | |
219 | |/ |
|
219 | |/ | |
220 | o 0: b173517d0057 'a' |
|
220 | o 0: b173517d0057 'a' | |
221 |
|
221 | |||
222 | $ hg rebase -r . -d 5 |
|
222 | $ hg rebase -r . -d 5 | |
223 | rebasing 7:855e9797387e "added a back!" (tip) |
|
223 | rebasing 7:855e9797387e "added a back!" (tip) | |
224 | saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/855e9797387e-81ee4c5d-rebase.hg |
|
224 | saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/855e9797387e-81ee4c5d-rebase.hg | |
225 |
|
225 | |||
226 | $ hg tglog |
|
226 | $ hg tglog | |
227 | @ 7: bb3f02be2688 'added a back!' |
|
227 | @ 7: bb3f02be2688 'added a back!' | |
228 | | |
|
228 | | | |
229 | | o 6: d14530e5e3e6 'added bar' |
|
229 | | o 6: d14530e5e3e6 'added bar' | |
230 | | | |
|
230 | | | | |
231 | o | 5: 9b94b9373deb 'added foo' |
|
231 | o | 5: 9b94b9373deb 'added foo' | |
232 | |/ |
|
232 | |/ | |
233 | o 4: c6ad37a4f250 'a/a' |
|
233 | o 4: c6ad37a4f250 'a/a' | |
234 | | |
|
234 | | | |
235 | | o 3: 844a7de3e617 'c' |
|
235 | | o 3: 844a7de3e617 'c' | |
236 | | | |
|
236 | | | | |
237 | o | 2: 09c044d2cb43 'd' |
|
237 | o | 2: 09c044d2cb43 'd' | |
238 | | | |
|
238 | | | | |
239 | o | 1: fc055c3b4d33 'b' |
|
239 | o | 1: fc055c3b4d33 'b' | |
240 | |/ |
|
240 | |/ | |
241 | o 0: b173517d0057 'a' |
|
241 | o 0: b173517d0057 'a' | |
242 |
|
242 | |||
243 | $ mkdir -p c/subdir |
|
243 | $ mkdir -p c/subdir | |
244 | $ echo c > c/subdir/file.txt |
|
244 | $ echo c > c/subdir/file.txt | |
245 | $ hg add c/subdir/file.txt |
|
245 | $ hg add c/subdir/file.txt | |
246 | $ hg ci -m 'c/subdir/file.txt' |
|
246 | $ hg ci -m 'c/subdir/file.txt' | |
247 | $ hg rebase -r . -d 3 -n |
|
247 | $ hg rebase -r . -d 3 -n | |
248 | starting dry-run rebase; repository will not be changed |
|
248 | starting dry-run rebase; repository will not be changed | |
249 | rebasing 8:e147e6e3c490 "c/subdir/file.txt" (tip) |
|
249 | rebasing 8:e147e6e3c490 "c/subdir/file.txt" (tip) | |
250 | abort: error: 'c/subdir/file.txt' conflicts with file 'c' in 3. |
|
250 | abort: error: 'c/subdir/file.txt' conflicts with file 'c' in 3. | |
251 | [255] |
|
251 | [255] | |
252 | $ hg rebase -r 3 -d . -n |
|
252 | $ hg rebase -r 3 -d . -n | |
253 | starting dry-run rebase; repository will not be changed |
|
253 | starting dry-run rebase; repository will not be changed | |
254 | rebasing 3:844a7de3e617 "c" |
|
254 | rebasing 3:844a7de3e617 "c" | |
255 | abort: error: file 'c' cannot be written because 'c/' is a directory in e147e6e3c490 (containing 1 entries: c/subdir/file.txt) |
|
255 | abort: error: file 'c' cannot be written because 'c/' is a directory in e147e6e3c490 (containing 1 entries: c/subdir/file.txt) | |
256 | [255] |
|
256 | [255] | |
257 |
|
257 | |||
258 | $ cd .. |
|
258 | $ cd .. | |
259 |
|
259 | |||
260 | Test path auditing (issue5818) |
|
260 | Test path auditing (issue5818) | |
261 |
|
261 | |||
262 | $ mkdir lib_ |
|
262 | $ mkdir lib_ | |
263 | $ ln -s lib_ lib |
|
263 | $ ln -s lib_ lib | |
264 | $ hg init repo |
|
264 | $ hg init repo | |
265 | $ cd repo |
|
265 | $ cd repo | |
266 | $ mkdir -p ".$TESTTMP/lib" |
|
266 | $ mkdir -p ".$TESTTMP/lib" | |
267 | $ touch ".$TESTTMP/lib/a" |
|
267 | $ touch ".$TESTTMP/lib/a" | |
268 | $ hg add ".$TESTTMP/lib/a" |
|
268 | $ hg add ".$TESTTMP/lib/a" | |
269 | $ hg ci -m 'a' |
|
269 | $ hg ci -m 'a' | |
270 |
|
270 | |||
271 | $ touch ".$TESTTMP/lib/b" |
|
271 | $ touch ".$TESTTMP/lib/b" | |
272 | $ hg add ".$TESTTMP/lib/b" |
|
272 | $ hg add ".$TESTTMP/lib/b" | |
273 | $ hg ci -m 'b' |
|
273 | $ hg ci -m 'b' | |
274 |
|
274 | |||
275 | $ hg up -q '.^' |
|
275 | $ hg up -q '.^' | |
276 | $ touch ".$TESTTMP/lib/c" |
|
276 | $ touch ".$TESTTMP/lib/c" | |
277 | $ hg add ".$TESTTMP/lib/c" |
|
277 | $ hg add ".$TESTTMP/lib/c" | |
278 | $ hg ci -m 'c' |
|
278 | $ hg ci -m 'c' | |
279 | created new head |
|
279 | created new head | |
280 | $ hg rebase -s 1 -d . |
|
280 | $ hg rebase -s 1 -d . | |
281 | rebasing 1:* "b" (glob) |
|
281 | rebasing 1:* "b" (glob) | |
282 | saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-rebase.hg (glob) |
|
282 | saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-rebase.hg (glob) | |
283 | $ cd .. |
|
283 | $ cd .. | |
284 |
|
284 | |||
285 | Test dry-run rebasing |
|
285 | Test dry-run rebasing | |
286 |
|
286 | |||
287 | $ hg init repo3 |
|
287 | $ hg init repo3 | |
288 | $ cd repo3 |
|
288 | $ cd repo3 | |
289 | $ echo a>a |
|
289 | $ echo a>a | |
290 | $ hg ci -Aqma |
|
290 | $ hg ci -Aqma | |
291 | $ echo b>b |
|
291 | $ echo b>b | |
292 | $ hg ci -Aqmb |
|
292 | $ hg ci -Aqmb | |
293 | $ echo c>c |
|
293 | $ echo c>c | |
294 | $ hg ci -Aqmc |
|
294 | $ hg ci -Aqmc | |
295 | $ echo d>d |
|
295 | $ echo d>d | |
296 | $ hg ci -Aqmd |
|
296 | $ hg ci -Aqmd | |
297 | $ echo e>e |
|
297 | $ echo e>e | |
298 | $ hg ci -Aqme |
|
298 | $ hg ci -Aqme | |
299 |
|
299 | |||
300 | $ hg up 1 -q |
|
300 | $ hg up 1 -q | |
301 | $ echo f>f |
|
301 | $ echo f>f | |
302 | $ hg ci -Amf |
|
302 | $ hg ci -Amf | |
303 | adding f |
|
303 | adding f | |
304 | created new head |
|
304 | created new head | |
305 | $ echo g>g |
|
305 | $ echo g>g | |
306 | $ hg ci -Aqmg |
|
306 | $ hg ci -Aqmg | |
307 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
307 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
308 | @ 6:baf10c5166d4 test |
|
308 | @ 6:baf10c5166d4 test | |
309 | | g |
|
309 | | g | |
310 | | |
|
310 | | | |
311 | o 5:6343ca3eff20 test |
|
311 | o 5:6343ca3eff20 test | |
312 | | f |
|
312 | | f | |
313 | | |
|
313 | | | |
314 | | o 4:e860deea161a test |
|
314 | | o 4:e860deea161a test | |
315 | | | e |
|
315 | | | e | |
316 | | | |
|
316 | | | | |
317 | | o 3:055a42cdd887 test |
|
317 | | o 3:055a42cdd887 test | |
318 | | | d |
|
318 | | | d | |
319 | | | |
|
319 | | | | |
320 | | o 2:177f92b77385 test |
|
320 | | o 2:177f92b77385 test | |
321 | |/ c |
|
321 | |/ c | |
322 | | |
|
322 | | | |
323 | o 1:d2ae7f538514 test |
|
323 | o 1:d2ae7f538514 test | |
324 | | b |
|
324 | | b | |
325 | | |
|
325 | | | |
326 | o 0:cb9a9f314b8b test |
|
326 | o 0:cb9a9f314b8b test | |
327 | a |
|
327 | a | |
328 |
|
328 | |||
329 | Make sure it throws error while passing --continue or --abort with --dry-run |
|
329 | Make sure it throws error while passing --continue or --abort with --dry-run | |
330 | $ hg rebase -s 2 -d 6 -n --continue |
|
330 | $ hg rebase -s 2 -d 6 -n --continue | |
331 | abort: cannot specify both --dry-run and --continue |
|
331 | abort: cannot specify both --dry-run and --continue | |
332 | [255] |
|
332 | [255] | |
333 | $ hg rebase -s 2 -d 6 -n --abort |
|
333 | $ hg rebase -s 2 -d 6 -n --abort | |
334 | abort: cannot specify both --dry-run and --abort |
|
334 | abort: cannot specify both --dry-run and --abort | |
335 | [255] |
|
335 | [255] | |
336 |
|
336 | |||
337 | Check dryrun gives correct results when there is no conflict in rebasing |
|
337 | Check dryrun gives correct results when there is no conflict in rebasing | |
338 | $ hg rebase -s 2 -d 6 -n |
|
338 | $ hg rebase -s 2 -d 6 -n | |
339 | starting dry-run rebase; repository will not be changed |
|
339 | starting dry-run rebase; repository will not be changed | |
340 | rebasing 2:177f92b77385 "c" |
|
340 | rebasing 2:177f92b77385 "c" | |
341 | rebasing 3:055a42cdd887 "d" |
|
341 | rebasing 3:055a42cdd887 "d" | |
342 | rebasing 4:e860deea161a "e" |
|
342 | rebasing 4:e860deea161a "e" | |
343 | dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase |
|
343 | dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase | |
344 |
|
344 | |||
345 | $ hg diff |
|
345 | $ hg diff | |
346 | $ hg status |
|
346 | $ hg status | |
347 |
|
347 | |||
348 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
348 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
349 | @ 6:baf10c5166d4 test |
|
349 | @ 6:baf10c5166d4 test | |
350 | | g |
|
350 | | g | |
351 | | |
|
351 | | | |
352 | o 5:6343ca3eff20 test |
|
352 | o 5:6343ca3eff20 test | |
353 | | f |
|
353 | | f | |
354 | | |
|
354 | | | |
355 | | o 4:e860deea161a test |
|
355 | | o 4:e860deea161a test | |
356 | | | e |
|
356 | | | e | |
357 | | | |
|
357 | | | | |
358 | | o 3:055a42cdd887 test |
|
358 | | o 3:055a42cdd887 test | |
359 | | | d |
|
359 | | | d | |
360 | | | |
|
360 | | | | |
361 | | o 2:177f92b77385 test |
|
361 | | o 2:177f92b77385 test | |
362 | |/ c |
|
362 | |/ c | |
363 | | |
|
363 | | | |
364 | o 1:d2ae7f538514 test |
|
364 | o 1:d2ae7f538514 test | |
365 | | b |
|
365 | | b | |
366 | | |
|
366 | | | |
367 | o 0:cb9a9f314b8b test |
|
367 | o 0:cb9a9f314b8b test | |
368 | a |
|
368 | a | |
369 |
|
369 | |||
370 | Check dryrun working with --collapse when there is no conflict |
|
370 | Check dryrun working with --collapse when there is no conflict | |
371 | $ hg rebase -s 2 -d 6 -n --collapse |
|
371 | $ hg rebase -s 2 -d 6 -n --collapse | |
372 | starting dry-run rebase; repository will not be changed |
|
372 | starting dry-run rebase; repository will not be changed | |
373 | rebasing 2:177f92b77385 "c" |
|
373 | rebasing 2:177f92b77385 "c" | |
374 | rebasing 3:055a42cdd887 "d" |
|
374 | rebasing 3:055a42cdd887 "d" | |
375 | rebasing 4:e860deea161a "e" |
|
375 | rebasing 4:e860deea161a "e" | |
376 | dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase |
|
376 | dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase | |
377 |
|
377 | |||
378 | Check dryrun gives correct results when there is conflict in rebasing |
|
378 | Check dryrun gives correct results when there is conflict in rebasing | |
379 | Make a conflict: |
|
379 | Make a conflict: | |
380 | $ hg up 6 -q |
|
380 | $ hg up 6 -q | |
381 | $ echo conflict>e |
|
381 | $ echo conflict>e | |
382 | $ hg ci -Aqm "conflict with e" |
|
382 | $ hg ci -Aqm "conflict with e" | |
383 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
383 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
384 | @ 7:d2c195b28050 test |
|
384 | @ 7:d2c195b28050 test | |
385 | | conflict with e |
|
385 | | conflict with e | |
386 | | |
|
386 | | | |
387 | o 6:baf10c5166d4 test |
|
387 | o 6:baf10c5166d4 test | |
388 | | g |
|
388 | | g | |
389 | | |
|
389 | | | |
390 | o 5:6343ca3eff20 test |
|
390 | o 5:6343ca3eff20 test | |
391 | | f |
|
391 | | f | |
392 | | |
|
392 | | | |
393 | | o 4:e860deea161a test |
|
393 | | o 4:e860deea161a test | |
394 | | | e |
|
394 | | | e | |
395 | | | |
|
395 | | | | |
396 | | o 3:055a42cdd887 test |
|
396 | | o 3:055a42cdd887 test | |
397 | | | d |
|
397 | | | d | |
398 | | | |
|
398 | | | | |
399 | | o 2:177f92b77385 test |
|
399 | | o 2:177f92b77385 test | |
400 | |/ c |
|
400 | |/ c | |
401 | | |
|
401 | | | |
402 | o 1:d2ae7f538514 test |
|
402 | o 1:d2ae7f538514 test | |
403 | | b |
|
403 | | b | |
404 | | |
|
404 | | | |
405 | o 0:cb9a9f314b8b test |
|
405 | o 0:cb9a9f314b8b test | |
406 | a |
|
406 | a | |
407 |
|
407 | |||
408 | $ hg rebase -s 2 -d 7 -n |
|
408 | $ hg rebase -s 2 -d 7 -n | |
409 | starting dry-run rebase; repository will not be changed |
|
409 | starting dry-run rebase; repository will not be changed | |
410 | rebasing 2:177f92b77385 "c" |
|
410 | rebasing 2:177f92b77385 "c" | |
411 | rebasing 3:055a42cdd887 "d" |
|
411 | rebasing 3:055a42cdd887 "d" | |
412 | rebasing 4:e860deea161a "e" |
|
412 | rebasing 4:e860deea161a "e" | |
413 | merging e |
|
413 | merging e | |
414 | transaction abort! |
|
414 | transaction abort! | |
415 | rollback completed |
|
415 | rollback completed | |
416 | hit a merge conflict |
|
416 | hit a merge conflict | |
417 | [1] |
|
417 | [1] | |
418 | $ hg diff |
|
418 | $ hg diff | |
419 | $ hg status |
|
419 | $ hg status | |
420 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
420 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
421 | @ 7:d2c195b28050 test |
|
421 | @ 7:d2c195b28050 test | |
422 | | conflict with e |
|
422 | | conflict with e | |
423 | | |
|
423 | | | |
424 | o 6:baf10c5166d4 test |
|
424 | o 6:baf10c5166d4 test | |
425 | | g |
|
425 | | g | |
426 | | |
|
426 | | | |
427 | o 5:6343ca3eff20 test |
|
427 | o 5:6343ca3eff20 test | |
428 | | f |
|
428 | | f | |
429 | | |
|
429 | | | |
430 | | o 4:e860deea161a test |
|
430 | | o 4:e860deea161a test | |
431 | | | e |
|
431 | | | e | |
432 | | | |
|
432 | | | | |
433 | | o 3:055a42cdd887 test |
|
433 | | o 3:055a42cdd887 test | |
434 | | | d |
|
434 | | | d | |
435 | | | |
|
435 | | | | |
436 | | o 2:177f92b77385 test |
|
436 | | o 2:177f92b77385 test | |
437 | |/ c |
|
437 | |/ c | |
438 | | |
|
438 | | | |
439 | o 1:d2ae7f538514 test |
|
439 | o 1:d2ae7f538514 test | |
440 | | b |
|
440 | | b | |
441 | | |
|
441 | | | |
442 | o 0:cb9a9f314b8b test |
|
442 | o 0:cb9a9f314b8b test | |
443 | a |
|
443 | a | |
444 |
|
444 | |||
445 | Check dryrun working with --collapse when there is conflicts |
|
445 | Check dryrun working with --collapse when there is conflicts | |
446 | $ hg rebase -s 2 -d 7 -n --collapse |
|
446 | $ hg rebase -s 2 -d 7 -n --collapse | |
447 | starting dry-run rebase; repository will not be changed |
|
447 | starting dry-run rebase; repository will not be changed | |
448 | rebasing 2:177f92b77385 "c" |
|
448 | rebasing 2:177f92b77385 "c" | |
449 | rebasing 3:055a42cdd887 "d" |
|
449 | rebasing 3:055a42cdd887 "d" | |
450 | rebasing 4:e860deea161a "e" |
|
450 | rebasing 4:e860deea161a "e" | |
451 | merging e |
|
451 | merging e | |
452 | hit a merge conflict |
|
452 | hit a merge conflict | |
453 | [1] |
|
453 | [1] | |
454 |
|
454 | |||
455 | In-memory rebase that fails due to merge conflicts |
|
455 | In-memory rebase that fails due to merge conflicts | |
456 |
|
456 | |||
457 | $ hg rebase -s 2 -d 7 |
|
457 | $ hg rebase -s 2 -d 7 | |
458 | rebasing 2:177f92b77385 "c" |
|
458 | rebasing 2:177f92b77385 "c" | |
459 | rebasing 3:055a42cdd887 "d" |
|
459 | rebasing 3:055a42cdd887 "d" | |
460 | rebasing 4:e860deea161a "e" |
|
460 | rebasing 4:e860deea161a "e" | |
461 | merging e |
|
461 | merging e | |
462 | transaction abort! |
|
462 | transaction abort! | |
463 | rollback completed |
|
463 | rollback completed | |
464 | hit merge conflicts; re-running rebase without in-memory merge |
|
464 | hit merge conflicts; re-running rebase without in-memory merge | |
465 | rebasing 2:177f92b77385 "c" |
|
465 | rebasing 2:177f92b77385 "c" | |
466 | rebasing 3:055a42cdd887 "d" |
|
466 | rebasing 3:055a42cdd887 "d" | |
467 | rebasing 4:e860deea161a "e" |
|
467 | rebasing 4:e860deea161a "e" | |
468 | merging e |
|
468 | merging e | |
469 | warning: conflicts while merging e! (edit, then use 'hg resolve --mark') |
|
469 | warning: conflicts while merging e! (edit, then use 'hg resolve --mark') | |
470 | unresolved conflicts (see hg resolve, then hg rebase --continue) |
|
470 | unresolved conflicts (see hg resolve, then hg rebase --continue) | |
471 | [1] |
|
471 | [1] | |
472 | $ hg rebase --abort |
|
472 | $ hg rebase --abort | |
473 | saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/c1e524d4287c-f91f82e1-backup.hg |
|
473 | saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/c1e524d4287c-f91f82e1-backup.hg | |
474 | rebase aborted |
|
474 | rebase aborted | |
475 |
|
475 | |||
476 | Retrying without in-memory merge won't lose working copy changes |
|
476 | Retrying without in-memory merge won't lose working copy changes | |
477 | $ cd .. |
|
477 | $ cd .. | |
478 | $ hg clone repo3 repo3-dirty -q |
|
478 | $ hg clone repo3 repo3-dirty -q | |
479 | $ cd repo3-dirty |
|
479 | $ cd repo3-dirty | |
480 | $ echo dirty > a |
|
480 | $ echo dirty > a | |
481 | $ hg rebase -s 2 -d 7 |
|
481 | $ hg rebase -s 2 -d 7 | |
482 | rebasing 2:177f92b77385 "c" |
|
482 | rebasing 2:177f92b77385 "c" | |
483 | rebasing 3:055a42cdd887 "d" |
|
483 | rebasing 3:055a42cdd887 "d" | |
484 | rebasing 4:e860deea161a "e" |
|
484 | rebasing 4:e860deea161a "e" | |
485 | merging e |
|
485 | merging e | |
486 | transaction abort! |
|
486 | transaction abort! | |
487 | rollback completed |
|
487 | rollback completed | |
488 | hit merge conflicts; re-running rebase without in-memory merge |
|
488 | hit merge conflicts; re-running rebase without in-memory merge | |
489 | abort: uncommitted changes |
|
489 | abort: uncommitted changes | |
490 | [255] |
|
490 | [255] | |
491 | $ cat a |
|
491 | $ cat a | |
492 | dirty |
|
492 | dirty | |
493 |
|
493 | |||
494 | Retrying without in-memory merge won't lose merge state |
|
494 | Retrying without in-memory merge won't lose merge state | |
495 | $ cd .. |
|
495 | $ cd .. | |
496 | $ hg clone repo3 repo3-merge-state -q |
|
496 | $ hg clone repo3 repo3-merge-state -q | |
497 | $ cd repo3-merge-state |
|
497 | $ cd repo3-merge-state | |
498 | $ hg merge 4 |
|
498 | $ hg merge 4 | |
499 | merging e |
|
499 | merging e | |
500 | warning: conflicts while merging e! (edit, then use 'hg resolve --mark') |
|
500 | warning: conflicts while merging e! (edit, then use 'hg resolve --mark') | |
501 | 2 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
501 | 2 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
502 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
|
502 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon | |
503 | [1] |
|
503 | [1] | |
504 | $ hg resolve -l |
|
504 | $ hg resolve -l | |
505 | U e |
|
505 | U e | |
506 | $ hg rebase -s 2 -d 7 |
|
506 | $ hg rebase -s 2 -d 7 | |
507 | rebasing 2:177f92b77385 "c" |
|
507 | rebasing 2:177f92b77385 "c" | |
508 | abort: outstanding merge conflicts |
|
508 | abort: outstanding merge conflicts | |
509 | [255] |
|
509 | [255] | |
510 | $ hg resolve -l |
|
510 | $ hg resolve -l | |
511 | U e |
|
511 | U e | |
512 |
|
512 | |||
513 | ========================== |
|
513 | ========================== | |
514 | Test for --confirm option| |
|
514 | Test for --confirm option| | |
515 | ========================== |
|
515 | ========================== | |
516 | $ cd .. |
|
516 | $ cd .. | |
517 | $ hg clone repo3 repo4 -q |
|
517 | $ hg clone repo3 repo4 -q | |
518 | $ cd repo4 |
|
518 | $ cd repo4 | |
519 | $ hg strip 7 -q |
|
519 | $ hg strip 7 -q | |
520 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
520 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
521 | @ 6:baf10c5166d4 test |
|
521 | @ 6:baf10c5166d4 test | |
522 | | g |
|
522 | | g | |
523 | | |
|
523 | | | |
524 | o 5:6343ca3eff20 test |
|
524 | o 5:6343ca3eff20 test | |
525 | | f |
|
525 | | f | |
526 | | |
|
526 | | | |
527 | | o 4:e860deea161a test |
|
527 | | o 4:e860deea161a test | |
528 | | | e |
|
528 | | | e | |
529 | | | |
|
529 | | | | |
530 | | o 3:055a42cdd887 test |
|
530 | | o 3:055a42cdd887 test | |
531 | | | d |
|
531 | | | d | |
532 | | | |
|
532 | | | | |
533 | | o 2:177f92b77385 test |
|
533 | | o 2:177f92b77385 test | |
534 | |/ c |
|
534 | |/ c | |
535 | | |
|
535 | | | |
536 | o 1:d2ae7f538514 test |
|
536 | o 1:d2ae7f538514 test | |
537 | | b |
|
537 | | b | |
538 | | |
|
538 | | | |
539 | o 0:cb9a9f314b8b test |
|
539 | o 0:cb9a9f314b8b test | |
540 | a |
|
540 | a | |
541 |
|
541 | |||
542 | Check it gives error when both --dryrun and --confirm is used: |
|
542 | Check it gives error when both --dryrun and --confirm is used: | |
543 | $ hg rebase -s 2 -d . --confirm --dry-run |
|
543 | $ hg rebase -s 2 -d . --confirm --dry-run | |
544 | abort: cannot specify both --confirm and --dry-run |
|
544 | abort: cannot specify both --confirm and --dry-run | |
545 | [255] |
|
545 | [255] | |
546 | $ hg rebase -s 2 -d . --confirm --abort |
|
546 | $ hg rebase -s 2 -d . --confirm --abort | |
547 | abort: cannot specify both --confirm and --abort |
|
547 | abort: cannot specify both --confirm and --abort | |
548 | [255] |
|
548 | [255] | |
549 | $ hg rebase -s 2 -d . --confirm --continue |
|
549 | $ hg rebase -s 2 -d . --confirm --continue | |
550 | abort: cannot specify both --confirm and --continue |
|
550 | abort: cannot specify both --confirm and --continue | |
551 | [255] |
|
551 | [255] | |
552 |
|
552 | |||
553 | Test --confirm option when there are no conflicts: |
|
553 | Test --confirm option when there are no conflicts: | |
554 | $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF |
|
554 | $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF | |
555 | > n |
|
555 | > n | |
556 | > EOF |
|
556 | > EOF | |
557 | starting in-memory rebase |
|
557 | starting in-memory rebase | |
558 | rebasing 2:177f92b77385 "c" |
|
558 | rebasing 2:177f92b77385 "c" | |
559 | rebasing 3:055a42cdd887 "d" |
|
559 | rebasing 3:055a42cdd887 "d" | |
560 | rebasing 4:e860deea161a "e" |
|
560 | rebasing 4:e860deea161a "e" | |
561 | rebase completed successfully |
|
561 | rebase completed successfully | |
562 | apply changes (yn)? n |
|
562 | apply changes (yn)? n | |
563 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
563 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
564 | @ 6:baf10c5166d4 test |
|
564 | @ 6:baf10c5166d4 test | |
565 | | g |
|
565 | | g | |
566 | | |
|
566 | | | |
567 | o 5:6343ca3eff20 test |
|
567 | o 5:6343ca3eff20 test | |
568 | | f |
|
568 | | f | |
569 | | |
|
569 | | | |
570 | | o 4:e860deea161a test |
|
570 | | o 4:e860deea161a test | |
571 | | | e |
|
571 | | | e | |
572 | | | |
|
572 | | | | |
573 | | o 3:055a42cdd887 test |
|
573 | | o 3:055a42cdd887 test | |
574 | | | d |
|
574 | | | d | |
575 | | | |
|
575 | | | | |
576 | | o 2:177f92b77385 test |
|
576 | | o 2:177f92b77385 test | |
577 | |/ c |
|
577 | |/ c | |
578 | | |
|
578 | | | |
579 | o 1:d2ae7f538514 test |
|
579 | o 1:d2ae7f538514 test | |
580 | | b |
|
580 | | b | |
581 | | |
|
581 | | | |
582 | o 0:cb9a9f314b8b test |
|
582 | o 0:cb9a9f314b8b test | |
583 | a |
|
583 | a | |
584 |
|
584 | |||
585 | $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF |
|
585 | $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF | |
586 | > y |
|
586 | > y | |
587 | > EOF |
|
587 | > EOF | |
588 | starting in-memory rebase |
|
588 | starting in-memory rebase | |
589 | rebasing 2:177f92b77385 "c" |
|
589 | rebasing 2:177f92b77385 "c" | |
590 | rebasing 3:055a42cdd887 "d" |
|
590 | rebasing 3:055a42cdd887 "d" | |
591 | rebasing 4:e860deea161a "e" |
|
591 | rebasing 4:e860deea161a "e" | |
592 | rebase completed successfully |
|
592 | rebase completed successfully | |
593 | apply changes (yn)? y |
|
593 | apply changes (yn)? y | |
594 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
594 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
595 | o 9:9fd28f55f6dc test |
|
595 | o 9:9fd28f55f6dc test | |
596 | | e |
|
596 | | e | |
597 | | |
|
597 | | | |
598 | o 8:12cbf031f469 test |
|
598 | o 8:12cbf031f469 test | |
599 | | d |
|
599 | | d | |
600 | | |
|
600 | | | |
601 | o 7:c83b1da5b1ae test |
|
601 | o 7:c83b1da5b1ae test | |
602 | | c |
|
602 | | c | |
603 | | |
|
603 | | | |
604 | @ 6:baf10c5166d4 test |
|
604 | @ 6:baf10c5166d4 test | |
605 | | g |
|
605 | | g | |
606 | | |
|
606 | | | |
607 | o 5:6343ca3eff20 test |
|
607 | o 5:6343ca3eff20 test | |
608 | | f |
|
608 | | f | |
609 | | |
|
609 | | | |
610 | | o 4:e860deea161a test |
|
610 | | o 4:e860deea161a test | |
611 | | | e |
|
611 | | | e | |
612 | | | |
|
612 | | | | |
613 | | o 3:055a42cdd887 test |
|
613 | | o 3:055a42cdd887 test | |
614 | | | d |
|
614 | | | d | |
615 | | | |
|
615 | | | | |
616 | | o 2:177f92b77385 test |
|
616 | | o 2:177f92b77385 test | |
617 | |/ c |
|
617 | |/ c | |
618 | | |
|
618 | | | |
619 | o 1:d2ae7f538514 test |
|
619 | o 1:d2ae7f538514 test | |
620 | | b |
|
620 | | b | |
621 | | |
|
621 | | | |
622 | o 0:cb9a9f314b8b test |
|
622 | o 0:cb9a9f314b8b test | |
623 | a |
|
623 | a | |
624 |
|
624 | |||
625 | Test --confirm option when there is a conflict |
|
625 | Test --confirm option when there is a conflict | |
626 | $ hg up tip -q |
|
626 | $ hg up tip -q | |
627 | $ echo ee>e |
|
627 | $ echo ee>e | |
628 | $ hg ci --amend -m "conflict with e" -q |
|
628 | $ hg ci --amend -m "conflict with e" -q | |
629 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
629 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
630 | @ 9:906d72f66a59 test |
|
630 | @ 9:906d72f66a59 test | |
631 | | conflict with e |
|
631 | | conflict with e | |
632 | | |
|
632 | | | |
633 | o 8:12cbf031f469 test |
|
633 | o 8:12cbf031f469 test | |
634 | | d |
|
634 | | d | |
635 | | |
|
635 | | | |
636 | o 7:c83b1da5b1ae test |
|
636 | o 7:c83b1da5b1ae test | |
637 | | c |
|
637 | | c | |
638 | | |
|
638 | | | |
639 | o 6:baf10c5166d4 test |
|
639 | o 6:baf10c5166d4 test | |
640 | | g |
|
640 | | g | |
641 | | |
|
641 | | | |
642 | o 5:6343ca3eff20 test |
|
642 | o 5:6343ca3eff20 test | |
643 | | f |
|
643 | | f | |
644 | | |
|
644 | | | |
645 | | o 4:e860deea161a test |
|
645 | | o 4:e860deea161a test | |
646 | | | e |
|
646 | | | e | |
647 | | | |
|
647 | | | | |
648 | | o 3:055a42cdd887 test |
|
648 | | o 3:055a42cdd887 test | |
649 | | | d |
|
649 | | | d | |
650 | | | |
|
650 | | | | |
651 | | o 2:177f92b77385 test |
|
651 | | o 2:177f92b77385 test | |
652 | |/ c |
|
652 | |/ c | |
653 | | |
|
653 | | | |
654 | o 1:d2ae7f538514 test |
|
654 | o 1:d2ae7f538514 test | |
655 | | b |
|
655 | | b | |
656 | | |
|
656 | | | |
657 | o 0:cb9a9f314b8b test |
|
657 | o 0:cb9a9f314b8b test | |
658 | a |
|
658 | a | |
659 |
|
659 | |||
660 | $ hg rebase -s 4 -d . --keep --confirm |
|
660 | $ hg rebase -s 4 -d . --keep --confirm | |
661 | starting in-memory rebase |
|
661 | starting in-memory rebase | |
662 | rebasing 4:e860deea161a "e" |
|
662 | rebasing 4:e860deea161a "e" | |
663 | merging e |
|
663 | merging e | |
664 | hit a merge conflict |
|
664 | hit a merge conflict | |
665 | [1] |
|
665 | [1] | |
666 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" |
|
666 | $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" | |
667 | @ 9:906d72f66a59 test |
|
667 | @ 9:906d72f66a59 test | |
668 | | conflict with e |
|
668 | | conflict with e | |
669 | | |
|
669 | | | |
670 | o 8:12cbf031f469 test |
|
670 | o 8:12cbf031f469 test | |
671 | | d |
|
671 | | d | |
672 | | |
|
672 | | | |
673 | o 7:c83b1da5b1ae test |
|
673 | o 7:c83b1da5b1ae test | |
674 | | c |
|
674 | | c | |
675 | | |
|
675 | | | |
676 | o 6:baf10c5166d4 test |
|
676 | o 6:baf10c5166d4 test | |
677 | | g |
|
677 | | g | |
678 | | |
|
678 | | | |
679 | o 5:6343ca3eff20 test |
|
679 | o 5:6343ca3eff20 test | |
680 | | f |
|
680 | | f | |
681 | | |
|
681 | | | |
682 | | o 4:e860deea161a test |
|
682 | | o 4:e860deea161a test | |
683 | | | e |
|
683 | | | e | |
684 | | | |
|
684 | | | | |
685 | | o 3:055a42cdd887 test |
|
685 | | o 3:055a42cdd887 test | |
686 | | | d |
|
686 | | | d | |
687 | | | |
|
687 | | | | |
688 | | o 2:177f92b77385 test |
|
688 | | o 2:177f92b77385 test | |
689 | |/ c |
|
689 | |/ c | |
690 | | |
|
690 | | | |
691 | o 1:d2ae7f538514 test |
|
691 | o 1:d2ae7f538514 test | |
692 | | b |
|
692 | | b | |
693 | | |
|
693 | | | |
694 | o 0:cb9a9f314b8b test |
|
694 | o 0:cb9a9f314b8b test | |
695 | a |
|
695 | a | |
696 |
|
696 | |||
697 | Test a metadata-only in-memory merge |
|
697 | Test a metadata-only in-memory merge | |
698 | $ cd $TESTTMP |
|
698 | $ cd $TESTTMP | |
699 | $ hg init no_exception |
|
699 | $ hg init no_exception | |
700 | $ cd no_exception |
|
700 | $ cd no_exception | |
701 | # Produce the following graph: |
|
701 | # Produce the following graph: | |
702 | # o 'add +x to foo.txt' |
|
702 | # o 'add +x to foo.txt' | |
703 | # | o r1 (adds bar.txt, just for something to rebase to) |
|
703 | # | o r1 (adds bar.txt, just for something to rebase to) | |
704 | # |/ |
|
704 | # |/ | |
705 | # o r0 (adds foo.txt, no +x) |
|
705 | # o r0 (adds foo.txt, no +x) | |
706 | $ echo hi > foo.txt |
|
706 | $ echo hi > foo.txt | |
707 | $ hg ci -qAm r0 |
|
707 | $ hg ci -qAm r0 | |
708 | $ echo hi > bar.txt |
|
708 | $ echo hi > bar.txt | |
709 | $ hg ci -qAm r1 |
|
709 | $ hg ci -qAm r1 | |
710 | $ hg co -qr ".^" |
|
710 | $ hg co -qr ".^" | |
711 | $ chmod +x foo.txt |
|
711 | $ chmod +x foo.txt | |
712 | $ hg ci -qAm 'add +x to foo.txt' |
|
712 | $ hg ci -qAm 'add +x to foo.txt' | |
713 | issue5960: this was raising an AttributeError exception |
|
713 | issue5960: this was raising an AttributeError exception | |
714 | $ hg rebase -r . -d 1 |
|
714 | $ hg rebase -r . -d 1 | |
715 | rebasing 2:539b93e77479 "add +x to foo.txt" (tip) |
|
715 | rebasing 2:539b93e77479 "add +x to foo.txt" (tip) | |
716 | saved backup bundle to $TESTTMP/no_exception/.hg/strip-backup/*.hg (glob) |
|
716 | saved backup bundle to $TESTTMP/no_exception/.hg/strip-backup/*.hg (glob) | |
717 | $ hg diff -c tip |
|
717 | $ hg diff -c tip | |
718 | diff --git a/foo.txt b/foo.txt |
|
718 | diff --git a/foo.txt b/foo.txt | |
719 | old mode 100644 |
|
719 | old mode 100644 | |
720 | new mode 100755 |
|
720 | new mode 100755 | |
721 |
|
721 | |||
722 | Test rebasing a commit with copy information, but no content changes |
|
722 | Test rebasing a commit with copy information, but no content changes | |
723 |
|
723 | |||
724 | $ cd .. |
|
724 | $ cd .. | |
725 | $ hg clone -q repo1 merge-and-rename |
|
725 | $ hg clone -q repo1 merge-and-rename | |
726 | $ cd merge-and-rename |
|
726 | $ cd merge-and-rename | |
727 | $ cat << EOF >> .hg/hgrc |
|
727 | $ cat << EOF >> .hg/hgrc | |
728 | > [experimental] |
|
728 | > [experimental] | |
729 | > evolution.createmarkers=True |
|
729 | > evolution.createmarkers=True | |
730 | > evolution.allowunstable=True |
|
730 | > evolution.allowunstable=True | |
731 | > EOF |
|
731 | > EOF | |
732 | $ hg co -q 1 |
|
732 | $ hg co -q 1 | |
733 | $ hg mv d e |
|
733 | $ hg mv d e | |
734 | $ hg ci -qm 'rename d to e' |
|
734 | $ hg ci -qm 'rename d to e' | |
735 | $ hg co -q 3 |
|
735 | $ hg co -q 3 | |
736 | $ hg merge -q 4 |
|
736 | $ hg merge -q 4 | |
737 | $ hg ci -m 'merge' |
|
737 | $ hg ci -m 'merge' | |
738 | $ hg co -q 2 |
|
738 | $ hg co -q 2 | |
739 | $ mv d e |
|
739 | $ mv d e | |
740 | $ hg addremove -qs 0 |
|
740 | $ hg addremove -qs 0 | |
741 | $ hg ci -qm 'untracked rename of d to e' |
|
741 | $ hg ci -qm 'untracked rename of d to e' | |
742 | $ hg debugobsolete -q `hg log -T '{node}' -r 4` `hg log -T '{node}' -r .` |
|
742 | $ hg debugobsolete -q `hg log -T '{node}' -r 4` `hg log -T '{node}' -r .` | |
743 | 1 new orphan changesets |
|
743 | 1 new orphan changesets | |
744 | $ hg tglog |
|
744 | $ hg tglog | |
745 | @ 6: 676538af172d 'untracked rename of d to e' |
|
745 | @ 6: 676538af172d 'untracked rename of d to e' | |
746 | | |
|
746 | | | |
747 | | * 5: 71cb43376053 'merge' |
|
747 | | * 5: 71cb43376053 'merge' | |
748 | | |\ |
|
748 | | |\ | |
749 | | | x 4: 2c8b5dad7956 'rename d to e' |
|
749 | | | x 4: 2c8b5dad7956 'rename d to e' | |
750 | | | | |
|
750 | | | | | |
751 | | o | 3: ca58782ad1e4 'b' |
|
751 | | o | 3: ca58782ad1e4 'b' | |
752 | |/ / |
|
752 | |/ / | |
753 | o / 2: 814f6bd05178 'c' |
|
753 | o / 2: 814f6bd05178 'c' | |
754 | |/ |
|
754 | |/ | |
755 | o 1: 02952614a83d 'd' |
|
755 | o 1: 02952614a83d 'd' | |
756 | | |
|
756 | | | |
757 | o 0: b173517d0057 'a' |
|
757 | o 0: b173517d0057 'a' | |
758 |
|
758 | |||
759 | $ hg rebase -b 5 -d tip |
|
759 | $ hg rebase -b 5 -d tip | |
760 | rebasing 3:ca58782ad1e4 "b" |
|
760 | rebasing 3:ca58782ad1e4 "b" | |
761 | rebasing 5:71cb43376053 "merge" |
|
761 | rebasing 5:71cb43376053 "merge" | |
762 | note: not rebasing 5:71cb43376053 "merge", its destination already has all its changes |
|
762 | note: not rebasing 5:71cb43376053 "merge", its destination already has all its changes | |
763 |
|
763 | |||
764 | $ cd .. |
|
764 | $ cd .. | |
765 |
|
765 | |||
766 | Test rebasing a commit with copy information |
|
766 | Test rebasing a commit with copy information | |
767 |
|
767 | |||
768 | $ hg init rebase-rename |
|
768 | $ hg init rebase-rename | |
769 | $ cd rebase-rename |
|
769 | $ cd rebase-rename | |
770 | $ echo a > a |
|
770 | $ echo a > a | |
771 | $ hg ci -Aqm 'add a' |
|
771 | $ hg ci -Aqm 'add a' | |
772 | $ echo a2 > a |
|
772 | $ echo a2 > a | |
773 | $ hg ci -m 'modify a' |
|
773 | $ hg ci -m 'modify a' | |
774 | $ hg co -q 0 |
|
774 | $ hg co -q 0 | |
775 | $ hg mv a b |
|
775 | $ hg mv a b | |
776 | $ hg ci -qm 'rename a to b' |
|
776 | $ hg ci -qm 'rename a to b' | |
777 | $ hg rebase -d 1 2>&1 | grep '** ProgrammingError' |
|
777 | $ hg rebase -d 1 | |
778 | ** ProgrammingError: copydata() called on clean context |
|
778 | rebasing 2:b977edf6f839 "rename a to b" (tip) | |
|
779 | merging a and b to b | |||
|
780 | saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/b977edf6f839-0864f570-rebase.hg | |||
|
781 | $ hg st --copies --change . | |||
|
782 | A b | |||
|
783 | a | |||
|
784 | R a | |||
779 | $ cd .. |
|
785 | $ cd .. | |
780 |
|
786 | |||
781 | Test rebasing when the file we are merging in destination is empty |
|
787 | Test rebasing when the file we are merging in destination is empty | |
782 |
|
788 | |||
783 | $ hg init test |
|
789 | $ hg init test | |
784 | $ cd test |
|
790 | $ cd test | |
785 | $ echo a > foo |
|
791 | $ echo a > foo | |
786 | $ hg ci -Aqm 'added a to foo' |
|
792 | $ hg ci -Aqm 'added a to foo' | |
787 |
|
793 | |||
788 | $ rm foo |
|
794 | $ rm foo | |
789 | $ touch foo |
|
795 | $ touch foo | |
790 | $ hg di |
|
796 | $ hg di | |
791 | diff --git a/foo b/foo |
|
797 | diff --git a/foo b/foo | |
792 | --- a/foo |
|
798 | --- a/foo | |
793 | +++ b/foo |
|
799 | +++ b/foo | |
794 | @@ -1,1 +0,0 @@ |
|
800 | @@ -1,1 +0,0 @@ | |
795 | -a |
|
801 | -a | |
796 |
|
802 | |||
797 | $ hg ci -m "make foo an empty file" |
|
803 | $ hg ci -m "make foo an empty file" | |
798 |
|
804 | |||
799 | $ hg up '.^' |
|
805 | $ hg up '.^' | |
800 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
806 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
801 | $ echo b > foo |
|
807 | $ echo b > foo | |
802 | $ hg di |
|
808 | $ hg di | |
803 | diff --git a/foo b/foo |
|
809 | diff --git a/foo b/foo | |
804 | --- a/foo |
|
810 | --- a/foo | |
805 | +++ b/foo |
|
811 | +++ b/foo | |
806 | @@ -1,1 +1,1 @@ |
|
812 | @@ -1,1 +1,1 @@ | |
807 | -a |
|
813 | -a | |
808 | +b |
|
814 | +b | |
809 | $ hg ci -m "add b to foo" |
|
815 | $ hg ci -m "add b to foo" | |
810 | created new head |
|
816 | created new head | |
811 |
|
817 | |||
812 | $ hg rebase -r . -d 1 --config ui.merge=internal:merge3 |
|
818 | $ hg rebase -r . -d 1 --config ui.merge=internal:merge3 | |
813 | rebasing 2:fb62b706688e "add b to foo" (tip) |
|
819 | rebasing 2:fb62b706688e "add b to foo" (tip) | |
814 | merging foo |
|
820 | merging foo | |
815 | hit merge conflicts; re-running rebase without in-memory merge |
|
821 | hit merge conflicts; re-running rebase without in-memory merge | |
816 | rebasing 2:fb62b706688e "add b to foo" (tip) |
|
822 | rebasing 2:fb62b706688e "add b to foo" (tip) | |
817 | merging foo |
|
823 | merging foo | |
818 | warning: conflicts while merging foo! (edit, then use 'hg resolve --mark') |
|
824 | warning: conflicts while merging foo! (edit, then use 'hg resolve --mark') | |
819 | unresolved conflicts (see hg resolve, then hg rebase --continue) |
|
825 | unresolved conflicts (see hg resolve, then hg rebase --continue) | |
820 | [1] |
|
826 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now