[meld/VersionControlRework: 77/123] vc: Add new-style commit API and use in git



commit b7683de8a0063e08d1ba733855524d8bbfae616e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Mar 21 12:42:01 2015 +1000

    vc: Add new-style commit API and use in git

 meld/vc/_vc.py |    3 +++
 meld/vc/git.py |    9 +++++----
 meld/vcview.py |    8 ++++++--
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index e4d455a..01a2ba6 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -144,6 +144,9 @@ class Vc(object):
     def get_commit_message_prefill(self):
         return None
 
+    def commit(self, runner, files, message):
+        raise NotImplementedError()
+
     def update(self, runner, files):
         raise NotImplementedError()
 
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 39c9c79..f1eed3f 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -2,7 +2,7 @@
 # Copyright (C) 2002-2005 Stephen Kennedy <stevek gnome org>
 # Copyright (C) 2005 Aaron Bentley <aaron bentley utoronto ca>
 # Copyright (C) 2007 José Fonseca <j_r_fonseca yahoo co uk>
-# Copyright (C) 2010-2013 Kai Willadsen <kai willadsen gmail com>
+# Copyright (C) 2010-2015 Kai Willadsen <kai willadsen gmail com>
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -80,9 +80,6 @@ class Vc(_vc.Vc):
         # Check exists instead of isdir, since .git might be a git-file
         return os.path.exists(os.path.join(location, self.VC_DIR))
 
-    def commit_command(self, message):
-        return [self.CMD, "commit", "-m", message]
-
     # Prototyping VC interface version 2
 
     def update_actions_for_paths(self, path_states, actions):
@@ -178,6 +175,10 @@ class Vc(_vc.Vc):
                 (l for l in message.splitlines() if not l.startswith("#")))
         return None
 
+    def commit(self, runner, files, message):
+        command = [self.CMD, 'commit', '-m', message]
+        runner(command, files, refresh=True, working_dir=self.root)
+
     def update(self, runner, files):
         command = [self.CMD, 'pull']
         runner(command, [], refresh=True, working_dir=self.root)
diff --git a/meld/vcview.py b/meld/vcview.py
index 4851e5b..2e7de2a 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -702,8 +702,12 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
     def on_button_commit_clicked(self, obj):
         response, commit_msg = vcdialogs.CommitDialog(self).run()
         if response == Gtk.ResponseType.OK:
-            self._command_on_selected(
-                self.vc.commit_command(commit_msg))
+            try:
+                self.vc.commit(
+                    self._command, self._get_selected_files(), commit_msg)
+            except NotImplementedError:
+                self._command_on_selected(
+                    self.vc.commit_command(commit_msg))
 
     def on_button_add_clicked(self, obj):
         try:


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