[qt4] fix non displayed working directory on refreshing (closes #137714)

This bug was appearing when the model was filled and the working directory was hidden, for exemple on filtered branch.

authorAlain Leufroy <alain@leufroy.fr>
changesetc006a7b9b6af
branchstable
phasedraft
hiddenyes
parent revision#cf93defad8a8 [launcher] load hgviewlib manually if standalone (closes #117624)
child revision#ed0e1c4f2f59 [qt4] fix typo
files modified by this revision
hgviewlib/qt4/hgrepomodel.py
hgviewlib/qt4/hgrepoviewer.py
# HG changeset patch
# User Alain Leufroy <alain@leufroy.fr>
# Date 1368151820 -7200
# Fri May 10 04:10:20 2013 +0200
# Branch stable
# Node ID c006a7b9b6afefa22a8b3a5f2b87cb7e56618b5f
# Parent cf93defad8a826e80ae683c84368cc3869731552
[qt4] fix non displayed working directory on refreshing (closes #137714)

This bug was appearing when the model was filled and the working
directory was hidden, for exemple on filtered branch.

diff --git a/hgviewlib/qt4/hgrepomodel.py b/hgviewlib/qt4/hgrepomodel.py
@@ -384,11 +384,10 @@
1      def indexFromRev(self, rev):
2          self.ensureBuilt(rev=rev)
3          row = self.rowFromRev(rev)
4          if row is not None:
5              return self.index(row, 0)
6 -        return None
7 
8  class FileRevModel(HgRepoListModel):
9      """
10      Model used to manage the list of revisions of a file, in file
11      viewer of in diff-file viewer dialogs.
diff --git a/hgviewlib/qt4/hgrepoviewer.py b/hgviewlib/qt4/hgrepoviewer.py
@@ -434,11 +434,15 @@
12                  pass
13          wc = self.repo[None]
14          idx = tv.model().index(0, 0) # Working directory or tip
15          if not wc.dirty() and wc.p1().rev() >= 0:
16              # parent of working directory is not nullrev
17 -            idx = tv.model().indexFromRev(wc.p1().rev())
18 +            _idx = tv.model().indexFromRev(wc.p1().rev())
19 +            # may appears if wc has been filtered out
20 +            # (for example not on the filtered branch)
21 +            if _idx is not None:
22 +                idx = _idx
23          tv.setCurrentIndex(idx)
24 
25      def revision_activated(self, rev=None):
26          """
27          Callback called when a revision is double-clicked in the revisions table