# HG changeset patch # User cedricbonhomme # Date 1320141953 -3600 # Tue Nov 01 11:05:53 2011 +0100 # Node ID e0cd24891c7b33bbd18e7fe9a7aea26f937ec9fb # Parent 7f24d1cc621ec1a9c05f57ceada9c81021523bf9 Test the type of the repository (hg, Git) before starting the watcher. diff --git a/watcher.py b/watcher.py --- a/watcher.py +++ b/watcher.py @@ -48,13 +48,14 @@ """ This class represent a watcher for the local repository. """ - def __init__(self, url, local_url, username): + def __init__(self, type_repo, url, local_url, username): """ """ - self.repo = hgsync.HgSync(url, local_url, username) - #self.repo.clone() + if type_repo == "hg": + self.repo = hgsync.HgSync(url, local_url, username) + #self.repo.clone() - self.in_from = "" + self.in_from = "" def process_IN_CREATE(self, event): """ @@ -99,12 +100,12 @@ -def start_watcher(username, password, url, local_url): +def start_watcher(type_repo, username, password, url, local_url): """ Start a watcher. This function is called in a separate thread. """ wm = pyinotify.WatchManager() - notifier = pyinotify.Notifier(wm, PTmp("https://" + username + ":" + password + "@" + url, local_url, username)) + notifier = pyinotify.Notifier(wm, PTmp(type_repo, "https://" + username + ":" + password + "@" + url, local_url, username)) wdd = wm.add_watch((local_url) , mask, rec=True, auto_add=True, exclude_filter=excl) @@ -141,6 +142,6 @@ # Launch a new thread for the repository to watch - thread = threading.Thread(None, start_watcher, None, (username, password, url, local_url)) + thread = threading.Thread(None, start_watcher, None, (type_repo, username, password, url, local_url)) #thread.setDaemon(True) thread.start() \ No newline at end of file