From 431349cb771621fc336902695b724dfd193b924c Mon Sep 17 00:00:00 2001 From: nfnty Date: Mon, 19 Oct 2015 22:26:57 +0200 Subject: VCS: Fix class for non-root; fixes action commands --- ranger/config/commands.py | 39 ++++++++++++++++++--------------------- ranger/ext/vcs/vcs.py | 1 + 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 9aee9f29..b2c704c7 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1336,18 +1336,16 @@ class stage(Command): def execute(self): from ranger.ext.vcs import VcsError - filelist = [f.path for f in self.fm.thistab.get_selection()] - self.fm.thisdir.vcs_outdated = True -# for f in self.fm.thistab.get_selection(): -# f.vcs_outdated = True - - try: - self.fm.thisdir.vcs.add(filelist) - except VcsError: - self.fm.notify("Could not stage files.") - - self.fm.reload_cwd() + if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: + filelist = [f.path for f in self.fm.thistab.get_selection()] + try: + self.fm.thisdir.vcs.add(filelist) + except VcsError as error: + self.fm.notify('Unable to unstage files: {0:s}'.format(str(error))) + self.fm.reload_cwd() + else: + self.fm.notify('Unable to stage files: Not in repository') class unstage(Command): """ @@ -1358,17 +1356,16 @@ class unstage(Command): def execute(self): from ranger.ext.vcs import VcsError - filelist = [f.path for f in self.fm.thistab.get_selection()] - self.fm.thisdir.vcs_outdated = True -# for f in self.fm.thistab.get_selection(): -# f.vcs_outdated = True - try: - self.fm.thisdir.vcs.reset(filelist) - except VcsError: - self.fm.notify("Could not unstage files.") - - self.fm.reload_cwd() + if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: + filelist = [f.path for f in self.fm.thistab.get_selection()] + try: + self.fm.thisdir.vcs.reset(filelist) + except VcsError as error: + self.fm.notify('Unable to unstage files: {0:s}'.format(str(error))) + self.fm.reload_cwd() + else: + self.fm.notify('Unable to unstage files: Not in repository') class diff(Command): diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py index 9cf84663..5e9f03c1 100644 --- a/ranger/ext/vcs/vcs.py +++ b/ranger/ext/vcs/vcs.py @@ -107,6 +107,7 @@ class Vcs(object): self.track = False self.in_repodir = True else: + self.__class__ = self.rootvcs.__class__ self.track = self.rootvcs.track self.in_repodir = False else: -- cgit 1.4.1-2-gfad0