[meld] vc._null: Support new VC API in null VC to avoid crashes (bgo#723479)



commit c2fc5a906a773455287d1ed159ee907e5e8860ee
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Feb 8 10:43:16 2014 +1000

    vc._null: Support new VC API in null VC to avoid crashes (bgo#723479)

 meld/vc/_null.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/meld/vc/_null.py b/meld/vc/_null.py
index 0f7fab5..43a5876 100644
--- a/meld/vc/_null.py
+++ b/meld/vc/_null.py
@@ -21,6 +21,9 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import shutil
+import tempfile
+
 from meld.vc import _vc
 
 
@@ -34,3 +37,9 @@ class Vc(_vc.Vc):
         dirs = [_vc.Dir(d[1], d[0], _vc.STATE_NONE) for d in dirs]
         files = [_vc.File(f[1], f[0], _vc.STATE_NONE) for f in files]
         return dirs, files
+
+    def get_path_for_repo_file(self, path, commit=None):
+        with tempfile.NamedTemporaryFile(prefix='meld-tmp', delete=False) as f:
+            with open(path, 'r') as vc_file:
+                shutil.copyfileobj(vc_file, f)
+        return f.name


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