[meld] Support reverting of removed files in Git (bgo#698510)



commit 79432f3031ca2cbf69c37b33e9ee18ee342805fe
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Apr 27 14:50:37 2013 +1000

    Support reverting of removed files in Git (bgo#698510)

 meld/vc/git.py |   10 ++++++++++
 meld/vcview.py |    5 ++++-
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index c8a1cf6..c3579a7 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -96,6 +96,16 @@ class Vc(_vc.CachedVc):
         command = [self.CMD, 'pull']
         runner(command, [], refresh=True, working_dir=self.root)
 
+    def revert(self, runner, files):
+        exists = [f for f in files if os.path.exists(f)]
+        missing = [f for f in files if not os.path.exists(f)]
+        if exists:
+            command = [self.CMD, 'checkout']
+            runner(command, files, refresh=True, working_dir=self.root)
+        if missing:
+            command = [self.CMD, 'checkout', 'HEAD']
+            runner(command, files, refresh=True, working_dir=self.root)
+
     def get_path_for_conflict(self, path, conflict):
         if not path.startswith(self.root + os.path.sep):
             raise _vc.InvalidVCPath(self, path, "Path not in repository")
diff --git a/meld/vcview.py b/meld/vcview.py
index 0a30cd8..87f0865 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -712,7 +712,10 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self._command_on_selected(self.vc.resolved_command())
 
     def on_button_revert_clicked(self, obj):
-        self._command_on_selected(self.vc.revert_command())
+        try:
+            self.vc.revert(self._command, self._get_selected_files())
+        except AttributeError:
+            self._command_on_selected(self.vc.revert_command())
 
     def on_button_delete_clicked(self, obj):
         files = self._get_selected_files()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]