[meld] Support direct repo file access in monotone



commit 3f568f3031f99890f71d3b75a8a062d70a35dc15
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Jun 18 08:08:00 2013 +1000

    Support direct repo file access in monotone

 meld/vc/monotone.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/meld/vc/monotone.py b/meld/vc/monotone.py
index 34c3aea..9485836 100644
--- a/meld/vc/monotone.py
+++ b/meld/vc/monotone.py
@@ -25,6 +25,9 @@
 import errno
 import logging
 import os
+import shutil
+import subprocess
+import tempfile
 
 from . import _vc
 
@@ -155,6 +158,27 @@ class Vc(_vc.CachedVc):
     def get_working_directory(self, workdir):
         return self.root
 
+    def get_path_for_repo_file(self, path, commit=None):
+        if commit is None:
+            commit = ""
+
+        if not path.startswith(self.root + os.path.sep):
+            raise _vc.InvalidVCPath(self, path, "Path not in repository")
+        path = path[len(self.root) + 1:]
+
+        command = [self.CMD, "cat", path]
+        if commit:
+            command.extend(["--revision", commit])
+
+        process = subprocess.Popen(command,
+                                   cwd=self.root, stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE)
+        vc_file = process.stdout
+
+        with tempfile.NamedTemporaryFile(prefix='meld-tmp', delete=False) as f:
+            shutil.copyfileobj(vc_file, f)
+        return f.name
+
     def _lookup_tree_cache(self, rootdir):
         log = logging.getLogger(__name__)
 


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