diff options
author | Abdo Roig-Maranges <abdo.roig@gmail.com> | 2013-02-16 01:46:34 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2013-02-16 02:08:17 +0100 |
commit | a7136a4664ce9c402b9149555d6d07a2d3cb51b1 (patch) | |
tree | 31de4cbf978b711440392ac1c78b310ed5e139a7 | |
parent | 7cfa2556a2f25264b3146ec3d8120801a232dd76 (diff) | |
download | ranger-a7136a4664ce9c402b9149555d6d07a2d3cb51b1.tar.gz |
replace vcs_backends setting by vcs_backend_git, etc.
The variables vcs_backend_git, vcs_backend_hg and vcs_backend_bzr have three possible values: disabled, local (only local info) and enabled (local and remote info).
-rw-r--r-- | ranger/config/rc.conf | 12 | ||||
-rw-r--r-- | ranger/container/settingobject.py | 4 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 47 |
3 files changed, 37 insertions, 26 deletions
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 9d4fc775..e02e6548 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -41,11 +41,15 @@ set preview_script ~/.config/ranger/scope.sh # Use the external preview script or display simple plain text previews? set use_preview_script true -# Be aware of version control systems and display information about their -# state. Supported version control systems: git, mercurial, bzr. +# Be aware of version control systems and display information. set vcs_aware false -set vcs_backends git -#set vcs_backends git,hg,bzr + +# State of the three backends git, hg, bzr. The possible states are +# disabled, local (only show local info), enabled (show local and remote +# information). +set vcs_backend_git enabled +set vcs_backend_hg disabled +set vcs_backend_hg disabled # Preview images in full color with the external command "w3mimgpreview"? set preview_images false diff --git a/ranger/container/settingobject.py b/ranger/container/settingobject.py index b587676a..06572d97 100644 --- a/ranger/container/settingobject.py +++ b/ranger/container/settingobject.py @@ -46,7 +46,9 @@ ALLOWED_SETTINGS = { 'update_tmux_title': bool, 'use_preview_script': bool, 'vcs_aware': bool, - 'vcs_backends': list, + 'vcs_backend_git': str, + 'vcs_backend_hg': str, + 'vcs_backend_bzr': str, 'xterm_alt_key': bool, } diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index e0b1daa6..86014f38 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -257,27 +257,32 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware): # Load vcs data if self.settings.vcs_aware: item.load_vcs() - if item.vcs and item.vcs.vcsname in self.settings.vcs_backends: - self.has_vcschild = True - try: - if self.vcs_outdated or item.vcs_outdated: - item.vcs_outdated = False - item.vcs.get_status() # caches the file status for get_file_status() - item.vcsbranch = item.vcs.get_branch() - item.vcshead = item.vcs.get_info(item.vcs.HEAD) - if item.path == item.vcs.root: - item.vcsremotestatus = item.vcs.get_remote_status() - else: - item.vcsbranch = self.vcsbranch - item.vcshead = self.vcshead - item.vcsfilestatus = item.vcs.get_file_status(item.path) - except VcsError as err: - item.vcsbranch = None - item.vcshead = None - item.vcsremotestatus = 'unknown' - item.vcsfilestatus = 'unknown' - - self.fm.notify("Can not load vcs data on %s: %s" % (item.path, err), bad=True) + if item.vcs: + if item.vcs.vcsname == 'git': backend_state = self.settings.vcs_backend_git + elif item.vcs.vcsname == 'hg': backend_state = self.settings.vcs_backend_hg + elif item.vcs.vcsname == 'bzr': backend_state = self.settings.vcs_backend_bzr + else: backend_state = 'disabled' + + if backend_state in set(['enabled', 'local']): + self.has_vcschild = True + try: + if self.vcs_outdated or item.vcs_outdated: + item.vcs_outdated = False + item.vcs.get_status() # caches the file status for get_file_status() + item.vcsbranch = item.vcs.get_branch() + item.vcshead = item.vcs.get_info(item.vcs.HEAD) + if item.path == item.vcs.root and backend_state == 'enabled': + item.vcsremotestatus = item.vcs.get_remote_status() + else: + item.vcsbranch = self.vcsbranch + item.vcshead = self.vcshead + item.vcsfilestatus = item.vcs.get_file_status(item.path) + except VcsError as err: + item.vcsbranch = None + item.vcshead = None + item.vcsremotestatus = 'unknown' + item.vcsfilestatus = 'unknown' + self.fm.notify("Can not load vcs data on %s: %s" % (item.path, err), bad=True) files.append(item) self.percent = 100 * len(files) // len(filenames) |