Do not reload data from locked repository (closes #92297)

Hgview displayed nonsense when repo was reloaded in the middle of an Hg operation.

Hg writting operations lock the repo. So, we donnot reload repo data until the lock is released.

authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
changeset578e8d7ff39f
branchdefault
phasepublic
hiddenno
parent revision#e0b63a609824 [qt] allow to pass node/rev/tag as link anchor (closes #87902)
child revision#c0b3108cfe1f [qt] obsolete: grey obsolete changeset out., #d2ff3f7a5444 [lib] phases: display changets with higher phase value on top (wip #92312)
files modified by this revision
hgviewlib/qt4/hgrepoviewer.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1335945849 -7200
# Wed May 02 10:04:09 2012 +0200
# Node ID 578e8d7ff39f653022965517f83a19c8c6e78fec
# Parent e0b63a6098244c123b11ddec613ea9fe23721cfd
Do not reload data from locked repository (closes #92297)

Hgview displayed nonsense when repo was reloaded in the middle of an Hg operation.

Hg writting operations lock the repo. So, we donnot reload repo data until the
lock is released.

diff --git a/hgviewlib/qt4/hgrepoviewer.py b/hgviewlib/qt4/hgrepoviewer.py
@@ -465,16 +465,24 @@
1          watchedfiles = [(self.repo.root, ".hg", "store"),
2                          (self.repo.root, ".hg", "store", "00changelog.i"),
3                          (self.repo.root, ".hg", "dirstate"),
4                          (self.repo.root, ".hg", "store", "phasesroots"),]
5          watchedfiles = [os.path.join(*wf) for wf in watchedfiles]
6 -        mtime = [os.path.getmtime(wf) for wf in watchedfiles \
7 -                 if os.path.exists(wf)]
8 -        if mtime:
9 -            return max(mtime)
10 -        # humm, directory has probably been deleted, exiting...
11 -        self.close()
12 +        for l in (self.repo.sjoin('lock'), self.repo.join('wlock')):
13 +            try:
14 +                if util.readlock(l):
15 +                    break
16 +            except OSError, err:
17 +                if err.errno != 2:
18 +                    raise
19 +        else: # repo not locked by an Hg operation
20 +            mtime = [os.path.getmtime(wf) for wf in watchedfiles \
21 +                     if os.path.exists(wf)]
22 +            if mtime:
23 +                return max(mtime)
24 +            # humm, directory has probably been deleted, exiting...
25 +            self.close()
26 
27      def reload(self):
28          """Reload the repository"""
29          self._reload_rev = self.tableView_revisions.current_rev
30          self._reload_file = self.tableView_filelist.currentFile()