##// END OF EJS Templates
basectx: move sub from changectx
Sean Farley -
r19562:389d7767 default
parent child Browse files
Show More
@@ -1,1398 +1,1398 b''
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 of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from node import nullid, nullrev, short, hex, bin
9 9 from i18n import _
10 10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
11 11 import copies
12 12 import match as matchmod
13 13 import os, errno, stat
14 14 import obsolete as obsmod
15 15 import repoview
16 16
17 17 propertycache = util.propertycache
18 18
19 19 class basectx(object):
20 20 """A basectx object represents the common logic for its children:
21 21 changectx: read-only context that is already present in the repo,
22 22 workingctx: a context that represents the working directory and can
23 23 be committed,
24 24 memctx: a context that represents changes in-memory and can also
25 25 be committed."""
26 26 def __new__(cls, repo, changeid='', *args, **kwargs):
27 27 if isinstance(changeid, basectx):
28 28 return changeid
29 29
30 30 o = super(basectx, cls).__new__(cls)
31 31
32 32 o._repo = repo
33 33 o._rev = nullrev
34 34 o._node = nullid
35 35
36 36 return o
37 37
38 38 def __str__(self):
39 39 return short(self.node())
40 40
41 41 def __int__(self):
42 42 return self.rev()
43 43
44 44 def __repr__(self):
45 45 return "<%s %s>" % (type(self).__name__, str(self))
46 46
47 47 def __eq__(self, other):
48 48 try:
49 49 return type(self) == type(other) and self._rev == other._rev
50 50 except AttributeError:
51 51 return False
52 52
53 53 def __ne__(self, other):
54 54 return not (self == other)
55 55
56 56 def __contains__(self, key):
57 57 return key in self._manifest
58 58
59 59 def __getitem__(self, key):
60 60 return self.filectx(key)
61 61
62 62 def __iter__(self):
63 63 for f in sorted(self._manifest):
64 64 yield f
65 65
66 66 @propertycache
67 67 def substate(self):
68 68 return subrepo.state(self, self._repo.ui)
69 69
70 70 def rev(self):
71 71 return self._rev
72 72 def node(self):
73 73 return self._node
74 74 def hex(self):
75 75 return hex(self.node())
76 76 def manifest(self):
77 77 return self._manifest
78 78 def phasestr(self):
79 79 return phases.phasenames[self.phase()]
80 80 def mutable(self):
81 81 return self.phase() > phases.public
82 82
83 83 def parents(self):
84 84 """return contexts for each parent changeset"""
85 85 return self._parents
86 86
87 87 def p1(self):
88 88 return self._parents[0]
89 89
90 90 def p2(self):
91 91 if len(self._parents) == 2:
92 92 return self._parents[1]
93 93 return changectx(self._repo, -1)
94 94
95 95 def _fileinfo(self, path):
96 96 if '_manifest' in self.__dict__:
97 97 try:
98 98 return self._manifest[path], self._manifest.flags(path)
99 99 except KeyError:
100 100 raise error.ManifestLookupError(self._node, path,
101 101 _('not found in manifest'))
102 102 if '_manifestdelta' in self.__dict__ or path in self.files():
103 103 if path in self._manifestdelta:
104 104 return (self._manifestdelta[path],
105 105 self._manifestdelta.flags(path))
106 106 node, flag = self._repo.manifest.find(self._changeset[0], path)
107 107 if not node:
108 108 raise error.ManifestLookupError(self._node, path,
109 109 _('not found in manifest'))
110 110
111 111 return node, flag
112 112
113 113 def filenode(self, path):
114 114 return self._fileinfo(path)[0]
115 115
116 116 def flags(self, path):
117 117 try:
118 118 return self._fileinfo(path)[1]
119 119 except error.LookupError:
120 120 return ''
121 121
122 def sub(self, path):
123 return subrepo.subrepo(self, path)
124
122 125 class changectx(basectx):
123 126 """A changecontext object makes access to data related to a particular
124 127 changeset convenient. It represents a read-only context already presnt in
125 128 the repo."""
126 129 def __init__(self, repo, changeid=''):
127 130 """changeid is a revision number, node, or tag"""
128 131
129 132 # since basectx.__new__ already took care of copying the object, we
130 133 # don't need to do anything in __init__, so we just exit here
131 134 if isinstance(changeid, basectx):
132 135 return
133 136
134 137 if changeid == '':
135 138 changeid = '.'
136 139 self._repo = repo
137 140
138 141 if isinstance(changeid, int):
139 142 try:
140 143 self._node = repo.changelog.node(changeid)
141 144 except IndexError:
142 145 raise error.RepoLookupError(
143 146 _("unknown revision '%s'") % changeid)
144 147 self._rev = changeid
145 148 return
146 149 if isinstance(changeid, long):
147 150 changeid = str(changeid)
148 151 if changeid == '.':
149 152 self._node = repo.dirstate.p1()
150 153 self._rev = repo.changelog.rev(self._node)
151 154 return
152 155 if changeid == 'null':
153 156 self._node = nullid
154 157 self._rev = nullrev
155 158 return
156 159 if changeid == 'tip':
157 160 self._node = repo.changelog.tip()
158 161 self._rev = repo.changelog.rev(self._node)
159 162 return
160 163 if len(changeid) == 20:
161 164 try:
162 165 self._node = changeid
163 166 self._rev = repo.changelog.rev(changeid)
164 167 return
165 168 except LookupError:
166 169 pass
167 170
168 171 try:
169 172 r = int(changeid)
170 173 if str(r) != changeid:
171 174 raise ValueError
172 175 l = len(repo.changelog)
173 176 if r < 0:
174 177 r += l
175 178 if r < 0 or r >= l:
176 179 raise ValueError
177 180 self._rev = r
178 181 self._node = repo.changelog.node(r)
179 182 return
180 183 except (ValueError, OverflowError, IndexError):
181 184 pass
182 185
183 186 if len(changeid) == 40:
184 187 try:
185 188 self._node = bin(changeid)
186 189 self._rev = repo.changelog.rev(self._node)
187 190 return
188 191 except (TypeError, LookupError):
189 192 pass
190 193
191 194 if changeid in repo._bookmarks:
192 195 self._node = repo._bookmarks[changeid]
193 196 self._rev = repo.changelog.rev(self._node)
194 197 return
195 198 if changeid in repo._tagscache.tags:
196 199 self._node = repo._tagscache.tags[changeid]
197 200 self._rev = repo.changelog.rev(self._node)
198 201 return
199 202 try:
200 203 self._node = repo.branchtip(changeid)
201 204 self._rev = repo.changelog.rev(self._node)
202 205 return
203 206 except error.RepoLookupError:
204 207 pass
205 208
206 209 self._node = repo.changelog._partialmatch(changeid)
207 210 if self._node is not None:
208 211 self._rev = repo.changelog.rev(self._node)
209 212 return
210 213
211 214 # lookup failed
212 215 # check if it might have come from damaged dirstate
213 216 #
214 217 # XXX we could avoid the unfiltered if we had a recognizable exception
215 218 # for filtered changeset access
216 219 if changeid in repo.unfiltered().dirstate.parents():
217 220 raise error.Abort(_("working directory has unknown parent '%s'!")
218 221 % short(changeid))
219 222 try:
220 223 if len(changeid) == 20:
221 224 changeid = hex(changeid)
222 225 except TypeError:
223 226 pass
224 227 raise error.RepoLookupError(
225 228 _("unknown revision '%s'") % changeid)
226 229
227 230 def __hash__(self):
228 231 try:
229 232 return hash(self._rev)
230 233 except AttributeError:
231 234 return id(self)
232 235
233 236 def __nonzero__(self):
234 237 return self._rev != nullrev
235 238
236 239 @propertycache
237 240 def _changeset(self):
238 241 return self._repo.changelog.read(self.rev())
239 242
240 243 @propertycache
241 244 def _manifest(self):
242 245 return self._repo.manifest.read(self._changeset[0])
243 246
244 247 @propertycache
245 248 def _manifestdelta(self):
246 249 return self._repo.manifest.readdelta(self._changeset[0])
247 250
248 251 @propertycache
249 252 def _parents(self):
250 253 p = self._repo.changelog.parentrevs(self._rev)
251 254 if p[1] == nullrev:
252 255 p = p[:-1]
253 256 return [changectx(self._repo, x) for x in p]
254 257
255 258 def changeset(self):
256 259 return self._changeset
257 260 def manifestnode(self):
258 261 return self._changeset[0]
259 262
260 263 def user(self):
261 264 return self._changeset[1]
262 265 def date(self):
263 266 return self._changeset[2]
264 267 def files(self):
265 268 return self._changeset[3]
266 269 def description(self):
267 270 return self._changeset[4]
268 271 def branch(self):
269 272 return encoding.tolocal(self._changeset[5].get("branch"))
270 273 def closesbranch(self):
271 274 return 'close' in self._changeset[5]
272 275 def extra(self):
273 276 return self._changeset[5]
274 277 def tags(self):
275 278 return self._repo.nodetags(self._node)
276 279 def bookmarks(self):
277 280 return self._repo.nodebookmarks(self._node)
278 281 def phase(self):
279 282 return self._repo._phasecache.phase(self._repo, self._rev)
280 283 def hidden(self):
281 284 return self._rev in repoview.filterrevs(self._repo, 'visible')
282 285
283 286 def children(self):
284 287 """return contexts for each child changeset"""
285 288 c = self._repo.changelog.children(self._node)
286 289 return [changectx(self._repo, x) for x in c]
287 290
288 291 def ancestors(self):
289 292 for a in self._repo.changelog.ancestors([self._rev]):
290 293 yield changectx(self._repo, a)
291 294
292 295 def descendants(self):
293 296 for d in self._repo.changelog.descendants([self._rev]):
294 297 yield changectx(self._repo, d)
295 298
296 299 def obsolete(self):
297 300 """True if the changeset is obsolete"""
298 301 return self.rev() in obsmod.getrevs(self._repo, 'obsolete')
299 302
300 303 def extinct(self):
301 304 """True if the changeset is extinct"""
302 305 return self.rev() in obsmod.getrevs(self._repo, 'extinct')
303 306
304 307 def unstable(self):
305 308 """True if the changeset is not obsolete but it's ancestor are"""
306 309 return self.rev() in obsmod.getrevs(self._repo, 'unstable')
307 310
308 311 def bumped(self):
309 312 """True if the changeset try to be a successor of a public changeset
310 313
311 314 Only non-public and non-obsolete changesets may be bumped.
312 315 """
313 316 return self.rev() in obsmod.getrevs(self._repo, 'bumped')
314 317
315 318 def divergent(self):
316 319 """Is a successors of a changeset with multiple possible successors set
317 320
318 321 Only non-public and non-obsolete changesets may be divergent.
319 322 """
320 323 return self.rev() in obsmod.getrevs(self._repo, 'divergent')
321 324
322 325 def troubled(self):
323 326 """True if the changeset is either unstable, bumped or divergent"""
324 327 return self.unstable() or self.bumped() or self.divergent()
325 328
326 329 def troubles(self):
327 330 """return the list of troubles affecting this changesets.
328 331
329 332 Troubles are returned as strings. possible values are:
330 333 - unstable,
331 334 - bumped,
332 335 - divergent.
333 336 """
334 337 troubles = []
335 338 if self.unstable():
336 339 troubles.append('unstable')
337 340 if self.bumped():
338 341 troubles.append('bumped')
339 342 if self.divergent():
340 343 troubles.append('divergent')
341 344 return troubles
342 345
343 346 def filectx(self, path, fileid=None, filelog=None):
344 347 """get a file context from this changeset"""
345 348 if fileid is None:
346 349 fileid = self.filenode(path)
347 350 return filectx(self._repo, path, fileid=fileid,
348 351 changectx=self, filelog=filelog)
349 352
350 353 def ancestor(self, c2):
351 354 """
352 355 return the ancestor context of self and c2
353 356 """
354 357 # deal with workingctxs
355 358 n2 = c2._node
356 359 if n2 is None:
357 360 n2 = c2._parents[0]._node
358 361 n = self._repo.changelog.ancestor(self._node, n2)
359 362 return changectx(self._repo, n)
360 363
361 364 def descendant(self, other):
362 365 """True if other is descendant of this changeset"""
363 366 return self._repo.changelog.descendant(self._rev, other._rev)
364 367
365 368 def walk(self, match):
366 369 fset = set(match.files())
367 370 # for dirstate.walk, files=['.'] means "walk the whole tree".
368 371 # follow that here, too
369 372 fset.discard('.')
370 373 for fn in self:
371 374 if fn in fset:
372 375 # specified pattern is the exact name
373 376 fset.remove(fn)
374 377 if match(fn):
375 378 yield fn
376 379 for fn in sorted(fset):
377 380 if fn in self._dirs:
378 381 # specified pattern is a directory
379 382 continue
380 383 if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
381 384 yield fn
382 385
383 def sub(self, path):
384 return subrepo.subrepo(self, path)
385
386 386 def match(self, pats=[], include=None, exclude=None, default='glob'):
387 387 r = self._repo
388 388 return matchmod.match(r.root, r.getcwd(), pats,
389 389 include, exclude, default,
390 390 auditor=r.auditor, ctx=self)
391 391
392 392 def diff(self, ctx2=None, match=None, **opts):
393 393 """Returns a diff generator for the given contexts and matcher"""
394 394 if ctx2 is None:
395 395 ctx2 = self.p1()
396 396 if ctx2 is not None and not isinstance(ctx2, changectx):
397 397 ctx2 = self._repo[ctx2]
398 398 diffopts = patch.diffopts(self._repo.ui, opts)
399 399 return patch.diff(self._repo, ctx2.node(), self.node(),
400 400 match=match, opts=diffopts)
401 401
402 402 @propertycache
403 403 def _dirs(self):
404 404 return scmutil.dirs(self._manifest)
405 405
406 406 def dirs(self):
407 407 return self._dirs
408 408
409 409 def dirty(self):
410 410 return False
411 411
412 412 class filectx(object):
413 413 """A filecontext object makes access to data related to a particular
414 414 filerevision convenient."""
415 415 def __init__(self, repo, path, changeid=None, fileid=None,
416 416 filelog=None, changectx=None):
417 417 """changeid can be a changeset revision, node, or tag.
418 418 fileid can be a file revision or node."""
419 419 self._repo = repo
420 420 self._path = path
421 421
422 422 assert (changeid is not None
423 423 or fileid is not None
424 424 or changectx is not None), \
425 425 ("bad args: changeid=%r, fileid=%r, changectx=%r"
426 426 % (changeid, fileid, changectx))
427 427
428 428 if filelog is not None:
429 429 self._filelog = filelog
430 430
431 431 if changeid is not None:
432 432 self._changeid = changeid
433 433 if changectx is not None:
434 434 self._changectx = changectx
435 435 if fileid is not None:
436 436 self._fileid = fileid
437 437
438 438 @propertycache
439 439 def _changectx(self):
440 440 try:
441 441 return changectx(self._repo, self._changeid)
442 442 except error.RepoLookupError:
443 443 # Linkrev may point to any revision in the repository. When the
444 444 # repository is filtered this may lead to `filectx` trying to build
445 445 # `changectx` for filtered revision. In such case we fallback to
446 446 # creating `changectx` on the unfiltered version of the reposition.
447 447 # This fallback should not be an issue because `changectx` from
448 448 # `filectx` are not used in complex operations that care about
449 449 # filtering.
450 450 #
451 451 # This fallback is a cheap and dirty fix that prevent several
452 452 # crashes. It does not ensure the behavior is correct. However the
453 453 # behavior was not correct before filtering either and "incorrect
454 454 # behavior" is seen as better as "crash"
455 455 #
456 456 # Linkrevs have several serious troubles with filtering that are
457 457 # complicated to solve. Proper handling of the issue here should be
458 458 # considered when solving linkrev issue are on the table.
459 459 return changectx(self._repo.unfiltered(), self._changeid)
460 460
461 461 @propertycache
462 462 def _filelog(self):
463 463 return self._repo.file(self._path)
464 464
465 465 @propertycache
466 466 def _changeid(self):
467 467 if '_changeid' in self.__dict__:
468 468 return self._changeid
469 469 elif '_changectx' in self.__dict__:
470 470 return self._changectx.rev()
471 471 else:
472 472 return self._filelog.linkrev(self._filerev)
473 473
474 474 @propertycache
475 475 def _filenode(self):
476 476 if '_fileid' in self.__dict__:
477 477 return self._filelog.lookup(self._fileid)
478 478 else:
479 479 return self._changectx.filenode(self._path)
480 480
481 481 @propertycache
482 482 def _filerev(self):
483 483 return self._filelog.rev(self._filenode)
484 484
485 485 @propertycache
486 486 def _repopath(self):
487 487 return self._path
488 488
489 489 def __nonzero__(self):
490 490 try:
491 491 self._filenode
492 492 return True
493 493 except error.LookupError:
494 494 # file is missing
495 495 return False
496 496
497 497 def __str__(self):
498 498 return "%s@%s" % (self.path(), short(self.node()))
499 499
500 500 def __repr__(self):
501 501 return "<filectx %s>" % str(self)
502 502
503 503 def __hash__(self):
504 504 try:
505 505 return hash((self._path, self._filenode))
506 506 except AttributeError:
507 507 return id(self)
508 508
509 509 def __eq__(self, other):
510 510 try:
511 511 return (self._path == other._path
512 512 and self._filenode == other._filenode)
513 513 except AttributeError:
514 514 return False
515 515
516 516 def __ne__(self, other):
517 517 return not (self == other)
518 518
519 519 def filectx(self, fileid):
520 520 '''opens an arbitrary revision of the file without
521 521 opening a new filelog'''
522 522 return filectx(self._repo, self._path, fileid=fileid,
523 523 filelog=self._filelog)
524 524
525 525 def filerev(self):
526 526 return self._filerev
527 527 def filenode(self):
528 528 return self._filenode
529 529 def flags(self):
530 530 return self._changectx.flags(self._path)
531 531 def filelog(self):
532 532 return self._filelog
533 533 def rev(self):
534 534 return self._changeid
535 535 def linkrev(self):
536 536 return self._filelog.linkrev(self._filerev)
537 537 def node(self):
538 538 return self._changectx.node()
539 539 def hex(self):
540 540 return hex(self.node())
541 541 def user(self):
542 542 return self._changectx.user()
543 543 def date(self):
544 544 return self._changectx.date()
545 545 def files(self):
546 546 return self._changectx.files()
547 547 def description(self):
548 548 return self._changectx.description()
549 549 def branch(self):
550 550 return self._changectx.branch()
551 551 def extra(self):
552 552 return self._changectx.extra()
553 553 def phase(self):
554 554 return self._changectx.phase()
555 555 def phasestr(self):
556 556 return self._changectx.phasestr()
557 557 def manifest(self):
558 558 return self._changectx.manifest()
559 559 def changectx(self):
560 560 return self._changectx
561 561
562 562 def data(self):
563 563 return self._filelog.read(self._filenode)
564 564 def path(self):
565 565 return self._path
566 566 def size(self):
567 567 return self._filelog.size(self._filerev)
568 568
569 569 def isbinary(self):
570 570 try:
571 571 return util.binary(self.data())
572 572 except IOError:
573 573 return False
574 574
575 575 def cmp(self, fctx):
576 576 """compare with other file context
577 577
578 578 returns True if different than fctx.
579 579 """
580 580 if (fctx._filerev is None
581 581 and (self._repo._encodefilterpats
582 582 # if file data starts with '\1\n', empty metadata block is
583 583 # prepended, which adds 4 bytes to filelog.size().
584 584 or self.size() - 4 == fctx.size())
585 585 or self.size() == fctx.size()):
586 586 return self._filelog.cmp(self._filenode, fctx.data())
587 587
588 588 return True
589 589
590 590 def renamed(self):
591 591 """check if file was actually renamed in this changeset revision
592 592
593 593 If rename logged in file revision, we report copy for changeset only
594 594 if file revisions linkrev points back to the changeset in question
595 595 or both changeset parents contain different file revisions.
596 596 """
597 597
598 598 renamed = self._filelog.renamed(self._filenode)
599 599 if not renamed:
600 600 return renamed
601 601
602 602 if self.rev() == self.linkrev():
603 603 return renamed
604 604
605 605 name = self.path()
606 606 fnode = self._filenode
607 607 for p in self._changectx.parents():
608 608 try:
609 609 if fnode == p.filenode(name):
610 610 return None
611 611 except error.LookupError:
612 612 pass
613 613 return renamed
614 614
615 615 def parents(self):
616 616 p = self._path
617 617 fl = self._filelog
618 618 pl = [(p, n, fl) for n in self._filelog.parents(self._filenode)]
619 619
620 620 r = self._filelog.renamed(self._filenode)
621 621 if r:
622 622 pl[0] = (r[0], r[1], None)
623 623
624 624 return [filectx(self._repo, p, fileid=n, filelog=l)
625 625 for p, n, l in pl if n != nullid]
626 626
627 627 def p1(self):
628 628 return self.parents()[0]
629 629
630 630 def p2(self):
631 631 p = self.parents()
632 632 if len(p) == 2:
633 633 return p[1]
634 634 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog)
635 635
636 636 def children(self):
637 637 # hard for renames
638 638 c = self._filelog.children(self._filenode)
639 639 return [filectx(self._repo, self._path, fileid=x,
640 640 filelog=self._filelog) for x in c]
641 641
642 642 def annotate(self, follow=False, linenumber=None, diffopts=None):
643 643 '''returns a list of tuples of (ctx, line) for each line
644 644 in the file, where ctx is the filectx of the node where
645 645 that line was last changed.
646 646 This returns tuples of ((ctx, linenumber), line) for each line,
647 647 if "linenumber" parameter is NOT "None".
648 648 In such tuples, linenumber means one at the first appearance
649 649 in the managed file.
650 650 To reduce annotation cost,
651 651 this returns fixed value(False is used) as linenumber,
652 652 if "linenumber" parameter is "False".'''
653 653
654 654 def decorate_compat(text, rev):
655 655 return ([rev] * len(text.splitlines()), text)
656 656
657 657 def without_linenumber(text, rev):
658 658 return ([(rev, False)] * len(text.splitlines()), text)
659 659
660 660 def with_linenumber(text, rev):
661 661 size = len(text.splitlines())
662 662 return ([(rev, i) for i in xrange(1, size + 1)], text)
663 663
664 664 decorate = (((linenumber is None) and decorate_compat) or
665 665 (linenumber and with_linenumber) or
666 666 without_linenumber)
667 667
668 668 def pair(parent, child):
669 669 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
670 670 refine=True)
671 671 for (a1, a2, b1, b2), t in blocks:
672 672 # Changed blocks ('!') or blocks made only of blank lines ('~')
673 673 # belong to the child.
674 674 if t == '=':
675 675 child[0][b1:b2] = parent[0][a1:a2]
676 676 return child
677 677
678 678 getlog = util.lrucachefunc(lambda x: self._repo.file(x))
679 679
680 680 def parents(f):
681 681 pl = f.parents()
682 682
683 683 # Don't return renamed parents if we aren't following.
684 684 if not follow:
685 685 pl = [p for p in pl if p.path() == f.path()]
686 686
687 687 # renamed filectx won't have a filelog yet, so set it
688 688 # from the cache to save time
689 689 for p in pl:
690 690 if not '_filelog' in p.__dict__:
691 691 p._filelog = getlog(p.path())
692 692
693 693 return pl
694 694
695 695 # use linkrev to find the first changeset where self appeared
696 696 if self.rev() != self.linkrev():
697 697 base = self.filectx(self.filenode())
698 698 else:
699 699 base = self
700 700
701 701 # This algorithm would prefer to be recursive, but Python is a
702 702 # bit recursion-hostile. Instead we do an iterative
703 703 # depth-first search.
704 704
705 705 visit = [base]
706 706 hist = {}
707 707 pcache = {}
708 708 needed = {base: 1}
709 709 while visit:
710 710 f = visit[-1]
711 711 pcached = f in pcache
712 712 if not pcached:
713 713 pcache[f] = parents(f)
714 714
715 715 ready = True
716 716 pl = pcache[f]
717 717 for p in pl:
718 718 if p not in hist:
719 719 ready = False
720 720 visit.append(p)
721 721 if not pcached:
722 722 needed[p] = needed.get(p, 0) + 1
723 723 if ready:
724 724 visit.pop()
725 725 reusable = f in hist
726 726 if reusable:
727 727 curr = hist[f]
728 728 else:
729 729 curr = decorate(f.data(), f)
730 730 for p in pl:
731 731 if not reusable:
732 732 curr = pair(hist[p], curr)
733 733 if needed[p] == 1:
734 734 del hist[p]
735 735 del needed[p]
736 736 else:
737 737 needed[p] -= 1
738 738
739 739 hist[f] = curr
740 740 pcache[f] = []
741 741
742 742 return zip(hist[base][0], hist[base][1].splitlines(True))
743 743
744 744 def ancestor(self, fc2, actx):
745 745 """
746 746 find the common ancestor file context, if any, of self, and fc2
747 747
748 748 actx must be the changectx of the common ancestor
749 749 of self's and fc2's respective changesets.
750 750 """
751 751
752 752 # the easy case: no (relevant) renames
753 753 if fc2.path() == self.path() and self.path() in actx:
754 754 return actx[self.path()]
755 755
756 756 # the next easiest cases: unambiguous predecessor (name trumps
757 757 # history)
758 758 if self.path() in actx and fc2.path() not in actx:
759 759 return actx[self.path()]
760 760 if fc2.path() in actx and self.path() not in actx:
761 761 return actx[fc2.path()]
762 762
763 763 # prime the ancestor cache for the working directory
764 764 acache = {}
765 765 for c in (self, fc2):
766 766 if c.filenode() is None:
767 767 pl = [(n.path(), n.filenode()) for n in c.parents()]
768 768 acache[(c._path, None)] = pl
769 769
770 770 flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog}
771 771 def parents(vertex):
772 772 if vertex in acache:
773 773 return acache[vertex]
774 774 f, n = vertex
775 775 if f not in flcache:
776 776 flcache[f] = self._repo.file(f)
777 777 fl = flcache[f]
778 778 pl = [(f, p) for p in fl.parents(n) if p != nullid]
779 779 re = fl.renamed(n)
780 780 if re:
781 781 pl.append(re)
782 782 acache[vertex] = pl
783 783 return pl
784 784
785 785 a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
786 786 v = ancestor.genericancestor(a, b, parents)
787 787 if v:
788 788 f, n = v
789 789 return filectx(self._repo, f, fileid=n, filelog=flcache[f])
790 790
791 791 return None
792 792
793 793 def ancestors(self, followfirst=False):
794 794 visit = {}
795 795 c = self
796 796 cut = followfirst and 1 or None
797 797 while True:
798 798 for parent in c.parents()[:cut]:
799 799 visit[(parent.rev(), parent.node())] = parent
800 800 if not visit:
801 801 break
802 802 c = visit.pop(max(visit))
803 803 yield c
804 804
805 805 def copies(self, c2):
806 806 if not util.safehasattr(self, "_copycache"):
807 807 self._copycache = {}
808 808 sc2 = str(c2)
809 809 if sc2 not in self._copycache:
810 810 self._copycache[sc2] = copies.pathcopies(c2)
811 811 return self._copycache[sc2]
812 812
813 813 class workingctx(changectx):
814 814 """A workingctx object makes access to data related to
815 815 the current working directory convenient.
816 816 date - any valid date string or (unixtime, offset), or None.
817 817 user - username string, or None.
818 818 extra - a dictionary of extra values, or None.
819 819 changes - a list of file lists as returned by localrepo.status()
820 820 or None to use the repository status.
821 821 """
822 822 def __init__(self, repo, text="", user=None, date=None, extra=None,
823 823 changes=None):
824 824 self._repo = repo
825 825 self._rev = None
826 826 self._node = None
827 827 self._text = text
828 828 if date:
829 829 self._date = util.parsedate(date)
830 830 if user:
831 831 self._user = user
832 832 if changes:
833 833 self._status = list(changes[:4])
834 834 self._unknown = changes[4]
835 835 self._ignored = changes[5]
836 836 self._clean = changes[6]
837 837 else:
838 838 self._unknown = None
839 839 self._ignored = None
840 840 self._clean = None
841 841
842 842 self._extra = {}
843 843 if extra:
844 844 self._extra = extra.copy()
845 845 if 'branch' not in self._extra:
846 846 try:
847 847 branch = encoding.fromlocal(self._repo.dirstate.branch())
848 848 except UnicodeDecodeError:
849 849 raise util.Abort(_('branch name not in UTF-8!'))
850 850 self._extra['branch'] = branch
851 851 if self._extra['branch'] == '':
852 852 self._extra['branch'] = 'default'
853 853
854 854 def __str__(self):
855 855 return str(self._parents[0]) + "+"
856 856
857 857 def __repr__(self):
858 858 return "<workingctx %s>" % str(self)
859 859
860 860 def __nonzero__(self):
861 861 return True
862 862
863 863 def __contains__(self, key):
864 864 return self._repo.dirstate[key] not in "?r"
865 865
866 866 def _buildflagfunc(self):
867 867 # Create a fallback function for getting file flags when the
868 868 # filesystem doesn't support them
869 869
870 870 copiesget = self._repo.dirstate.copies().get
871 871
872 872 if len(self._parents) < 2:
873 873 # when we have one parent, it's easy: copy from parent
874 874 man = self._parents[0].manifest()
875 875 def func(f):
876 876 f = copiesget(f, f)
877 877 return man.flags(f)
878 878 else:
879 879 # merges are tricky: we try to reconstruct the unstored
880 880 # result from the merge (issue1802)
881 881 p1, p2 = self._parents
882 882 pa = p1.ancestor(p2)
883 883 m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
884 884
885 885 def func(f):
886 886 f = copiesget(f, f) # may be wrong for merges with copies
887 887 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f)
888 888 if fl1 == fl2:
889 889 return fl1
890 890 if fl1 == fla:
891 891 return fl2
892 892 if fl2 == fla:
893 893 return fl1
894 894 return '' # punt for conflicts
895 895
896 896 return func
897 897
898 898 @propertycache
899 899 def _flagfunc(self):
900 900 return self._repo.dirstate.flagfunc(self._buildflagfunc)
901 901
902 902 @propertycache
903 903 def _manifest(self):
904 904 """generate a manifest corresponding to the working directory"""
905 905
906 906 man = self._parents[0].manifest().copy()
907 907 if len(self._parents) > 1:
908 908 man2 = self.p2().manifest()
909 909 def getman(f):
910 910 if f in man:
911 911 return man
912 912 return man2
913 913 else:
914 914 getman = lambda f: man
915 915
916 916 copied = self._repo.dirstate.copies()
917 917 ff = self._flagfunc
918 918 modified, added, removed, deleted = self._status
919 919 for i, l in (("a", added), ("m", modified)):
920 920 for f in l:
921 921 orig = copied.get(f, f)
922 922 man[f] = getman(orig).get(orig, nullid) + i
923 923 try:
924 924 man.set(f, ff(f))
925 925 except OSError:
926 926 pass
927 927
928 928 for f in deleted + removed:
929 929 if f in man:
930 930 del man[f]
931 931
932 932 return man
933 933
934 934 def __iter__(self):
935 935 d = self._repo.dirstate
936 936 for f in d:
937 937 if d[f] != 'r':
938 938 yield f
939 939
940 940 @propertycache
941 941 def _status(self):
942 942 return self._repo.status()[:4]
943 943
944 944 @propertycache
945 945 def _user(self):
946 946 return self._repo.ui.username()
947 947
948 948 @propertycache
949 949 def _date(self):
950 950 return util.makedate()
951 951
952 952 @propertycache
953 953 def _parents(self):
954 954 p = self._repo.dirstate.parents()
955 955 if p[1] == nullid:
956 956 p = p[:-1]
957 957 return [changectx(self._repo, x) for x in p]
958 958
959 959 def status(self, ignored=False, clean=False, unknown=False):
960 960 """Explicit status query
961 961 Unless this method is used to query the working copy status, the
962 962 _status property will implicitly read the status using its default
963 963 arguments."""
964 964 stat = self._repo.status(ignored=ignored, clean=clean, unknown=unknown)
965 965 self._unknown = self._ignored = self._clean = None
966 966 if unknown:
967 967 self._unknown = stat[4]
968 968 if ignored:
969 969 self._ignored = stat[5]
970 970 if clean:
971 971 self._clean = stat[6]
972 972 self._status = stat[:4]
973 973 return stat
974 974
975 975 def manifest(self):
976 976 return self._manifest
977 977 def user(self):
978 978 return self._user or self._repo.ui.username()
979 979 def date(self):
980 980 return self._date
981 981 def description(self):
982 982 return self._text
983 983 def files(self):
984 984 return sorted(self._status[0] + self._status[1] + self._status[2])
985 985
986 986 def modified(self):
987 987 return self._status[0]
988 988 def added(self):
989 989 return self._status[1]
990 990 def removed(self):
991 991 return self._status[2]
992 992 def deleted(self):
993 993 return self._status[3]
994 994 def unknown(self):
995 995 assert self._unknown is not None # must call status first
996 996 return self._unknown
997 997 def ignored(self):
998 998 assert self._ignored is not None # must call status first
999 999 return self._ignored
1000 1000 def clean(self):
1001 1001 assert self._clean is not None # must call status first
1002 1002 return self._clean
1003 1003 def branch(self):
1004 1004 return encoding.tolocal(self._extra['branch'])
1005 1005 def closesbranch(self):
1006 1006 return 'close' in self._extra
1007 1007 def extra(self):
1008 1008 return self._extra
1009 1009
1010 1010 def tags(self):
1011 1011 t = []
1012 1012 for p in self.parents():
1013 1013 t.extend(p.tags())
1014 1014 return t
1015 1015
1016 1016 def bookmarks(self):
1017 1017 b = []
1018 1018 for p in self.parents():
1019 1019 b.extend(p.bookmarks())
1020 1020 return b
1021 1021
1022 1022 def phase(self):
1023 1023 phase = phases.draft # default phase to draft
1024 1024 for p in self.parents():
1025 1025 phase = max(phase, p.phase())
1026 1026 return phase
1027 1027
1028 1028 def hidden(self):
1029 1029 return False
1030 1030
1031 1031 def children(self):
1032 1032 return []
1033 1033
1034 1034 def flags(self, path):
1035 1035 if '_manifest' in self.__dict__:
1036 1036 try:
1037 1037 return self._manifest.flags(path)
1038 1038 except KeyError:
1039 1039 return ''
1040 1040
1041 1041 try:
1042 1042 return self._flagfunc(path)
1043 1043 except OSError:
1044 1044 return ''
1045 1045
1046 1046 def filectx(self, path, filelog=None):
1047 1047 """get a file context from the working directory"""
1048 1048 return workingfilectx(self._repo, path, workingctx=self,
1049 1049 filelog=filelog)
1050 1050
1051 1051 def ancestor(self, c2):
1052 1052 """return the ancestor context of self and c2"""
1053 1053 return self._parents[0].ancestor(c2) # punt on two parents for now
1054 1054
1055 1055 def walk(self, match):
1056 1056 return sorted(self._repo.dirstate.walk(match, sorted(self.substate),
1057 1057 True, False))
1058 1058
1059 1059 def dirty(self, missing=False, merge=True, branch=True):
1060 1060 "check whether a working directory is modified"
1061 1061 # check subrepos first
1062 1062 for s in sorted(self.substate):
1063 1063 if self.sub(s).dirty():
1064 1064 return True
1065 1065 # check current working dir
1066 1066 return ((merge and self.p2()) or
1067 1067 (branch and self.branch() != self.p1().branch()) or
1068 1068 self.modified() or self.added() or self.removed() or
1069 1069 (missing and self.deleted()))
1070 1070
1071 1071 def add(self, list, prefix=""):
1072 1072 join = lambda f: os.path.join(prefix, f)
1073 1073 wlock = self._repo.wlock()
1074 1074 ui, ds = self._repo.ui, self._repo.dirstate
1075 1075 try:
1076 1076 rejected = []
1077 1077 for f in list:
1078 1078 scmutil.checkportable(ui, join(f))
1079 1079 p = self._repo.wjoin(f)
1080 1080 try:
1081 1081 st = os.lstat(p)
1082 1082 except OSError:
1083 1083 ui.warn(_("%s does not exist!\n") % join(f))
1084 1084 rejected.append(f)
1085 1085 continue
1086 1086 if st.st_size > 10000000:
1087 1087 ui.warn(_("%s: up to %d MB of RAM may be required "
1088 1088 "to manage this file\n"
1089 1089 "(use 'hg revert %s' to cancel the "
1090 1090 "pending addition)\n")
1091 1091 % (f, 3 * st.st_size // 1000000, join(f)))
1092 1092 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1093 1093 ui.warn(_("%s not added: only files and symlinks "
1094 1094 "supported currently\n") % join(f))
1095 1095 rejected.append(p)
1096 1096 elif ds[f] in 'amn':
1097 1097 ui.warn(_("%s already tracked!\n") % join(f))
1098 1098 elif ds[f] == 'r':
1099 1099 ds.normallookup(f)
1100 1100 else:
1101 1101 ds.add(f)
1102 1102 return rejected
1103 1103 finally:
1104 1104 wlock.release()
1105 1105
1106 1106 def forget(self, files, prefix=""):
1107 1107 join = lambda f: os.path.join(prefix, f)
1108 1108 wlock = self._repo.wlock()
1109 1109 try:
1110 1110 rejected = []
1111 1111 for f in files:
1112 1112 if f not in self._repo.dirstate:
1113 1113 self._repo.ui.warn(_("%s not tracked!\n") % join(f))
1114 1114 rejected.append(f)
1115 1115 elif self._repo.dirstate[f] != 'a':
1116 1116 self._repo.dirstate.remove(f)
1117 1117 else:
1118 1118 self._repo.dirstate.drop(f)
1119 1119 return rejected
1120 1120 finally:
1121 1121 wlock.release()
1122 1122
1123 1123 def ancestors(self):
1124 1124 for a in self._repo.changelog.ancestors(
1125 1125 [p.rev() for p in self._parents]):
1126 1126 yield changectx(self._repo, a)
1127 1127
1128 1128 def undelete(self, list):
1129 1129 pctxs = self.parents()
1130 1130 wlock = self._repo.wlock()
1131 1131 try:
1132 1132 for f in list:
1133 1133 if self._repo.dirstate[f] != 'r':
1134 1134 self._repo.ui.warn(_("%s not removed!\n") % f)
1135 1135 else:
1136 1136 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
1137 1137 t = fctx.data()
1138 1138 self._repo.wwrite(f, t, fctx.flags())
1139 1139 self._repo.dirstate.normal(f)
1140 1140 finally:
1141 1141 wlock.release()
1142 1142
1143 1143 def copy(self, source, dest):
1144 1144 p = self._repo.wjoin(dest)
1145 1145 if not os.path.lexists(p):
1146 1146 self._repo.ui.warn(_("%s does not exist!\n") % dest)
1147 1147 elif not (os.path.isfile(p) or os.path.islink(p)):
1148 1148 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1149 1149 "symbolic link\n") % dest)
1150 1150 else:
1151 1151 wlock = self._repo.wlock()
1152 1152 try:
1153 1153 if self._repo.dirstate[dest] in '?r':
1154 1154 self._repo.dirstate.add(dest)
1155 1155 self._repo.dirstate.copy(source, dest)
1156 1156 finally:
1157 1157 wlock.release()
1158 1158
1159 1159 def markcommitted(self, node):
1160 1160 """Perform post-commit cleanup necessary after committing this ctx
1161 1161
1162 1162 Specifically, this updates backing stores this working context
1163 1163 wraps to reflect the fact that the changes reflected by this
1164 1164 workingctx have been committed. For example, it marks
1165 1165 modified and added files as normal in the dirstate.
1166 1166
1167 1167 """
1168 1168
1169 1169 for f in self.modified() + self.added():
1170 1170 self._repo.dirstate.normal(f)
1171 1171 for f in self.removed():
1172 1172 self._repo.dirstate.drop(f)
1173 1173 self._repo.dirstate.setparents(node)
1174 1174
1175 1175 def dirs(self):
1176 1176 return self._repo.dirstate.dirs()
1177 1177
1178 1178 class workingfilectx(filectx):
1179 1179 """A workingfilectx object makes access to data related to a particular
1180 1180 file in the working directory convenient."""
1181 1181 def __init__(self, repo, path, filelog=None, workingctx=None):
1182 1182 """changeid can be a changeset revision, node, or tag.
1183 1183 fileid can be a file revision or node."""
1184 1184 self._repo = repo
1185 1185 self._path = path
1186 1186 self._changeid = None
1187 1187 self._filerev = self._filenode = None
1188 1188
1189 1189 if filelog is not None:
1190 1190 self._filelog = filelog
1191 1191 if workingctx:
1192 1192 self._changectx = workingctx
1193 1193
1194 1194 @propertycache
1195 1195 def _changectx(self):
1196 1196 return workingctx(self._repo)
1197 1197
1198 1198 def __nonzero__(self):
1199 1199 return True
1200 1200
1201 1201 def __str__(self):
1202 1202 return "%s@%s" % (self.path(), self._changectx)
1203 1203
1204 1204 def __repr__(self):
1205 1205 return "<workingfilectx %s>" % str(self)
1206 1206
1207 1207 def data(self):
1208 1208 return self._repo.wread(self._path)
1209 1209 def renamed(self):
1210 1210 rp = self._repo.dirstate.copied(self._path)
1211 1211 if not rp:
1212 1212 return None
1213 1213 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
1214 1214
1215 1215 def parents(self):
1216 1216 '''return parent filectxs, following copies if necessary'''
1217 1217 def filenode(ctx, path):
1218 1218 return ctx._manifest.get(path, nullid)
1219 1219
1220 1220 path = self._path
1221 1221 fl = self._filelog
1222 1222 pcl = self._changectx._parents
1223 1223 renamed = self.renamed()
1224 1224
1225 1225 if renamed:
1226 1226 pl = [renamed + (None,)]
1227 1227 else:
1228 1228 pl = [(path, filenode(pcl[0], path), fl)]
1229 1229
1230 1230 for pc in pcl[1:]:
1231 1231 pl.append((path, filenode(pc, path), fl))
1232 1232
1233 1233 return [filectx(self._repo, p, fileid=n, filelog=l)
1234 1234 for p, n, l in pl if n != nullid]
1235 1235
1236 1236 def children(self):
1237 1237 return []
1238 1238
1239 1239 def size(self):
1240 1240 return os.lstat(self._repo.wjoin(self._path)).st_size
1241 1241 def date(self):
1242 1242 t, tz = self._changectx.date()
1243 1243 try:
1244 1244 return (int(os.lstat(self._repo.wjoin(self._path)).st_mtime), tz)
1245 1245 except OSError, err:
1246 1246 if err.errno != errno.ENOENT:
1247 1247 raise
1248 1248 return (t, tz)
1249 1249
1250 1250 def cmp(self, fctx):
1251 1251 """compare with other file context
1252 1252
1253 1253 returns True if different than fctx.
1254 1254 """
1255 1255 # fctx should be a filectx (not a workingfilectx)
1256 1256 # invert comparison to reuse the same code path
1257 1257 return fctx.cmp(self)
1258 1258
1259 1259 class memctx(object):
1260 1260 """Use memctx to perform in-memory commits via localrepo.commitctx().
1261 1261
1262 1262 Revision information is supplied at initialization time while
1263 1263 related files data and is made available through a callback
1264 1264 mechanism. 'repo' is the current localrepo, 'parents' is a
1265 1265 sequence of two parent revisions identifiers (pass None for every
1266 1266 missing parent), 'text' is the commit message and 'files' lists
1267 1267 names of files touched by the revision (normalized and relative to
1268 1268 repository root).
1269 1269
1270 1270 filectxfn(repo, memctx, path) is a callable receiving the
1271 1271 repository, the current memctx object and the normalized path of
1272 1272 requested file, relative to repository root. It is fired by the
1273 1273 commit function for every file in 'files', but calls order is
1274 1274 undefined. If the file is available in the revision being
1275 1275 committed (updated or added), filectxfn returns a memfilectx
1276 1276 object. If the file was removed, filectxfn raises an
1277 1277 IOError. Moved files are represented by marking the source file
1278 1278 removed and the new file added with copy information (see
1279 1279 memfilectx).
1280 1280
1281 1281 user receives the committer name and defaults to current
1282 1282 repository username, date is the commit date in any format
1283 1283 supported by util.parsedate() and defaults to current date, extra
1284 1284 is a dictionary of metadata or is left empty.
1285 1285 """
1286 1286 def __init__(self, repo, parents, text, files, filectxfn, user=None,
1287 1287 date=None, extra=None):
1288 1288 self._repo = repo
1289 1289 self._rev = None
1290 1290 self._node = None
1291 1291 self._text = text
1292 1292 self._date = date and util.parsedate(date) or util.makedate()
1293 1293 self._user = user
1294 1294 parents = [(p or nullid) for p in parents]
1295 1295 p1, p2 = parents
1296 1296 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
1297 1297 files = sorted(set(files))
1298 1298 self._status = [files, [], [], [], []]
1299 1299 self._filectxfn = filectxfn
1300 1300
1301 1301 self._extra = extra and extra.copy() or {}
1302 1302 if self._extra.get('branch', '') == '':
1303 1303 self._extra['branch'] = 'default'
1304 1304
1305 1305 def __str__(self):
1306 1306 return str(self._parents[0]) + "+"
1307 1307
1308 1308 def __int__(self):
1309 1309 return self._rev
1310 1310
1311 1311 def __nonzero__(self):
1312 1312 return True
1313 1313
1314 1314 def __getitem__(self, key):
1315 1315 return self.filectx(key)
1316 1316
1317 1317 def p1(self):
1318 1318 return self._parents[0]
1319 1319 def p2(self):
1320 1320 return self._parents[1]
1321 1321
1322 1322 def user(self):
1323 1323 return self._user or self._repo.ui.username()
1324 1324 def date(self):
1325 1325 return self._date
1326 1326 def description(self):
1327 1327 return self._text
1328 1328 def files(self):
1329 1329 return self.modified()
1330 1330 def modified(self):
1331 1331 return self._status[0]
1332 1332 def added(self):
1333 1333 return self._status[1]
1334 1334 def removed(self):
1335 1335 return self._status[2]
1336 1336 def deleted(self):
1337 1337 return self._status[3]
1338 1338 def unknown(self):
1339 1339 return self._status[4]
1340 1340 def ignored(self):
1341 1341 return self._status[5]
1342 1342 def clean(self):
1343 1343 return self._status[6]
1344 1344 def branch(self):
1345 1345 return encoding.tolocal(self._extra['branch'])
1346 1346 def extra(self):
1347 1347 return self._extra
1348 1348 def flags(self, f):
1349 1349 return self[f].flags()
1350 1350
1351 1351 def parents(self):
1352 1352 """return contexts for each parent changeset"""
1353 1353 return self._parents
1354 1354
1355 1355 def filectx(self, path, filelog=None):
1356 1356 """get a file context from the working directory"""
1357 1357 return self._filectxfn(self._repo, self, path)
1358 1358
1359 1359 def commit(self):
1360 1360 """commit context to the repo"""
1361 1361 return self._repo.commitctx(self)
1362 1362
1363 1363 class memfilectx(object):
1364 1364 """memfilectx represents an in-memory file to commit.
1365 1365
1366 1366 See memctx for more details.
1367 1367 """
1368 1368 def __init__(self, path, data, islink=False, isexec=False, copied=None):
1369 1369 """
1370 1370 path is the normalized file path relative to repository root.
1371 1371 data is the file content as a string.
1372 1372 islink is True if the file is a symbolic link.
1373 1373 isexec is True if the file is executable.
1374 1374 copied is the source file path if current file was copied in the
1375 1375 revision being committed, or None."""
1376 1376 self._path = path
1377 1377 self._data = data
1378 1378 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
1379 1379 self._copied = None
1380 1380 if copied:
1381 1381 self._copied = (copied, nullid)
1382 1382
1383 1383 def __nonzero__(self):
1384 1384 return True
1385 1385 def __str__(self):
1386 1386 return "%s@%s" % (self.path(), self._changectx)
1387 1387 def path(self):
1388 1388 return self._path
1389 1389 def data(self):
1390 1390 return self._data
1391 1391 def flags(self):
1392 1392 return self._flags
1393 1393 def isexec(self):
1394 1394 return 'x' in self._flags
1395 1395 def islink(self):
1396 1396 return 'l' in self._flags
1397 1397 def renamed(self):
1398 1398 return self._copied
General Comments 0
You need to be logged in to leave comments. Login now