[PATCH 6 of 9] vfs: add "mkstemp()"
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Sat Mar 8 10:07:11 CST 2014
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1394294608 -32400
# Sun Mar 09 01:03:28 2014 +0900
# Node ID 478805e9633b292ce1734dded800b9c4f42cd96f
# Parent dea46560b9fb70b49611ed868528deb35457de88
vfs: add "mkstemp()"
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -10,7 +10,7 @@
import util, error, osutil, revset, similar, encoding, phases, parsers
import pathutil
import match as matchmod
-import os, errno, re, glob
+import os, errno, re, glob, tempfile
if os.name == 'nt':
import scmwindows as scmplatform
@@ -193,6 +193,15 @@
def mkdir(self, path=None):
return os.mkdir(self.join(path))
+ def mkstemp(self, suffix='', prefix='tmp', dir=None, text=False):
+ fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
+ dir=self.join(dir), text=text)
+ dname, fname = util.split(name)
+ if dir:
+ return fd, os.path.join(dir, fname)
+ else:
+ return fd, fname
+
def readdir(self, path=None, stat=None, skip=None):
return osutil.listdir(self.join(path), stat, skip)
More information about the Mercurial-devel
mailing list