Show More
@@ -1,622 +1,625 | |||
|
1 | 1 | # context.py - changeset and file context objects for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | from node import nullid, nullrev, short |
|
9 | 9 | from i18n import _ |
|
10 | 10 | import ancestor, bdiff, revlog, util, os, errno |
|
11 | 11 | |
|
12 | 12 | class changectx(object): |
|
13 | 13 | """A changecontext object makes access to data related to a particular |
|
14 | 14 | changeset convenient.""" |
|
15 | 15 | def __init__(self, repo, changeid=None): |
|
16 | 16 | """changeid is a revision number, node, or tag""" |
|
17 | 17 | self._repo = repo |
|
18 | 18 | |
|
19 | 19 | if not changeid and changeid != 0: |
|
20 | 20 | p1, p2 = self._repo.dirstate.parents() |
|
21 | 21 | self._rev = self._repo.changelog.rev(p1) |
|
22 | 22 | if self._rev == -1: |
|
23 | 23 | changeid = 'tip' |
|
24 | 24 | else: |
|
25 | 25 | self._node = p1 |
|
26 | 26 | return |
|
27 | 27 | |
|
28 | 28 | self._node = self._repo.lookup(changeid) |
|
29 | 29 | self._rev = self._repo.changelog.rev(self._node) |
|
30 | 30 | |
|
31 | 31 | def __str__(self): |
|
32 | 32 | return short(self.node()) |
|
33 | 33 | |
|
34 | 34 | def __repr__(self): |
|
35 | 35 | return "<changectx %s>" % str(self) |
|
36 | 36 | |
|
37 | 37 | def __eq__(self, other): |
|
38 | 38 | try: |
|
39 | 39 | return self._rev == other._rev |
|
40 | 40 | except AttributeError: |
|
41 | 41 | return False |
|
42 | 42 | |
|
43 | 43 | def __ne__(self, other): |
|
44 | 44 | return not (self == other) |
|
45 | 45 | |
|
46 | 46 | def __nonzero__(self): |
|
47 | 47 | return self._rev != nullrev |
|
48 | 48 | |
|
49 | 49 | def __getattr__(self, name): |
|
50 | 50 | if name == '_changeset': |
|
51 | 51 | self._changeset = self._repo.changelog.read(self.node()) |
|
52 | 52 | return self._changeset |
|
53 | 53 | elif name == '_manifest': |
|
54 | 54 | self._manifest = self._repo.manifest.read(self._changeset[0]) |
|
55 | 55 | return self._manifest |
|
56 | 56 | elif name == '_manifestdelta': |
|
57 | 57 | md = self._repo.manifest.readdelta(self._changeset[0]) |
|
58 | 58 | self._manifestdelta = md |
|
59 | 59 | return self._manifestdelta |
|
60 | 60 | else: |
|
61 | 61 | raise AttributeError, name |
|
62 | 62 | |
|
63 | 63 | def __contains__(self, key): |
|
64 | 64 | return key in self._manifest |
|
65 | 65 | |
|
66 | 66 | def __getitem__(self, key): |
|
67 | 67 | return self.filectx(key) |
|
68 | 68 | |
|
69 | 69 | def __iter__(self): |
|
70 | 70 | a = self._manifest.keys() |
|
71 | 71 | a.sort() |
|
72 | 72 | for f in a: |
|
73 | 73 | yield f |
|
74 | 74 | |
|
75 | 75 | def changeset(self): return self._changeset |
|
76 | 76 | def manifest(self): return self._manifest |
|
77 | 77 | |
|
78 | 78 | def rev(self): return self._rev |
|
79 | 79 | def node(self): return self._node |
|
80 | 80 | def user(self): return self._changeset[1] |
|
81 | 81 | def date(self): return self._changeset[2] |
|
82 | 82 | def files(self): return self._changeset[3] |
|
83 | 83 | def description(self): return self._changeset[4] |
|
84 | 84 | def branch(self): return self._changeset[5].get("branch") |
|
85 | 85 | def extra(self): return self._changeset[5] |
|
86 | 86 | def tags(self): return self._repo.nodetags(self._node) |
|
87 | 87 | |
|
88 | 88 | def parents(self): |
|
89 | 89 | """return contexts for each parent changeset""" |
|
90 | 90 | p = self._repo.changelog.parents(self._node) |
|
91 | 91 | return [changectx(self._repo, x) for x in p] |
|
92 | 92 | |
|
93 | 93 | def children(self): |
|
94 | 94 | """return contexts for each child changeset""" |
|
95 | 95 | c = self._repo.changelog.children(self._node) |
|
96 | 96 | return [changectx(self._repo, x) for x in c] |
|
97 | 97 | |
|
98 | 98 | def _fileinfo(self, path): |
|
99 | 99 | if '_manifest' in self.__dict__: |
|
100 | 100 | try: |
|
101 | 101 | return self._manifest[path], self._manifest.flags(path) |
|
102 | 102 | except KeyError: |
|
103 | 103 | raise revlog.LookupError(self._node, path, |
|
104 | 104 | _('not found in manifest')) |
|
105 | 105 | if '_manifestdelta' in self.__dict__ or path in self.files(): |
|
106 | 106 | if path in self._manifestdelta: |
|
107 | 107 | return self._manifestdelta[path], self._manifestdelta.flags(path) |
|
108 | 108 | node, flag = self._repo.manifest.find(self._changeset[0], path) |
|
109 | 109 | if not node: |
|
110 | 110 | raise revlog.LookupError(self._node, path, |
|
111 | 111 | _('not found in manifest')) |
|
112 | 112 | |
|
113 | 113 | return node, flag |
|
114 | 114 | |
|
115 | 115 | def filenode(self, path): |
|
116 | 116 | return self._fileinfo(path)[0] |
|
117 | 117 | |
|
118 | 118 | def fileflags(self, path): |
|
119 | 119 | try: |
|
120 | 120 | return self._fileinfo(path)[1] |
|
121 | 121 | except revlog.LookupError: |
|
122 | 122 | return '' |
|
123 | 123 | |
|
124 | 124 | def filectx(self, path, fileid=None, filelog=None): |
|
125 | 125 | """get a file context from this changeset""" |
|
126 | 126 | if fileid is None: |
|
127 | 127 | fileid = self.filenode(path) |
|
128 | 128 | return filectx(self._repo, path, fileid=fileid, |
|
129 | 129 | changectx=self, filelog=filelog) |
|
130 | 130 | |
|
131 | 131 | def filectxs(self): |
|
132 | 132 | """generate a file context for each file in this changeset's |
|
133 | 133 | manifest""" |
|
134 | 134 | mf = self.manifest() |
|
135 | 135 | m = mf.keys() |
|
136 | 136 | m.sort() |
|
137 | 137 | for f in m: |
|
138 | 138 | yield self.filectx(f, fileid=mf[f]) |
|
139 | 139 | |
|
140 | 140 | def ancestor(self, c2): |
|
141 | 141 | """ |
|
142 | 142 | return the ancestor context of self and c2 |
|
143 | 143 | """ |
|
144 | 144 | n = self._repo.changelog.ancestor(self._node, c2._node) |
|
145 | 145 | return changectx(self._repo, n) |
|
146 | 146 | |
|
147 | 147 | class filectx(object): |
|
148 | 148 | """A filecontext object makes access to data related to a particular |
|
149 | 149 | filerevision convenient.""" |
|
150 | 150 | def __init__(self, repo, path, changeid=None, fileid=None, |
|
151 | 151 | filelog=None, changectx=None): |
|
152 | 152 | """changeid can be a changeset revision, node, or tag. |
|
153 | 153 | fileid can be a file revision or node.""" |
|
154 | 154 | self._repo = repo |
|
155 | 155 | self._path = path |
|
156 | 156 | |
|
157 | 157 | assert (changeid is not None |
|
158 | 158 | or fileid is not None |
|
159 | 159 | or changectx is not None) |
|
160 | 160 | |
|
161 | 161 | if filelog: |
|
162 | 162 | self._filelog = filelog |
|
163 | 163 | |
|
164 | 164 | if changeid is not None: |
|
165 | 165 | self._changeid = changeid |
|
166 | 166 | if changectx is not None: |
|
167 | 167 | self._changectx = changectx |
|
168 | 168 | if fileid is not None: |
|
169 | 169 | self._fileid = fileid |
|
170 | 170 | |
|
171 | 171 | def __getattr__(self, name): |
|
172 | 172 | if name == '_changectx': |
|
173 | 173 | self._changectx = changectx(self._repo, self._changeid) |
|
174 | 174 | return self._changectx |
|
175 | 175 | elif name == '_filelog': |
|
176 | 176 | self._filelog = self._repo.file(self._path) |
|
177 | 177 | return self._filelog |
|
178 | 178 | elif name == '_changeid': |
|
179 | 179 | if '_changectx' in self.__dict__: |
|
180 | 180 | self._changeid = self._changectx.rev() |
|
181 | 181 | else: |
|
182 | 182 | self._changeid = self._filelog.linkrev(self._filenode) |
|
183 | 183 | return self._changeid |
|
184 | 184 | elif name == '_filenode': |
|
185 | 185 | if '_fileid' in self.__dict__: |
|
186 | 186 | self._filenode = self._filelog.lookup(self._fileid) |
|
187 | 187 | else: |
|
188 | 188 | self._filenode = self._changectx.filenode(self._path) |
|
189 | 189 | return self._filenode |
|
190 | 190 | elif name == '_filerev': |
|
191 | 191 | self._filerev = self._filelog.rev(self._filenode) |
|
192 | 192 | return self._filerev |
|
193 | elif name == '_repopath': | |
|
194 | self._repopath = self._path | |
|
195 | return self._repopath | |
|
193 | 196 | else: |
|
194 | 197 | raise AttributeError, name |
|
195 | 198 | |
|
196 | 199 | def __nonzero__(self): |
|
197 | 200 | try: |
|
198 | 201 | n = self._filenode |
|
199 | 202 | return True |
|
200 | 203 | except revlog.LookupError: |
|
201 | 204 | # file is missing |
|
202 | 205 | return False |
|
203 | 206 | |
|
204 | 207 | def __str__(self): |
|
205 | 208 | return "%s@%s" % (self.path(), short(self.node())) |
|
206 | 209 | |
|
207 | 210 | def __repr__(self): |
|
208 | 211 | return "<filectx %s>" % str(self) |
|
209 | 212 | |
|
210 | 213 | def __eq__(self, other): |
|
211 | 214 | try: |
|
212 | 215 | return (self._path == other._path |
|
213 | 216 | and self._fileid == other._fileid) |
|
214 | 217 | except AttributeError: |
|
215 | 218 | return False |
|
216 | 219 | |
|
217 | 220 | def __ne__(self, other): |
|
218 | 221 | return not (self == other) |
|
219 | 222 | |
|
220 | 223 | def filectx(self, fileid): |
|
221 | 224 | '''opens an arbitrary revision of the file without |
|
222 | 225 | opening a new filelog''' |
|
223 | 226 | return filectx(self._repo, self._path, fileid=fileid, |
|
224 | 227 | filelog=self._filelog) |
|
225 | 228 | |
|
226 | 229 | def filerev(self): return self._filerev |
|
227 | 230 | def filenode(self): return self._filenode |
|
228 | 231 | def fileflags(self): return self._changectx.fileflags(self._path) |
|
229 | 232 | def isexec(self): return 'x' in self.fileflags() |
|
230 | 233 | def islink(self): return 'l' in self.fileflags() |
|
231 | 234 | def filelog(self): return self._filelog |
|
232 | 235 | |
|
233 | 236 | def rev(self): |
|
234 | 237 | if '_changectx' in self.__dict__: |
|
235 | 238 | return self._changectx.rev() |
|
236 | 239 | if '_changeid' in self.__dict__: |
|
237 | 240 | return self._changectx.rev() |
|
238 | 241 | return self._filelog.linkrev(self._filenode) |
|
239 | 242 | |
|
240 | 243 | def linkrev(self): return self._filelog.linkrev(self._filenode) |
|
241 | 244 | def node(self): return self._changectx.node() |
|
242 | 245 | def user(self): return self._changectx.user() |
|
243 | 246 | def date(self): return self._changectx.date() |
|
244 | 247 | def files(self): return self._changectx.files() |
|
245 | 248 | def description(self): return self._changectx.description() |
|
246 | 249 | def branch(self): return self._changectx.branch() |
|
247 | 250 | def manifest(self): return self._changectx.manifest() |
|
248 | 251 | def changectx(self): return self._changectx |
|
249 | 252 | |
|
250 | 253 | def data(self): return self._filelog.read(self._filenode) |
|
251 | 254 | def path(self): return self._path |
|
252 | 255 | def size(self): return self._filelog.size(self._filerev) |
|
253 | 256 | |
|
254 | 257 | def cmp(self, text): return self._filelog.cmp(self._filenode, text) |
|
255 | 258 | |
|
256 | 259 | def renamed(self): |
|
257 | 260 | """check if file was actually renamed in this changeset revision |
|
258 | 261 | |
|
259 | 262 | If rename logged in file revision, we report copy for changeset only |
|
260 | 263 | if file revisions linkrev points back to the changeset in question |
|
261 | 264 | or both changeset parents contain different file revisions. |
|
262 | 265 | """ |
|
263 | 266 | |
|
264 | 267 | renamed = self._filelog.renamed(self._filenode) |
|
265 | 268 | if not renamed: |
|
266 | 269 | return renamed |
|
267 | 270 | |
|
268 | 271 | if self.rev() == self.linkrev(): |
|
269 | 272 | return renamed |
|
270 | 273 | |
|
271 | 274 | name = self.path() |
|
272 | 275 | fnode = self._filenode |
|
273 | 276 | for p in self._changectx.parents(): |
|
274 | 277 | try: |
|
275 | 278 | if fnode == p.filenode(name): |
|
276 | 279 | return None |
|
277 | 280 | except revlog.LookupError: |
|
278 | 281 | pass |
|
279 | 282 | return renamed |
|
280 | 283 | |
|
281 | 284 | def parents(self): |
|
282 | 285 | p = self._path |
|
283 | 286 | fl = self._filelog |
|
284 | 287 | pl = [(p, n, fl) for n in self._filelog.parents(self._filenode)] |
|
285 | 288 | |
|
286 | 289 | r = self._filelog.renamed(self._filenode) |
|
287 | 290 | if r: |
|
288 | 291 | pl[0] = (r[0], r[1], None) |
|
289 | 292 | |
|
290 | 293 | return [filectx(self._repo, p, fileid=n, filelog=l) |
|
291 | 294 | for p,n,l in pl if n != nullid] |
|
292 | 295 | |
|
293 | 296 | def children(self): |
|
294 | 297 | # hard for renames |
|
295 | 298 | c = self._filelog.children(self._filenode) |
|
296 | 299 | return [filectx(self._repo, self._path, fileid=x, |
|
297 | 300 | filelog=self._filelog) for x in c] |
|
298 | 301 | |
|
299 | 302 | def annotate(self, follow=False, linenumber=None): |
|
300 | 303 | '''returns a list of tuples of (ctx, line) for each line |
|
301 | 304 | in the file, where ctx is the filectx of the node where |
|
302 | 305 | that line was last changed. |
|
303 | 306 | This returns tuples of ((ctx, linenumber), line) for each line, |
|
304 | 307 | if "linenumber" parameter is NOT "None". |
|
305 | 308 | In such tuples, linenumber means one at the first appearance |
|
306 | 309 | in the managed file. |
|
307 | 310 | To reduce annotation cost, |
|
308 | 311 | this returns fixed value(False is used) as linenumber, |
|
309 | 312 | if "linenumber" parameter is "False".''' |
|
310 | 313 | |
|
311 | 314 | def decorate_compat(text, rev): |
|
312 | 315 | return ([rev] * len(text.splitlines()), text) |
|
313 | 316 | |
|
314 | 317 | def without_linenumber(text, rev): |
|
315 | 318 | return ([(rev, False)] * len(text.splitlines()), text) |
|
316 | 319 | |
|
317 | 320 | def with_linenumber(text, rev): |
|
318 | 321 | size = len(text.splitlines()) |
|
319 | 322 | return ([(rev, i) for i in xrange(1, size + 1)], text) |
|
320 | 323 | |
|
321 | 324 | decorate = (((linenumber is None) and decorate_compat) or |
|
322 | 325 | (linenumber and with_linenumber) or |
|
323 | 326 | without_linenumber) |
|
324 | 327 | |
|
325 | 328 | def pair(parent, child): |
|
326 | 329 | for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): |
|
327 | 330 | child[0][b1:b2] = parent[0][a1:a2] |
|
328 | 331 | return child |
|
329 | 332 | |
|
330 | 333 | getlog = util.cachefunc(lambda x: self._repo.file(x)) |
|
331 | 334 | def getctx(path, fileid): |
|
332 | 335 | log = path == self._path and self._filelog or getlog(path) |
|
333 | 336 | return filectx(self._repo, path, fileid=fileid, filelog=log) |
|
334 | 337 | getctx = util.cachefunc(getctx) |
|
335 | 338 | |
|
336 | 339 | def parents(f): |
|
337 | 340 | # we want to reuse filectx objects as much as possible |
|
338 | 341 | p = f._path |
|
339 | 342 | if f._filerev is None: # working dir |
|
340 | 343 | pl = [(n.path(), n.filerev()) for n in f.parents()] |
|
341 | 344 | else: |
|
342 | 345 | pl = [(p, n) for n in f._filelog.parentrevs(f._filerev)] |
|
343 | 346 | |
|
344 | 347 | if follow: |
|
345 | 348 | r = f.renamed() |
|
346 | 349 | if r: |
|
347 | 350 | pl[0] = (r[0], getlog(r[0]).rev(r[1])) |
|
348 | 351 | |
|
349 | 352 | return [getctx(p, n) for p, n in pl if n != nullrev] |
|
350 | 353 | |
|
351 | 354 | # use linkrev to find the first changeset where self appeared |
|
352 | 355 | if self.rev() != self.linkrev(): |
|
353 | 356 | base = self.filectx(self.filerev()) |
|
354 | 357 | else: |
|
355 | 358 | base = self |
|
356 | 359 | |
|
357 | 360 | # find all ancestors |
|
358 | 361 | needed = {base: 1} |
|
359 | 362 | visit = [base] |
|
360 | 363 | files = [base._path] |
|
361 | 364 | while visit: |
|
362 | 365 | f = visit.pop(0) |
|
363 | 366 | for p in parents(f): |
|
364 | 367 | if p not in needed: |
|
365 | 368 | needed[p] = 1 |
|
366 | 369 | visit.append(p) |
|
367 | 370 | if p._path not in files: |
|
368 | 371 | files.append(p._path) |
|
369 | 372 | else: |
|
370 | 373 | # count how many times we'll use this |
|
371 | 374 | needed[p] += 1 |
|
372 | 375 | |
|
373 | 376 | # sort by revision (per file) which is a topological order |
|
374 | 377 | visit = [] |
|
375 | 378 | for f in files: |
|
376 | 379 | fn = [(n.rev(), n) for n in needed.keys() if n._path == f] |
|
377 | 380 | visit.extend(fn) |
|
378 | 381 | visit.sort() |
|
379 | 382 | hist = {} |
|
380 | 383 | |
|
381 | 384 | for r, f in visit: |
|
382 | 385 | curr = decorate(f.data(), f) |
|
383 | 386 | for p in parents(f): |
|
384 | 387 | if p != nullid: |
|
385 | 388 | curr = pair(hist[p], curr) |
|
386 | 389 | # trim the history of unneeded revs |
|
387 | 390 | needed[p] -= 1 |
|
388 | 391 | if not needed[p]: |
|
389 | 392 | del hist[p] |
|
390 | 393 | hist[f] = curr |
|
391 | 394 | |
|
392 | 395 | return zip(hist[f][0], hist[f][1].splitlines(1)) |
|
393 | 396 | |
|
394 | 397 | def ancestor(self, fc2): |
|
395 | 398 | """ |
|
396 | 399 | find the common ancestor file context, if any, of self, and fc2 |
|
397 | 400 | """ |
|
398 | 401 | |
|
399 | 402 | acache = {} |
|
400 | 403 | |
|
401 | 404 | # prime the ancestor cache for the working directory |
|
402 | 405 | for c in (self, fc2): |
|
403 | 406 | if c._filerev == None: |
|
404 | 407 | pl = [(n.path(), n.filenode()) for n in c.parents()] |
|
405 | 408 | acache[(c._path, None)] = pl |
|
406 | 409 | |
|
407 | flcache = {self._path:self._filelog, fc2._path:fc2._filelog} | |
|
410 | flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog} | |
|
408 | 411 | def parents(vertex): |
|
409 | 412 | if vertex in acache: |
|
410 | 413 | return acache[vertex] |
|
411 | 414 | f, n = vertex |
|
412 | 415 | if f not in flcache: |
|
413 | 416 | flcache[f] = self._repo.file(f) |
|
414 | 417 | fl = flcache[f] |
|
415 | 418 | pl = [(f, p) for p in fl.parents(n) if p != nullid] |
|
416 | 419 | re = fl.renamed(n) |
|
417 | 420 | if re: |
|
418 | 421 | pl.append(re) |
|
419 | 422 | acache[vertex] = pl |
|
420 | 423 | return pl |
|
421 | 424 | |
|
422 | 425 | a, b = (self._path, self._filenode), (fc2._path, fc2._filenode) |
|
423 | 426 | v = ancestor.ancestor(a, b, parents) |
|
424 | 427 | if v: |
|
425 | 428 | f, n = v |
|
426 | 429 | return filectx(self._repo, f, fileid=n, filelog=flcache[f]) |
|
427 | 430 | |
|
428 | 431 | return None |
|
429 | 432 | |
|
430 | 433 | class workingctx(changectx): |
|
431 | 434 | """A workingctx object makes access to data related to |
|
432 | 435 | the current working directory convenient.""" |
|
433 | 436 | def __init__(self, repo): |
|
434 | 437 | self._repo = repo |
|
435 | 438 | self._rev = None |
|
436 | 439 | self._node = None |
|
437 | 440 | |
|
438 | 441 | def __str__(self): |
|
439 | 442 | return str(self._parents[0]) + "+" |
|
440 | 443 | |
|
441 | 444 | def __nonzero__(self): |
|
442 | 445 | return True |
|
443 | 446 | |
|
444 | 447 | def __getattr__(self, name): |
|
445 | 448 | if name == '_parents': |
|
446 | 449 | self._parents = self._repo.parents() |
|
447 | 450 | return self._parents |
|
448 | 451 | if name == '_status': |
|
449 | 452 | self._status = self._repo.status() |
|
450 | 453 | return self._status |
|
451 | 454 | if name == '_manifest': |
|
452 | 455 | self._buildmanifest() |
|
453 | 456 | return self._manifest |
|
454 | 457 | else: |
|
455 | 458 | raise AttributeError, name |
|
456 | 459 | |
|
457 | 460 | def _buildmanifest(self): |
|
458 | 461 | """generate a manifest corresponding to the working directory""" |
|
459 | 462 | |
|
460 | 463 | man = self._parents[0].manifest().copy() |
|
461 | 464 | copied = self._repo.dirstate.copies() |
|
462 | 465 | is_exec = util.execfunc(self._repo.root, |
|
463 | 466 | lambda p: man.execf(copied.get(p,p))) |
|
464 | 467 | is_link = util.linkfunc(self._repo.root, |
|
465 | 468 | lambda p: man.linkf(copied.get(p,p))) |
|
466 | 469 | modified, added, removed, deleted, unknown = self._status[:5] |
|
467 | 470 | for i, l in (("a", added), ("m", modified), ("u", unknown)): |
|
468 | 471 | for f in l: |
|
469 | 472 | man[f] = man.get(copied.get(f, f), nullid) + i |
|
470 | 473 | try: |
|
471 | 474 | man.set(f, is_exec(f), is_link(f)) |
|
472 | 475 | except OSError: |
|
473 | 476 | pass |
|
474 | 477 | |
|
475 | 478 | for f in deleted + removed: |
|
476 | 479 | if f in man: |
|
477 | 480 | del man[f] |
|
478 | 481 | |
|
479 | 482 | self._manifest = man |
|
480 | 483 | |
|
481 | 484 | def manifest(self): return self._manifest |
|
482 | 485 | |
|
483 | 486 | def user(self): return self._repo.ui.username() |
|
484 | 487 | def date(self): return util.makedate() |
|
485 | 488 | def description(self): return "" |
|
486 | 489 | def files(self): |
|
487 | 490 | f = self.modified() + self.added() + self.removed() |
|
488 | 491 | f.sort() |
|
489 | 492 | return f |
|
490 | 493 | |
|
491 | 494 | def modified(self): return self._status[0] |
|
492 | 495 | def added(self): return self._status[1] |
|
493 | 496 | def removed(self): return self._status[2] |
|
494 | 497 | def deleted(self): return self._status[3] |
|
495 | 498 | def unknown(self): return self._status[4] |
|
496 | 499 | def clean(self): return self._status[5] |
|
497 | 500 | def branch(self): return self._repo.dirstate.branch() |
|
498 | 501 | |
|
499 | 502 | def tags(self): |
|
500 | 503 | t = [] |
|
501 | 504 | [t.extend(p.tags()) for p in self.parents()] |
|
502 | 505 | return t |
|
503 | 506 | |
|
504 | 507 | def parents(self): |
|
505 | 508 | """return contexts for each parent changeset""" |
|
506 | 509 | return self._parents |
|
507 | 510 | |
|
508 | 511 | def children(self): |
|
509 | 512 | return [] |
|
510 | 513 | |
|
511 | 514 | def fileflags(self, path): |
|
512 | 515 | if '_manifest' in self.__dict__: |
|
513 | 516 | try: |
|
514 | 517 | return self._manifest.flags(path) |
|
515 | 518 | except KeyError: |
|
516 | 519 | return '' |
|
517 | 520 | |
|
518 | 521 | pnode = self._parents[0].changeset()[0] |
|
519 | 522 | orig = self._repo.dirstate.copies().get(path, path) |
|
520 | 523 | node, flag = self._repo.manifest.find(pnode, orig) |
|
521 | 524 | is_link = util.linkfunc(self._repo.root, lambda p: 'l' in flag) |
|
522 | 525 | is_exec = util.execfunc(self._repo.root, lambda p: 'x' in flag) |
|
523 | 526 | try: |
|
524 | 527 | return (is_link(path) and 'l' or '') + (is_exec(path) and 'e' or '') |
|
525 | 528 | except OSError: |
|
526 | 529 | pass |
|
527 | 530 | |
|
528 | 531 | if not node or path in self.deleted() or path in self.removed(): |
|
529 | 532 | return '' |
|
530 | 533 | return flag |
|
531 | 534 | |
|
532 | 535 | def filectx(self, path, filelog=None): |
|
533 | 536 | """get a file context from the working directory""" |
|
534 | 537 | return workingfilectx(self._repo, path, workingctx=self, |
|
535 | 538 | filelog=filelog) |
|
536 | 539 | |
|
537 | 540 | def ancestor(self, c2): |
|
538 | 541 | """return the ancestor context of self and c2""" |
|
539 | 542 | return self._parents[0].ancestor(c2) # punt on two parents for now |
|
540 | 543 | |
|
541 | 544 | class workingfilectx(filectx): |
|
542 | 545 | """A workingfilectx object makes access to data related to a particular |
|
543 | 546 | file in the working directory convenient.""" |
|
544 | 547 | def __init__(self, repo, path, filelog=None, workingctx=None): |
|
545 | 548 | """changeid can be a changeset revision, node, or tag. |
|
546 | 549 | fileid can be a file revision or node.""" |
|
547 | 550 | self._repo = repo |
|
548 | 551 | self._path = path |
|
549 | 552 | self._changeid = None |
|
550 | 553 | self._filerev = self._filenode = None |
|
551 | 554 | |
|
552 | 555 | if filelog: |
|
553 | 556 | self._filelog = filelog |
|
554 | 557 | if workingctx: |
|
555 | 558 | self._changectx = workingctx |
|
556 | 559 | |
|
557 | 560 | def __getattr__(self, name): |
|
558 | 561 | if name == '_changectx': |
|
559 | 562 | self._changectx = workingctx(self._repo) |
|
560 | 563 | return self._changectx |
|
561 | 564 | elif name == '_repopath': |
|
562 | 565 | self._repopath = (self._repo.dirstate.copied(self._path) |
|
563 | 566 | or self._path) |
|
564 | 567 | return self._repopath |
|
565 | 568 | elif name == '_filelog': |
|
566 | 569 | self._filelog = self._repo.file(self._repopath) |
|
567 | 570 | return self._filelog |
|
568 | 571 | else: |
|
569 | 572 | raise AttributeError, name |
|
570 | 573 | |
|
571 | 574 | def __nonzero__(self): |
|
572 | 575 | return True |
|
573 | 576 | |
|
574 | 577 | def __str__(self): |
|
575 | 578 | return "%s@%s" % (self.path(), self._changectx) |
|
576 | 579 | |
|
577 | 580 | def filectx(self, fileid): |
|
578 | 581 | '''opens an arbitrary revision of the file without |
|
579 | 582 | opening a new filelog''' |
|
580 | 583 | return filectx(self._repo, self._repopath, fileid=fileid, |
|
581 | 584 | filelog=self._filelog) |
|
582 | 585 | |
|
583 | 586 | def rev(self): |
|
584 | 587 | if '_changectx' in self.__dict__: |
|
585 | 588 | return self._changectx.rev() |
|
586 | 589 | return self._filelog.linkrev(self._filenode) |
|
587 | 590 | |
|
588 | 591 | def data(self): return self._repo.wread(self._path) |
|
589 | 592 | def renamed(self): |
|
590 | 593 | rp = self._repopath |
|
591 | 594 | if rp == self._path: |
|
592 | 595 | return None |
|
593 | 596 | return rp, self._changectx._parents[0]._manifest.get(rp, nullid) |
|
594 | 597 | |
|
595 | 598 | def parents(self): |
|
596 | 599 | '''return parent filectxs, following copies if necessary''' |
|
597 | 600 | p = self._path |
|
598 | 601 | rp = self._repopath |
|
599 | 602 | pcl = self._changectx._parents |
|
600 | 603 | fl = self._filelog |
|
601 | 604 | pl = [(rp, pcl[0]._manifest.get(rp, nullid), fl)] |
|
602 | 605 | if len(pcl) > 1: |
|
603 | 606 | if rp != p: |
|
604 | 607 | fl = None |
|
605 | 608 | pl.append((p, pcl[1]._manifest.get(p, nullid), fl)) |
|
606 | 609 | |
|
607 | 610 | return [filectx(self._repo, p, fileid=n, filelog=l) |
|
608 | 611 | for p,n,l in pl if n != nullid] |
|
609 | 612 | |
|
610 | 613 | def children(self): |
|
611 | 614 | return [] |
|
612 | 615 | |
|
613 | 616 | def size(self): return os.stat(self._repo.wjoin(self._path)).st_size |
|
614 | 617 | def date(self): |
|
615 | 618 | t, tz = self._changectx.date() |
|
616 | 619 | try: |
|
617 | 620 | return (int(os.lstat(self._repo.wjoin(self._path)).st_mtime), tz) |
|
618 | 621 | except OSError, err: |
|
619 | 622 | if err.errno != errno.ENOENT: raise |
|
620 | 623 | return (t, tz) |
|
621 | 624 | |
|
622 | 625 | def cmp(self, text): return self._repo.wread(self._path) == text |
@@ -1,67 +1,68 | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | add() |
|
4 | 4 | { |
|
5 | 5 | echo $2 >> $1 |
|
6 | 6 | } |
|
7 | 7 | |
|
8 | 8 | hg init t |
|
9 | 9 | cd t |
|
10 | 10 | |
|
11 | 11 | # set up a boring main branch |
|
12 | 12 | add a a |
|
13 | 13 | hg add a |
|
14 | 14 | hg ci -m0 |
|
15 | 15 | |
|
16 | 16 | add a m1 |
|
17 | 17 | hg ci -m1 |
|
18 | 18 | |
|
19 | 19 | add a m2 |
|
20 | 20 | hg ci -m2 |
|
21 | 21 | |
|
22 | 22 | show() |
|
23 | 23 | { |
|
24 | 24 | echo "- $2: $1" |
|
25 | 25 | hg st -C $1 |
|
26 | 26 | echo |
|
27 | 27 | hg diff --git $1 |
|
28 | 28 | echo |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | count=0 |
|
32 | 32 | # make a new branch and get diff/status output |
|
33 | 33 | # $1 - first commit |
|
34 | 34 | # $2 - second commit |
|
35 | 35 | # $3 - working dir action |
|
36 | 36 | # $4 - test description |
|
37 | 37 | tb() |
|
38 | 38 | { |
|
39 | 39 | hg co -q -C 0 |
|
40 | 40 | |
|
41 | 41 | add a $count |
|
42 | 42 | count=`expr $count + 1` |
|
43 | 43 | hg ci -m "t0" |
|
44 | 44 | $1 |
|
45 | 45 | hg ci -m "t1" |
|
46 | 46 | $2 |
|
47 | 47 | hg ci -m "t2" |
|
48 | 48 | $3 |
|
49 | 49 | |
|
50 | 50 | echo "** $4 **" |
|
51 | 51 | echo "** $1 / $2 / $3" |
|
52 | 52 | show "" "working to parent" |
|
53 | 53 | show "--rev 0" "working to root" |
|
54 | 54 | show "--rev 2" "working to branch" |
|
55 | 55 | show "--rev 0 --rev ." "root to parent" |
|
56 | 56 | show "--rev . --rev 0" "parent to root" |
|
57 | 57 | show "--rev 2 --rev ." "branch to parent" |
|
58 | 58 | show "--rev . --rev 2" "parent to branch" |
|
59 | 59 | echo |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | tb "add a a1" "add a a2" "hg mv a b" "rename in working dir" |
|
63 | 63 | tb "add a a1" "add a a2" "hg cp a b" "copy in working dir" |
|
64 | 64 | tb "hg mv a b" "add b b1" "add b w" "single rename" |
|
65 | 65 | tb "hg cp a b" "add b b1" "add a w" "single copy" |
|
66 | 66 | tb "hg mv a b" "hg mv b c" "hg mv c d" "rename chain" |
|
67 | 67 | tb "hg cp a b" "hg cp b c" "hg cp c d" "copy chain" |
|
68 | tb "add a a1" "hg mv a b" "hg mv b a" "circular rename" |
@@ -1,795 +1,895 | |||
|
1 | 1 | ** rename in working dir ** |
|
2 | 2 | ** add a a1 / add a a2 / hg mv a b |
|
3 | 3 | - working to parent: |
|
4 | 4 | A b |
|
5 | 5 | a |
|
6 | 6 | R a |
|
7 | 7 | |
|
8 | 8 | diff --git a/a b/b |
|
9 | 9 | rename from a |
|
10 | 10 | rename to b |
|
11 | 11 | |
|
12 | 12 | - working to root: --rev 0 |
|
13 | 13 | A b |
|
14 | 14 | a |
|
15 | 15 | R a |
|
16 | 16 | |
|
17 | 17 | diff --git a/a b/b |
|
18 | 18 | rename from a |
|
19 | 19 | rename to b |
|
20 | 20 | --- a/a |
|
21 | 21 | +++ b/b |
|
22 | 22 | @@ -1,1 +1,4 @@ |
|
23 | 23 | a |
|
24 | 24 | +0 |
|
25 | 25 | +a1 |
|
26 | 26 | +a2 |
|
27 | 27 | |
|
28 | 28 | - working to branch: --rev 2 |
|
29 | 29 | A b |
|
30 | 30 | a |
|
31 | 31 | R a |
|
32 | 32 | |
|
33 | 33 | diff --git a/a b/b |
|
34 | 34 | rename from a |
|
35 | 35 | rename to b |
|
36 | 36 | --- a/a |
|
37 | 37 | +++ b/b |
|
38 | 38 | @@ -1,3 +1,4 @@ |
|
39 | 39 | a |
|
40 | 40 | -m1 |
|
41 | 41 | -m2 |
|
42 | 42 | +0 |
|
43 | 43 | +a1 |
|
44 | 44 | +a2 |
|
45 | 45 | |
|
46 | 46 | - root to parent: --rev 0 --rev . |
|
47 | 47 | M a |
|
48 | 48 | |
|
49 | 49 | diff --git a/a b/a |
|
50 | 50 | --- a/a |
|
51 | 51 | +++ b/a |
|
52 | 52 | @@ -1,1 +1,4 @@ |
|
53 | 53 | a |
|
54 | 54 | +0 |
|
55 | 55 | +a1 |
|
56 | 56 | +a2 |
|
57 | 57 | |
|
58 | 58 | - parent to root: --rev . --rev 0 |
|
59 | 59 | M a |
|
60 | 60 | |
|
61 | 61 | diff --git a/a b/a |
|
62 | 62 | --- a/a |
|
63 | 63 | +++ b/a |
|
64 | 64 | @@ -1,4 +1,1 @@ |
|
65 | 65 | a |
|
66 | 66 | -0 |
|
67 | 67 | -a1 |
|
68 | 68 | -a2 |
|
69 | 69 | |
|
70 | 70 | - branch to parent: --rev 2 --rev . |
|
71 | 71 | M a |
|
72 | 72 | |
|
73 | 73 | diff --git a/a b/a |
|
74 | 74 | --- a/a |
|
75 | 75 | +++ b/a |
|
76 | 76 | @@ -1,3 +1,4 @@ |
|
77 | 77 | a |
|
78 | 78 | -m1 |
|
79 | 79 | -m2 |
|
80 | 80 | +0 |
|
81 | 81 | +a1 |
|
82 | 82 | +a2 |
|
83 | 83 | |
|
84 | 84 | - parent to branch: --rev . --rev 2 |
|
85 | 85 | M a |
|
86 | 86 | |
|
87 | 87 | diff --git a/a b/a |
|
88 | 88 | --- a/a |
|
89 | 89 | +++ b/a |
|
90 | 90 | @@ -1,4 +1,3 @@ |
|
91 | 91 | a |
|
92 | 92 | -0 |
|
93 | 93 | -a1 |
|
94 | 94 | -a2 |
|
95 | 95 | +m1 |
|
96 | 96 | +m2 |
|
97 | 97 | |
|
98 | 98 | |
|
99 | 99 | ** copy in working dir ** |
|
100 | 100 | ** add a a1 / add a a2 / hg cp a b |
|
101 | 101 | - working to parent: |
|
102 | 102 | A b |
|
103 | 103 | a |
|
104 | 104 | |
|
105 | 105 | diff --git a/a b/b |
|
106 | 106 | copy from a |
|
107 | 107 | copy to b |
|
108 | 108 | |
|
109 | 109 | - working to root: --rev 0 |
|
110 | 110 | M a |
|
111 | 111 | A b |
|
112 | 112 | a |
|
113 | 113 | |
|
114 | 114 | diff --git a/a b/a |
|
115 | 115 | --- a/a |
|
116 | 116 | +++ b/a |
|
117 | 117 | @@ -1,1 +1,4 @@ |
|
118 | 118 | a |
|
119 | 119 | +1 |
|
120 | 120 | +a1 |
|
121 | 121 | +a2 |
|
122 | 122 | diff --git a/a b/b |
|
123 | 123 | copy from a |
|
124 | 124 | copy to b |
|
125 | 125 | --- a/a |
|
126 | 126 | +++ b/b |
|
127 | 127 | @@ -1,1 +1,4 @@ |
|
128 | 128 | a |
|
129 | 129 | +1 |
|
130 | 130 | +a1 |
|
131 | 131 | +a2 |
|
132 | 132 | |
|
133 | 133 | - working to branch: --rev 2 |
|
134 | 134 | M a |
|
135 | 135 | A b |
|
136 | 136 | a |
|
137 | 137 | |
|
138 | 138 | diff --git a/a b/a |
|
139 | 139 | --- a/a |
|
140 | 140 | +++ b/a |
|
141 | 141 | @@ -1,3 +1,4 @@ |
|
142 | 142 | a |
|
143 | 143 | -m1 |
|
144 | 144 | -m2 |
|
145 | 145 | +1 |
|
146 | 146 | +a1 |
|
147 | 147 | +a2 |
|
148 | 148 | diff --git a/a b/b |
|
149 | 149 | copy from a |
|
150 | 150 | copy to b |
|
151 | 151 | --- a/a |
|
152 | 152 | +++ b/b |
|
153 | 153 | @@ -1,3 +1,4 @@ |
|
154 | 154 | a |
|
155 | 155 | -m1 |
|
156 | 156 | -m2 |
|
157 | 157 | +1 |
|
158 | 158 | +a1 |
|
159 | 159 | +a2 |
|
160 | 160 | |
|
161 | 161 | - root to parent: --rev 0 --rev . |
|
162 | 162 | M a |
|
163 | 163 | |
|
164 | 164 | diff --git a/a b/a |
|
165 | 165 | --- a/a |
|
166 | 166 | +++ b/a |
|
167 | 167 | @@ -1,1 +1,4 @@ |
|
168 | 168 | a |
|
169 | 169 | +1 |
|
170 | 170 | +a1 |
|
171 | 171 | +a2 |
|
172 | 172 | |
|
173 | 173 | - parent to root: --rev . --rev 0 |
|
174 | 174 | M a |
|
175 | 175 | |
|
176 | 176 | diff --git a/a b/a |
|
177 | 177 | --- a/a |
|
178 | 178 | +++ b/a |
|
179 | 179 | @@ -1,4 +1,1 @@ |
|
180 | 180 | a |
|
181 | 181 | -1 |
|
182 | 182 | -a1 |
|
183 | 183 | -a2 |
|
184 | 184 | |
|
185 | 185 | - branch to parent: --rev 2 --rev . |
|
186 | 186 | M a |
|
187 | 187 | |
|
188 | 188 | diff --git a/a b/a |
|
189 | 189 | --- a/a |
|
190 | 190 | +++ b/a |
|
191 | 191 | @@ -1,3 +1,4 @@ |
|
192 | 192 | a |
|
193 | 193 | -m1 |
|
194 | 194 | -m2 |
|
195 | 195 | +1 |
|
196 | 196 | +a1 |
|
197 | 197 | +a2 |
|
198 | 198 | |
|
199 | 199 | - parent to branch: --rev . --rev 2 |
|
200 | 200 | M a |
|
201 | 201 | |
|
202 | 202 | diff --git a/a b/a |
|
203 | 203 | --- a/a |
|
204 | 204 | +++ b/a |
|
205 | 205 | @@ -1,4 +1,3 @@ |
|
206 | 206 | a |
|
207 | 207 | -1 |
|
208 | 208 | -a1 |
|
209 | 209 | -a2 |
|
210 | 210 | +m1 |
|
211 | 211 | +m2 |
|
212 | 212 | |
|
213 | 213 | |
|
214 | 214 | ** single rename ** |
|
215 | 215 | ** hg mv a b / add b b1 / add b w |
|
216 | 216 | - working to parent: |
|
217 | 217 | M b |
|
218 | 218 | |
|
219 | 219 | diff --git a/b b/b |
|
220 | 220 | --- a/b |
|
221 | 221 | +++ b/b |
|
222 | 222 | @@ -1,3 +1,4 @@ |
|
223 | 223 | a |
|
224 | 224 | 2 |
|
225 | 225 | b1 |
|
226 | 226 | +w |
|
227 | 227 | |
|
228 | 228 | - working to root: --rev 0 |
|
229 | 229 | A b |
|
230 | 230 | a |
|
231 | 231 | R a |
|
232 | 232 | |
|
233 | 233 | diff --git a/a b/b |
|
234 | 234 | rename from a |
|
235 | 235 | rename to b |
|
236 | 236 | --- a/a |
|
237 | 237 | +++ b/b |
|
238 | 238 | @@ -1,1 +1,4 @@ |
|
239 | 239 | a |
|
240 | 240 | +2 |
|
241 | 241 | +b1 |
|
242 | 242 | +w |
|
243 | 243 | |
|
244 | 244 | - working to branch: --rev 2 |
|
245 | 245 | A b |
|
246 | 246 | a |
|
247 | 247 | R a |
|
248 | 248 | |
|
249 | 249 | diff --git a/a b/b |
|
250 | 250 | rename from a |
|
251 | 251 | rename to b |
|
252 | 252 | --- a/a |
|
253 | 253 | +++ b/b |
|
254 | 254 | @@ -1,3 +1,4 @@ |
|
255 | 255 | a |
|
256 | 256 | -m1 |
|
257 | 257 | -m2 |
|
258 | 258 | +2 |
|
259 | 259 | +b1 |
|
260 | 260 | +w |
|
261 | 261 | |
|
262 | 262 | - root to parent: --rev 0 --rev . |
|
263 | 263 | A b |
|
264 | 264 | a |
|
265 | 265 | R a |
|
266 | 266 | |
|
267 | 267 | diff --git a/a b/b |
|
268 | 268 | rename from a |
|
269 | 269 | rename to b |
|
270 | 270 | --- a/a |
|
271 | 271 | +++ b/b |
|
272 | 272 | @@ -1,1 +1,3 @@ |
|
273 | 273 | a |
|
274 | 274 | +2 |
|
275 | 275 | +b1 |
|
276 | 276 | |
|
277 | 277 | - parent to root: --rev . --rev 0 |
|
278 | 278 | A a |
|
279 | 279 | b |
|
280 | 280 | R b |
|
281 | 281 | |
|
282 | 282 | diff --git a/b b/a |
|
283 | 283 | rename from b |
|
284 | 284 | rename to a |
|
285 | 285 | --- a/b |
|
286 | 286 | +++ b/a |
|
287 | 287 | @@ -1,3 +1,1 @@ |
|
288 | 288 | a |
|
289 | 289 | -2 |
|
290 | 290 | -b1 |
|
291 | 291 | |
|
292 | 292 | - branch to parent: --rev 2 --rev . |
|
293 | 293 | A b |
|
294 | 294 | a |
|
295 | 295 | R a |
|
296 | 296 | |
|
297 | 297 | diff --git a/a b/b |
|
298 | 298 | rename from a |
|
299 | 299 | rename to b |
|
300 | 300 | --- a/a |
|
301 | 301 | +++ b/b |
|
302 | 302 | @@ -1,3 +1,3 @@ |
|
303 | 303 | a |
|
304 | 304 | -m1 |
|
305 | 305 | -m2 |
|
306 | 306 | +2 |
|
307 | 307 | +b1 |
|
308 | 308 | |
|
309 | 309 | - parent to branch: --rev . --rev 2 |
|
310 | 310 | A a |
|
311 | 311 | b |
|
312 | 312 | R b |
|
313 | 313 | |
|
314 | 314 | diff --git a/b b/a |
|
315 | 315 | rename from b |
|
316 | 316 | rename to a |
|
317 | 317 | --- a/b |
|
318 | 318 | +++ b/a |
|
319 | 319 | @@ -1,3 +1,3 @@ |
|
320 | 320 | a |
|
321 | 321 | -2 |
|
322 | 322 | -b1 |
|
323 | 323 | +m1 |
|
324 | 324 | +m2 |
|
325 | 325 | |
|
326 | 326 | |
|
327 | 327 | ** single copy ** |
|
328 | 328 | ** hg cp a b / add b b1 / add a w |
|
329 | 329 | - working to parent: |
|
330 | 330 | M a |
|
331 | 331 | |
|
332 | 332 | diff --git a/a b/a |
|
333 | 333 | --- a/a |
|
334 | 334 | +++ b/a |
|
335 | 335 | @@ -1,2 +1,3 @@ |
|
336 | 336 | a |
|
337 | 337 | 3 |
|
338 | 338 | +w |
|
339 | 339 | |
|
340 | 340 | - working to root: --rev 0 |
|
341 | 341 | M a |
|
342 | 342 | A b |
|
343 | 343 | a |
|
344 | 344 | |
|
345 | 345 | diff --git a/a b/a |
|
346 | 346 | --- a/a |
|
347 | 347 | +++ b/a |
|
348 | 348 | @@ -1,1 +1,3 @@ |
|
349 | 349 | a |
|
350 | 350 | +3 |
|
351 | 351 | +w |
|
352 | 352 | diff --git a/a b/b |
|
353 | 353 | copy from a |
|
354 | 354 | copy to b |
|
355 | 355 | --- a/a |
|
356 | 356 | +++ b/b |
|
357 | 357 | @@ -1,1 +1,3 @@ |
|
358 | 358 | a |
|
359 | 359 | +3 |
|
360 | 360 | +b1 |
|
361 | 361 | |
|
362 | 362 | - working to branch: --rev 2 |
|
363 | 363 | M a |
|
364 | 364 | A b |
|
365 | 365 | a |
|
366 | 366 | |
|
367 | 367 | diff --git a/a b/a |
|
368 | 368 | --- a/a |
|
369 | 369 | +++ b/a |
|
370 | 370 | @@ -1,3 +1,3 @@ |
|
371 | 371 | a |
|
372 | 372 | -m1 |
|
373 | 373 | -m2 |
|
374 | 374 | +3 |
|
375 | 375 | +w |
|
376 | 376 | diff --git a/a b/b |
|
377 | 377 | copy from a |
|
378 | 378 | copy to b |
|
379 | 379 | --- a/a |
|
380 | 380 | +++ b/b |
|
381 | 381 | @@ -1,3 +1,3 @@ |
|
382 | 382 | a |
|
383 | 383 | -m1 |
|
384 | 384 | -m2 |
|
385 | 385 | +3 |
|
386 | 386 | +b1 |
|
387 | 387 | |
|
388 | 388 | - root to parent: --rev 0 --rev . |
|
389 | 389 | M a |
|
390 | 390 | A b |
|
391 | 391 | a |
|
392 | 392 | |
|
393 | 393 | diff --git a/a b/a |
|
394 | 394 | --- a/a |
|
395 | 395 | +++ b/a |
|
396 | 396 | @@ -1,1 +1,2 @@ |
|
397 | 397 | a |
|
398 | 398 | +3 |
|
399 | 399 | diff --git a/a b/b |
|
400 | 400 | copy from a |
|
401 | 401 | copy to b |
|
402 | 402 | --- a/a |
|
403 | 403 | +++ b/b |
|
404 | 404 | @@ -1,1 +1,3 @@ |
|
405 | 405 | a |
|
406 | 406 | +3 |
|
407 | 407 | +b1 |
|
408 | 408 | |
|
409 | 409 | - parent to root: --rev . --rev 0 |
|
410 | 410 | M a |
|
411 | 411 | R b |
|
412 | 412 | |
|
413 | 413 | diff --git a/a b/a |
|
414 | 414 | --- a/a |
|
415 | 415 | +++ b/a |
|
416 | 416 | @@ -1,2 +1,1 @@ |
|
417 | 417 | a |
|
418 | 418 | -3 |
|
419 | 419 | diff --git a/b b/b |
|
420 | 420 | deleted file mode 100644 |
|
421 | 421 | --- a/b |
|
422 | 422 | +++ /dev/null |
|
423 | 423 | @@ -1,3 +0,0 @@ |
|
424 | 424 | -a |
|
425 | 425 | -3 |
|
426 | 426 | -b1 |
|
427 | 427 | |
|
428 | 428 | - branch to parent: --rev 2 --rev . |
|
429 | 429 | M a |
|
430 | 430 | A b |
|
431 | 431 | a |
|
432 | 432 | |
|
433 | 433 | diff --git a/a b/a |
|
434 | 434 | --- a/a |
|
435 | 435 | +++ b/a |
|
436 | 436 | @@ -1,3 +1,2 @@ |
|
437 | 437 | a |
|
438 | 438 | -m1 |
|
439 | 439 | -m2 |
|
440 | 440 | +3 |
|
441 | 441 | diff --git a/a b/b |
|
442 | 442 | copy from a |
|
443 | 443 | copy to b |
|
444 | 444 | --- a/a |
|
445 | 445 | +++ b/b |
|
446 | 446 | @@ -1,3 +1,3 @@ |
|
447 | 447 | a |
|
448 | 448 | -m1 |
|
449 | 449 | -m2 |
|
450 | 450 | +3 |
|
451 | 451 | +b1 |
|
452 | 452 | |
|
453 | 453 | - parent to branch: --rev . --rev 2 |
|
454 | 454 | M a |
|
455 | 455 | R b |
|
456 | 456 | |
|
457 | 457 | diff --git a/a b/a |
|
458 | 458 | --- a/a |
|
459 | 459 | +++ b/a |
|
460 | 460 | @@ -1,2 +1,3 @@ |
|
461 | 461 | a |
|
462 | 462 | -3 |
|
463 | 463 | +m1 |
|
464 | 464 | +m2 |
|
465 | 465 | diff --git a/b b/b |
|
466 | 466 | deleted file mode 100644 |
|
467 | 467 | --- a/b |
|
468 | 468 | +++ /dev/null |
|
469 | 469 | @@ -1,3 +0,0 @@ |
|
470 | 470 | -a |
|
471 | 471 | -3 |
|
472 | 472 | -b1 |
|
473 | 473 | |
|
474 | 474 | |
|
475 | 475 | ** rename chain ** |
|
476 | 476 | ** hg mv a b / hg mv b c / hg mv c d |
|
477 | 477 | - working to parent: |
|
478 | 478 | A d |
|
479 | 479 | c |
|
480 | 480 | R c |
|
481 | 481 | |
|
482 | 482 | diff --git a/c b/d |
|
483 | 483 | rename from c |
|
484 | 484 | rename to d |
|
485 | 485 | |
|
486 | 486 | - working to root: --rev 0 |
|
487 | 487 | A d |
|
488 | 488 | a |
|
489 | 489 | R a |
|
490 | 490 | |
|
491 | 491 | diff --git a/a b/d |
|
492 | 492 | rename from a |
|
493 | 493 | rename to d |
|
494 | 494 | --- a/a |
|
495 | 495 | +++ b/d |
|
496 | 496 | @@ -1,1 +1,2 @@ |
|
497 | 497 | a |
|
498 | 498 | +4 |
|
499 | 499 | |
|
500 | 500 | - working to branch: --rev 2 |
|
501 | 501 | A d |
|
502 | 502 | a |
|
503 | 503 | R a |
|
504 | 504 | |
|
505 | 505 | diff --git a/a b/d |
|
506 | 506 | rename from a |
|
507 | 507 | rename to d |
|
508 | 508 | --- a/a |
|
509 | 509 | +++ b/d |
|
510 | 510 | @@ -1,3 +1,2 @@ |
|
511 | 511 | a |
|
512 | 512 | -m1 |
|
513 | 513 | -m2 |
|
514 | 514 | +4 |
|
515 | 515 | |
|
516 | 516 | - root to parent: --rev 0 --rev . |
|
517 | 517 | A c |
|
518 | 518 | a |
|
519 | 519 | R a |
|
520 | 520 | |
|
521 | 521 | diff --git a/a b/c |
|
522 | 522 | rename from a |
|
523 | 523 | rename to c |
|
524 | 524 | --- a/a |
|
525 | 525 | +++ b/c |
|
526 | 526 | @@ -1,1 +1,2 @@ |
|
527 | 527 | a |
|
528 | 528 | +4 |
|
529 | 529 | |
|
530 | 530 | - parent to root: --rev . --rev 0 |
|
531 | 531 | A a |
|
532 | 532 | c |
|
533 | 533 | R c |
|
534 | 534 | |
|
535 | 535 | diff --git a/c b/a |
|
536 | 536 | rename from c |
|
537 | 537 | rename to a |
|
538 | 538 | --- a/c |
|
539 | 539 | +++ b/a |
|
540 | 540 | @@ -1,2 +1,1 @@ |
|
541 | 541 | a |
|
542 | 542 | -4 |
|
543 | 543 | |
|
544 | 544 | - branch to parent: --rev 2 --rev . |
|
545 | 545 | A c |
|
546 | 546 | a |
|
547 | 547 | R a |
|
548 | 548 | |
|
549 | 549 | diff --git a/a b/c |
|
550 | 550 | rename from a |
|
551 | 551 | rename to c |
|
552 | 552 | --- a/a |
|
553 | 553 | +++ b/c |
|
554 | 554 | @@ -1,3 +1,2 @@ |
|
555 | 555 | a |
|
556 | 556 | -m1 |
|
557 | 557 | -m2 |
|
558 | 558 | +4 |
|
559 | 559 | |
|
560 | 560 | - parent to branch: --rev . --rev 2 |
|
561 | 561 | A a |
|
562 | 562 | c |
|
563 | 563 | R c |
|
564 | 564 | |
|
565 | 565 | diff --git a/c b/a |
|
566 | 566 | rename from c |
|
567 | 567 | rename to a |
|
568 | 568 | --- a/c |
|
569 | 569 | +++ b/a |
|
570 | 570 | @@ -1,2 +1,3 @@ |
|
571 | 571 | a |
|
572 | 572 | -4 |
|
573 | 573 | +m1 |
|
574 | 574 | +m2 |
|
575 | 575 | |
|
576 | 576 | |
|
577 | 577 | ** copy chain ** |
|
578 | 578 | ** hg cp a b / hg cp b c / hg cp c d |
|
579 | 579 | - working to parent: |
|
580 | 580 | A d |
|
581 | 581 | c |
|
582 | 582 | |
|
583 | 583 | diff --git a/c b/d |
|
584 | 584 | copy from c |
|
585 | 585 | copy to d |
|
586 | 586 | |
|
587 | 587 | - working to root: --rev 0 |
|
588 | 588 | M a |
|
589 | 589 | A b |
|
590 | 590 | a |
|
591 | 591 | A c |
|
592 | 592 | a |
|
593 | 593 | A d |
|
594 | 594 | a |
|
595 | 595 | |
|
596 | 596 | diff --git a/a b/a |
|
597 | 597 | --- a/a |
|
598 | 598 | +++ b/a |
|
599 | 599 | @@ -1,1 +1,2 @@ |
|
600 | 600 | a |
|
601 | 601 | +5 |
|
602 | 602 | diff --git a/a b/b |
|
603 | 603 | copy from a |
|
604 | 604 | copy to b |
|
605 | 605 | --- a/a |
|
606 | 606 | +++ b/b |
|
607 | 607 | @@ -1,1 +1,2 @@ |
|
608 | 608 | a |
|
609 | 609 | +5 |
|
610 | 610 | diff --git a/a b/c |
|
611 | 611 | copy from a |
|
612 | 612 | copy to c |
|
613 | 613 | --- a/a |
|
614 | 614 | +++ b/c |
|
615 | 615 | @@ -1,1 +1,2 @@ |
|
616 | 616 | a |
|
617 | 617 | +5 |
|
618 | 618 | diff --git a/a b/d |
|
619 | 619 | copy from a |
|
620 | 620 | copy to d |
|
621 | 621 | --- a/a |
|
622 | 622 | +++ b/d |
|
623 | 623 | @@ -1,1 +1,2 @@ |
|
624 | 624 | a |
|
625 | 625 | +5 |
|
626 | 626 | |
|
627 | 627 | - working to branch: --rev 2 |
|
628 | 628 | M a |
|
629 | 629 | A b |
|
630 | 630 | a |
|
631 | 631 | A c |
|
632 | 632 | a |
|
633 | 633 | A d |
|
634 | 634 | a |
|
635 | 635 | |
|
636 | 636 | diff --git a/a b/a |
|
637 | 637 | --- a/a |
|
638 | 638 | +++ b/a |
|
639 | 639 | @@ -1,3 +1,2 @@ |
|
640 | 640 | a |
|
641 | 641 | -m1 |
|
642 | 642 | -m2 |
|
643 | 643 | +5 |
|
644 | 644 | diff --git a/a b/b |
|
645 | 645 | copy from a |
|
646 | 646 | copy to b |
|
647 | 647 | --- a/a |
|
648 | 648 | +++ b/b |
|
649 | 649 | @@ -1,3 +1,2 @@ |
|
650 | 650 | a |
|
651 | 651 | -m1 |
|
652 | 652 | -m2 |
|
653 | 653 | +5 |
|
654 | 654 | diff --git a/a b/c |
|
655 | 655 | copy from a |
|
656 | 656 | copy to c |
|
657 | 657 | --- a/a |
|
658 | 658 | +++ b/c |
|
659 | 659 | @@ -1,3 +1,2 @@ |
|
660 | 660 | a |
|
661 | 661 | -m1 |
|
662 | 662 | -m2 |
|
663 | 663 | +5 |
|
664 | 664 | diff --git a/a b/d |
|
665 | 665 | copy from a |
|
666 | 666 | copy to d |
|
667 | 667 | --- a/a |
|
668 | 668 | +++ b/d |
|
669 | 669 | @@ -1,3 +1,2 @@ |
|
670 | 670 | a |
|
671 | 671 | -m1 |
|
672 | 672 | -m2 |
|
673 | 673 | +5 |
|
674 | 674 | |
|
675 | 675 | - root to parent: --rev 0 --rev . |
|
676 | 676 | M a |
|
677 | 677 | A b |
|
678 | 678 | a |
|
679 | 679 | A c |
|
680 | 680 | a |
|
681 | 681 | |
|
682 | 682 | diff --git a/a b/a |
|
683 | 683 | --- a/a |
|
684 | 684 | +++ b/a |
|
685 | 685 | @@ -1,1 +1,2 @@ |
|
686 | 686 | a |
|
687 | 687 | +5 |
|
688 | 688 | diff --git a/a b/b |
|
689 | 689 | copy from a |
|
690 | 690 | copy to b |
|
691 | 691 | --- a/a |
|
692 | 692 | +++ b/b |
|
693 | 693 | @@ -1,1 +1,2 @@ |
|
694 | 694 | a |
|
695 | 695 | +5 |
|
696 | 696 | diff --git a/a b/c |
|
697 | 697 | copy from a |
|
698 | 698 | copy to c |
|
699 | 699 | --- a/a |
|
700 | 700 | +++ b/c |
|
701 | 701 | @@ -1,1 +1,2 @@ |
|
702 | 702 | a |
|
703 | 703 | +5 |
|
704 | 704 | |
|
705 | 705 | - parent to root: --rev . --rev 0 |
|
706 | 706 | M a |
|
707 | 707 | R b |
|
708 | 708 | R c |
|
709 | 709 | |
|
710 | 710 | diff --git a/a b/a |
|
711 | 711 | --- a/a |
|
712 | 712 | +++ b/a |
|
713 | 713 | @@ -1,2 +1,1 @@ |
|
714 | 714 | a |
|
715 | 715 | -5 |
|
716 | 716 | diff --git a/b b/b |
|
717 | 717 | deleted file mode 100644 |
|
718 | 718 | --- a/b |
|
719 | 719 | +++ /dev/null |
|
720 | 720 | @@ -1,2 +0,0 @@ |
|
721 | 721 | -a |
|
722 | 722 | -5 |
|
723 | 723 | diff --git a/c b/c |
|
724 | 724 | deleted file mode 100644 |
|
725 | 725 | --- a/c |
|
726 | 726 | +++ /dev/null |
|
727 | 727 | @@ -1,2 +0,0 @@ |
|
728 | 728 | -a |
|
729 | 729 | -5 |
|
730 | 730 | |
|
731 | 731 | - branch to parent: --rev 2 --rev . |
|
732 | 732 | M a |
|
733 | 733 | A b |
|
734 | 734 | a |
|
735 | 735 | A c |
|
736 | 736 | a |
|
737 | 737 | |
|
738 | 738 | diff --git a/a b/a |
|
739 | 739 | --- a/a |
|
740 | 740 | +++ b/a |
|
741 | 741 | @@ -1,3 +1,2 @@ |
|
742 | 742 | a |
|
743 | 743 | -m1 |
|
744 | 744 | -m2 |
|
745 | 745 | +5 |
|
746 | 746 | diff --git a/a b/b |
|
747 | 747 | copy from a |
|
748 | 748 | copy to b |
|
749 | 749 | --- a/a |
|
750 | 750 | +++ b/b |
|
751 | 751 | @@ -1,3 +1,2 @@ |
|
752 | 752 | a |
|
753 | 753 | -m1 |
|
754 | 754 | -m2 |
|
755 | 755 | +5 |
|
756 | 756 | diff --git a/a b/c |
|
757 | 757 | copy from a |
|
758 | 758 | copy to c |
|
759 | 759 | --- a/a |
|
760 | 760 | +++ b/c |
|
761 | 761 | @@ -1,3 +1,2 @@ |
|
762 | 762 | a |
|
763 | 763 | -m1 |
|
764 | 764 | -m2 |
|
765 | 765 | +5 |
|
766 | 766 | |
|
767 | 767 | - parent to branch: --rev . --rev 2 |
|
768 | 768 | M a |
|
769 | 769 | R b |
|
770 | 770 | R c |
|
771 | 771 | |
|
772 | 772 | diff --git a/a b/a |
|
773 | 773 | --- a/a |
|
774 | 774 | +++ b/a |
|
775 | 775 | @@ -1,2 +1,3 @@ |
|
776 | 776 | a |
|
777 | 777 | -5 |
|
778 | 778 | +m1 |
|
779 | 779 | +m2 |
|
780 | 780 | diff --git a/b b/b |
|
781 | 781 | deleted file mode 100644 |
|
782 | 782 | --- a/b |
|
783 | 783 | +++ /dev/null |
|
784 | 784 | @@ -1,2 +0,0 @@ |
|
785 | 785 | -a |
|
786 | 786 | -5 |
|
787 | 787 | diff --git a/c b/c |
|
788 | 788 | deleted file mode 100644 |
|
789 | 789 | --- a/c |
|
790 | 790 | +++ /dev/null |
|
791 | 791 | @@ -1,2 +0,0 @@ |
|
792 | 792 | -a |
|
793 | 793 | -5 |
|
794 | 794 | |
|
795 | 795 | |
|
796 | ** circular rename ** | |
|
797 | ** add a a1 / hg mv a b / hg mv b a | |
|
798 | - working to parent: | |
|
799 | A a | |
|
800 | b | |
|
801 | R b | |
|
802 | ||
|
803 | diff --git a/b b/a | |
|
804 | rename from b | |
|
805 | rename to a | |
|
806 | ||
|
807 | - working to root: --rev 0 | |
|
808 | M a | |
|
809 | ||
|
810 | diff --git a/a b/a | |
|
811 | --- a/a | |
|
812 | +++ b/a | |
|
813 | @@ -1,1 +1,3 @@ | |
|
814 | a | |
|
815 | +6 | |
|
816 | +a1 | |
|
817 | ||
|
818 | - working to branch: --rev 2 | |
|
819 | M a | |
|
820 | ||
|
821 | diff --git a/a b/a | |
|
822 | --- a/a | |
|
823 | +++ b/a | |
|
824 | @@ -1,3 +1,3 @@ | |
|
825 | a | |
|
826 | -m1 | |
|
827 | -m2 | |
|
828 | +6 | |
|
829 | +a1 | |
|
830 | ||
|
831 | - root to parent: --rev 0 --rev . | |
|
832 | A b | |
|
833 | a | |
|
834 | R a | |
|
835 | ||
|
836 | diff --git a/a b/b | |
|
837 | rename from a | |
|
838 | rename to b | |
|
839 | --- a/a | |
|
840 | +++ b/b | |
|
841 | @@ -1,1 +1,3 @@ | |
|
842 | a | |
|
843 | +6 | |
|
844 | +a1 | |
|
845 | ||
|
846 | - parent to root: --rev . --rev 0 | |
|
847 | A a | |
|
848 | b | |
|
849 | R b | |
|
850 | ||
|
851 | diff --git a/b b/a | |
|
852 | rename from b | |
|
853 | rename to a | |
|
854 | --- a/b | |
|
855 | +++ b/a | |
|
856 | @@ -1,3 +1,1 @@ | |
|
857 | a | |
|
858 | -6 | |
|
859 | -a1 | |
|
860 | ||
|
861 | - branch to parent: --rev 2 --rev . | |
|
862 | A b | |
|
863 | a | |
|
864 | R a | |
|
865 | ||
|
866 | diff --git a/a b/b | |
|
867 | rename from a | |
|
868 | rename to b | |
|
869 | --- a/a | |
|
870 | +++ b/b | |
|
871 | @@ -1,3 +1,3 @@ | |
|
872 | a | |
|
873 | -m1 | |
|
874 | -m2 | |
|
875 | +6 | |
|
876 | +a1 | |
|
877 | ||
|
878 | - parent to branch: --rev . --rev 2 | |
|
879 | A a | |
|
880 | b | |
|
881 | R b | |
|
882 | ||
|
883 | diff --git a/b b/a | |
|
884 | rename from b | |
|
885 | rename to a | |
|
886 | --- a/b | |
|
887 | +++ b/a | |
|
888 | @@ -1,3 +1,3 @@ | |
|
889 | a | |
|
890 | -6 | |
|
891 | -a1 | |
|
892 | +m1 | |
|
893 | +m2 | |
|
894 | ||
|
895 |
General Comments 0
You need to be logged in to leave comments.
Login now