hgext/convert/hg.py
changeset 19890 9057855d8749
parent 19457 948df0f10ec1
child 19891 e271970b9821
equal deleted inserted replaced
19889:3828b3e09462 19890:9057855d8749
   258             except error.RepoError:
   258             except error.RepoError:
   259                 raise util.Abort(_('%s is not a valid start revision')
   259                 raise util.Abort(_('%s is not a valid start revision')
   260                                  % startnode)
   260                                  % startnode)
   261             startrev = self.repo.changelog.rev(startnode)
   261             startrev = self.repo.changelog.rev(startnode)
   262             children = {startnode: 1}
   262             children = {startnode: 1}
   263             for rev in self.repo.changelog.descendants([startrev]):
   263             for r in self.repo.changelog.descendants([startrev]):
   264                 children[self.repo.changelog.node(rev)] = 1
   264                 children[self.repo.changelog.node(r)] = 1
   265             self.keep = children.__contains__
   265             self.keep = children.__contains__
   266         else:
   266         else:
   267             self.keep = util.always
   267             self.keep = util.always
       
   268         if rev:
       
   269             self._heads = [self.repo[rev].node()]
       
   270         else:
       
   271             self._heads = self.repo.heads()
   268 
   272 
   269     def changectx(self, rev):
   273     def changectx(self, rev):
   270         if self.lastrev != rev:
   274         if self.lastrev != rev:
   271             self.lastctx = self.repo[rev]
   275             self.lastctx = self.repo[rev]
   272             self.lastrev = rev
   276             self.lastrev = rev
   274 
   278 
   275     def parents(self, ctx):
   279     def parents(self, ctx):
   276         return [p for p in ctx.parents() if p and self.keep(p.node())]
   280         return [p for p in ctx.parents() if p and self.keep(p.node())]
   277 
   281 
   278     def getheads(self):
   282     def getheads(self):
   279         if self.rev:
   283         return [hex(h) for h in self._heads if self.keep(h)]
   280             heads = [self.repo[self.rev].node()]
       
   281         else:
       
   282             heads = self.repo.heads()
       
   283         return [hex(h) for h in heads if self.keep(h)]
       
   284 
   284 
   285     def getfile(self, name, rev):
   285     def getfile(self, name, rev):
   286         try:
   286         try:
   287             fctx = self.changectx(rev)[name]
   287             fctx = self.changectx(rev)[name]
   288             return fctx.data(), fctx.flags()
   288             return fctx.data(), fctx.flags()