115 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) |
115 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) |
116 return self.dirstate |
116 return self.dirstate |
117 else: |
117 else: |
118 raise AttributeError, name |
118 raise AttributeError, name |
119 |
119 |
|
120 def __getitem__(self, changeid): |
|
121 if changeid == None: |
|
122 return context.workingctx(self) |
|
123 return context.changectx(self, changeid) |
|
124 |
120 def url(self): |
125 def url(self): |
121 return 'file:' + self.root |
126 return 'file:' + self.root |
122 |
127 |
123 def hook(self, name, throw=False, **args): |
128 def hook(self, name, throw=False, **args): |
124 return hook.hook(self.ui, self, name, throw, **args) |
129 return hook.hook(self.ui, self, name, throw, **args) |
434 except (IOError, OSError): |
439 except (IOError, OSError): |
435 pass |
440 pass |
436 |
441 |
437 def _updatebranchcache(self, partial, start, end): |
442 def _updatebranchcache(self, partial, start, end): |
438 for r in xrange(start, end): |
443 for r in xrange(start, end): |
439 c = self.changectx(r) |
444 c = self[r] |
440 b = c.branch() |
445 b = c.branch() |
441 partial[b] = c.node() |
446 partial[b] = c.node() |
442 |
447 |
443 def lookup(self, key): |
448 def lookup(self, key): |
444 if key == '.': |
449 if key == '.': |
482 if f[0] == '/': |
487 if f[0] == '/': |
483 f = f[1:] |
488 f = f[1:] |
484 return filelog.filelog(self.sopener, f) |
489 return filelog.filelog(self.sopener, f) |
485 |
490 |
486 def changectx(self, changeid): |
491 def changectx(self, changeid): |
487 if changeid == None: |
492 return self[changeid] |
488 return context.workingctx(self) |
|
489 return context.changectx(self, changeid) |
|
490 |
493 |
491 def parents(self, changeid=None): |
494 def parents(self, changeid=None): |
492 '''get list of changectxs for parents of changeid''' |
495 '''get list of changectxs for parents of changeid''' |
493 return self.changectx(changeid).parents() |
496 return self[changeid].parents() |
494 |
497 |
495 def filectx(self, path, changeid=None, fileid=None): |
498 def filectx(self, path, changeid=None, fileid=None): |
496 """changeid can be a changeset revision, node, or tag. |
499 """changeid can be a changeset revision, node, or tag. |
497 fileid can be a file revision or node.""" |
500 fileid can be a file revision or node.""" |
498 return context.filectx(self, path, changeid, fileid) |
501 return context.filectx(self, path, changeid, fileid) |
1003 # are we comparing working dir against its parent? |
1006 # are we comparing working dir against its parent? |
1004 if compareworking: |
1007 if compareworking: |
1005 if lookup: |
1008 if lookup: |
1006 fixup = [] |
1009 fixup = [] |
1007 # do a full compare of any files that might have changed |
1010 # do a full compare of any files that might have changed |
1008 ctx = self.changectx('') |
1011 ctx = self['.'] |
1009 ff = self.dirstate.flagfunc(ctx.flags) |
1012 ff = self.dirstate.flagfunc(ctx.flags) |
1010 for f in lookup: |
1013 for f in lookup: |
1011 if (f not in ctx or ff(f) != ctx.flags(f) |
1014 if (f not in ctx or ff(f) != ctx.flags(f) |
1012 or ctx[f].cmp(self.wread(f))): |
1015 or ctx[f].cmp(self.wread(f))): |
1013 modified.append(f) |
1016 modified.append(f) |
1179 heads = [(-self.changelog.rev(h), h) for h in heads] |
1182 heads = [(-self.changelog.rev(h), h) for h in heads] |
1180 heads.sort() |
1183 heads.sort() |
1181 return [n for (r, n) in heads] |
1184 return [n for (r, n) in heads] |
1182 |
1185 |
1183 def branchheads(self, branch=None, start=None): |
1186 def branchheads(self, branch=None, start=None): |
1184 branch = branch is None and self.changectx(None).branch() or branch |
1187 if branch is None: |
|
1188 branch = self[None].branch() |
1185 branches = self.branchtags() |
1189 branches = self.branchtags() |
1186 if branch not in branches: |
1190 if branch not in branches: |
1187 return [] |
1191 return [] |
1188 # The basic algorithm is this: |
1192 # The basic algorithm is this: |
1189 # |
1193 # |
1217 ancestors = set(self.changelog.parentrevs(heads[0])) |
1221 ancestors = set(self.changelog.parentrevs(heads[0])) |
1218 for rev in xrange(heads[0] - 1, nullrev, -1): |
1222 for rev in xrange(heads[0] - 1, nullrev, -1): |
1219 if rev in ancestors: |
1223 if rev in ancestors: |
1220 ancestors.update(self.changelog.parentrevs(rev)) |
1224 ancestors.update(self.changelog.parentrevs(rev)) |
1221 ancestors.remove(rev) |
1225 ancestors.remove(rev) |
1222 elif self.changectx(rev).branch() == branch: |
1226 elif self[rev].branch() == branch: |
1223 heads.append(rev) |
1227 heads.append(rev) |
1224 ancestors.update(self.changelog.parentrevs(rev)) |
1228 ancestors.update(self.changelog.parentrevs(rev)) |
1225 heads = [self.changelog.node(rev) for rev in heads] |
1229 heads = [self.changelog.node(rev) for rev in heads] |
1226 if start is not None: |
1230 if start is not None: |
1227 heads = self.changelog.nodesbetween([start], heads)[2] |
1231 heads = self.changelog.nodesbetween([start], heads)[2] |