Skip to content

Commit

Permalink
cmds: restart inotify when switching between bookmarks
Browse files Browse the repository at this point in the history
Restart inotify when switching repositories using the bookmarks widget.
This ensures that inotify sees the new repository.

Closes #256

Reported-by: Charles <char101@ui.ac.id>
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed May 16, 2014
1 parent c4c9bc0 commit 2cd3f8f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cola/app.py
Expand Up @@ -37,6 +37,7 @@
sys.exit(-1)

# Import cola modules
from cola import cmds
from cola import core
from cola import compat
from cola import git
Expand Down Expand Up @@ -143,6 +144,9 @@ def __init__(self, argv, locale=None, gui=True, git_path=None):
qtcompat.install()
qtutils.install()

# Call _update_files when inotify detects changes
inotify.observer(_update_files)

# Add the default style dir so that we find our icons
icon_dir = resources.icon_dir()
qtcompat.add_search_path(os.path.basename(icon_dir), icon_dir)
Expand Down Expand Up @@ -363,6 +367,11 @@ def _send_msg():
Interaction.log(msg)


def _update_files():
# Respond to inotify updates
cmds.do(cmds.UpdateFileStatus)


class ApplicationContext(object):

def __init__(self, args, app, model):
Expand Down
3 changes: 3 additions & 0 deletions cola/cmds.py
Expand Up @@ -9,6 +9,7 @@
from cola import core
from cola import gitcfg
from cola import gitcmds
from cola import inotify
from cola import utils
from cola import difftool
from cola import resources
Expand Down Expand Up @@ -767,6 +768,8 @@ def do(self):
core.chdir(new_worktree)
self.model.set_directory(self.repo_path)
_config.reset()
inotify.stop()
inotify.start()
self.model.update_status()


Expand Down
10 changes: 8 additions & 2 deletions cola/inotify.py
Expand Up @@ -32,7 +32,6 @@
from PyQt4 import QtCore

from cola import gitcfg
from cola import cmds
from cola import core
from cola.git import STDOUT
from cola.i18n import N_
Expand All @@ -41,6 +40,12 @@


_thread = None
_observers = []


def observer(fn):
_observers.append(fn)


def start():
global _thread
Expand Down Expand Up @@ -102,7 +107,8 @@ def __init__(self):
def broadcast(self):
"""Broadcasts a list of all files touched since last broadcast"""
with self._lock:
cmds.do(cmds.UpdateFileStatus)
for observer in _observers:
observer()
self._timer = None

def handle(self, path):
Expand Down
5 changes: 5 additions & 0 deletions share/doc/git-cola/relnotes.rst
Expand Up @@ -29,6 +29,11 @@ Fixes

https://github.com/git-cola/git-cola/pull/253

* Switching repositories using the bookmarks widget was not
refreshing the inotify watcher.

https://github.com/git-cola/git-cola/pull/256

git-cola v2.0.2
===============
Usability, bells and whistles
Expand Down
1 change: 1 addition & 0 deletions share/doc/git-cola/thanks.rst
Expand Up @@ -11,6 +11,7 @@ Thanks
* Boris W
* Ben Boeckel
* Benoît Nouyrigat
* Charles 101
* Christian Jann
* Christopher Meng
* Daniel Fahlke
Expand Down

0 comments on commit 2cd3f8f

Please sign in to comment.