[meld/Python3: 26/54] vc: Pull run helper out of the git module



commit aef6f90f9dc33b7e2a83a3eaf7f2d1d66a8af7fb
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 15 08:01:07 2015 +1000

    vc: Pull run helper out of the git module

 meld/vc/_vc.py |   11 +++++++++++
 meld/vc/git.py |    5 -----
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index be855e7..46046fd 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -144,6 +144,17 @@ class Vc(object):
         self._tree_meta_cache = {}
         self._tree_missing_cache = collections.defaultdict(set)
 
+    def run(self, *args):
+        """Return subprocess running VC with `args` at VC's location
+
+        For example, `git_vc.run('log', '-p')` will run `git log -p`
+        and return the subprocess object.
+
+        Note that this runs at the *location*, not at the *root*.
+        """
+        cmd = (self.CMD,) + args
+        return subprocess.Popen(cmd, cwd=self.location, stdout=subprocess.PIPE)
+
     def get_files_to_commit(self, paths):
         """Get a list of files that will be committed from paths
 
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 264957f..db0030e 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -31,7 +31,6 @@ import os
 import re
 import shutil
 import stat
-import subprocess
 import tempfile
 from collections import defaultdict
 
@@ -105,10 +104,6 @@ class Vc(_vc.Vc):
             label = ""
         return label
 
-    def run(self, *args):
-        cmd = (self.CMD,) + args
-        return subprocess.Popen(cmd, cwd=self.location, stdout=subprocess.PIPE)
-
     def get_commits_to_push(self):
         proc = self.run(
             "for-each-ref", "--format=%(refname:short) %(upstream:short)",


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