mercurial/context.py
changeset 6762 f67d1468ac50
parent 6760 4faaa0535ea7
child 6763 403682f1c678
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
    69 
    69 
    70     def __getitem__(self, key):
    70     def __getitem__(self, key):
    71         return self.filectx(key)
    71         return self.filectx(key)
    72 
    72 
    73     def __iter__(self):
    73     def __iter__(self):
    74         a = self._manifest.keys()
    74         for f in util.sort(self._manifest):
    75         a.sort()
       
    76         for f in a:
       
    77             yield f
    75             yield f
    78 
    76 
    79     def changeset(self): return self._changeset
    77     def changeset(self): return self._changeset
    80     def manifest(self): return self._manifest
    78     def manifest(self): return self._manifest
    81 
    79 
   132                        changectx=self, filelog=filelog)
   130                        changectx=self, filelog=filelog)
   133 
   131 
   134     def filectxs(self):
   132     def filectxs(self):
   135         """generate a file context for each file in this changeset's
   133         """generate a file context for each file in this changeset's
   136            manifest"""
   134            manifest"""
   137         mf = self.manifest()
   135         for f in util.sort(mf):
   138         m = mf.keys()
       
   139         m.sort()
       
   140         for f in m:
       
   141             yield self.filectx(f, fileid=mf[f])
   136             yield self.filectx(f, fileid=mf[f])
   142 
   137 
   143     def ancestor(self, c2):
   138     def ancestor(self, c2):
   144         """
   139         """
   145         return the ancestor context of self and c2
   140         return the ancestor context of self and c2
   381                     needed[p] += 1
   376                     needed[p] += 1
   382 
   377 
   383         # sort by revision (per file) which is a topological order
   378         # sort by revision (per file) which is a topological order
   384         visit = []
   379         visit = []
   385         for f in files:
   380         for f in files:
   386             fn = [(n.rev(), n) for n in needed.keys() if n._path == f]
   381             fn = [(n.rev(), n) for n in needed if n._path == f]
   387             visit.extend(fn)
   382             visit.extend(fn)
   388         visit.sort()
   383 
   389         hist = {}
   384         hist = {}
   390 
   385         for r, f in util.sort(visit):
   391         for r, f in visit:
       
   392             curr = decorate(f.data(), f)
   386             curr = decorate(f.data(), f)
   393             for p in parents(f):
   387             for p in parents(f):
   394                 if p != nullid:
   388                 if p != nullid:
   395                     curr = pair(hist[p], curr)
   389                     curr = pair(hist[p], curr)
   396                     # trim the history of unneeded revs
   390                     # trim the history of unneeded revs
   528 
   522 
   529     def user(self): return self._user
   523     def user(self): return self._user
   530     def date(self): return self._date
   524     def date(self): return self._date
   531     def description(self): return self._text
   525     def description(self): return self._text
   532     def files(self):
   526     def files(self):
   533         f = self.modified() + self.added() + self.removed()
   527         return util.sort(self._status[0] + self._status[1] + self._status[2])
   534         f.sort()
       
   535         return f
       
   536 
   528 
   537     def modified(self): return self._status[0]
   529     def modified(self): return self._status[0]
   538     def added(self): return self._status[1]
   530     def added(self): return self._status[1]
   539     def removed(self): return self._status[2]
   531     def removed(self): return self._status[2]
   540     def deleted(self): return self._status[3]
   532     def deleted(self): return self._status[3]
   686         self._date = date and util.parsedate(date) or util.makedate()
   678         self._date = date and util.parsedate(date) or util.makedate()
   687         self._user = user or self._repo.ui.username()
   679         self._user = user or self._repo.ui.username()
   688         parents = [(p or nullid) for p in parents]
   680         parents = [(p or nullid) for p in parents]
   689         p1, p2 = parents
   681         p1, p2 = parents
   690         self._parents = [changectx(self._repo, p) for p in (p1, p2)]
   682         self._parents = [changectx(self._repo, p) for p in (p1, p2)]
   691         files = list(files)
   683         files = util.sort(list(files))
   692         files.sort()
       
   693         self._status = [files, [], [], [], []]
   684         self._status = [files, [], [], [], []]
   694         self._filectxfn = filectxfn
   685         self._filectxfn = filectxfn
   695 
   686 
   696         self._extra = extra and extra.copy() or {}
   687         self._extra = extra and extra.copy() or {}
   697         if 'branch' not in self._extra:
   688         if 'branch' not in self._extra: