PageRenderTime 22ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tortoisehg/hgqt/filerevmodel.py

https://bitbucket.org/tortoisehg/hgtk/
Python | 69 lines | 42 code | 5 blank | 22 comment | 0 complexity | 19f14456ad87da89d1c849fc3dbe07c5 MD5 | raw file
Possible License(s): GPL-2.0
  1. # Copyright (c) 2009-2010 LOGILAB S.A. (Paris, FRANCE).
  2. # http://www.logilab.fr/ -- mailto:contact@logilab.fr
  3. #
  4. # This program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation; either version 2 of the License, or (at your option) any later
  7. # version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License along with
  14. # this program; if not, write to the Free Software Foundation, Inc.,
  15. # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. from tortoisehg.hgqt.repomodel import HgRepoListModel
  17. from tortoisehg.hgqt.graph import Graph, filelog_grapher
  18. from PyQt4.QtCore import *
  19. class FileRevModel(HgRepoListModel):
  20. """
  21. Model used to manage the list of revisions of a file, in file
  22. viewer of in diff-file viewer dialogs.
  23. """
  24. filled = pyqtSignal()
  25. _allcolumns = ('Rev', 'Branch', 'Description', 'Author', 'Age',
  26. 'LocalTime', 'UTCTime', 'Tags', 'Filename')
  27. _columns = ('Rev', 'Branch', 'Description', 'Author', 'Age', 'Filename')
  28. _stretchs = {'Description': 1, }
  29. _getcolumns = "getFilelogColumns"
  30. def __init__(self, repo, filename=None, parent=None):
  31. """
  32. data is a HgHLRepo instance
  33. """
  34. HgRepoListModel.__init__(self, repo, '', [], False, parent)
  35. self.setFilename(filename)
  36. def setRepo(self, repo, branch='', fromhead=None, follow=False):
  37. self.repo = repo
  38. self._datacache = {}
  39. self.reloadConfig()
  40. def setFilename(self, filename):
  41. self.filename = filename
  42. self._user_colors = {}
  43. self._branch_colors = {}
  44. self.rowcount = 0
  45. self._datacache = {}
  46. if self.filename:
  47. grapher = filelog_grapher(self.repo, self.filename)
  48. self.graph = Graph(self.repo, grapher)
  49. fl = self.repo.file(self.filename)
  50. # we use fl.index here (instead of linkrev) cause
  51. # linkrev API changed between 1.0 and 1.?. So this
  52. # works with both versions.
  53. self.heads = [fl.index[fl.rev(x)][4] for x in fl.heads()]
  54. self.ensureBuilt(row=self.fill_step/2)
  55. QTimer.singleShot(0, lambda: self.filled.emit())
  56. self._fill_timer = self.startTimer(500)
  57. else:
  58. self.graph = None
  59. self.heads = []