equal
deleted
inserted
replaced
1 # context.py - changeset and file context objects for mercurial |
1 # context.py - changeset and file context objects for mercurial |
2 # |
2 # |
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from node import nullid, nullrev, short, hex |
8 from node import nullid, nullrev, short, hex |
9 from i18n import _ |
9 from i18n import _ |
10 import ancestor, bdiff, error, util, subrepo |
10 import ancestor, bdiff, error, util, subrepo |
11 import os, errno |
11 import os, errno |
490 if v: |
490 if v: |
491 f, n = v |
491 f, n = v |
492 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) |
492 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) |
493 |
493 |
494 return None |
494 return None |
|
495 |
|
496 def ancestors(self): |
|
497 seen = set(str(self)) |
|
498 visit = [self] |
|
499 while visit: |
|
500 for parent in visit.pop(0).parents(): |
|
501 s = str(parent) |
|
502 if s not in seen: |
|
503 visit.append(parent) |
|
504 seen.add(s) |
|
505 yield parent |
495 |
506 |
496 class workingctx(changectx): |
507 class workingctx(changectx): |
497 """A workingctx object makes access to data related to |
508 """A workingctx object makes access to data related to |
498 the current working directory convenient. |
509 the current working directory convenient. |
499 parents - a pair of parent nodeids, or None to use the dirstate. |
510 parents - a pair of parent nodeids, or None to use the dirstate. |