Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

qtlib: add a gettempdir() utility function

All operations that need snapshots should share this temp
directory, and take advantage of its atexit cleanup.

Changeset c832ca5d46a6

Parent e6cd0f3920fe

by Steve Borho

Changes to one file · Browse files at c832ca5d46a6 Showing diff from parent e6cd0f3920fe Diff from another changeset...

 
5
6
7
 
 
 
 
8
9
10
 
12
13
14
 
 
 
 
 
 
 
 
 
 
 
15
16
17
 
5
6
7
8
9
10
11
12
13
14
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@@ -5,6 +5,10 @@
 # This software may be used and distributed according to the terms of the  # GNU General Public License version 2 or any later version.   +import atexit +import shutil +import tempfile +  from PyQt4 import QtCore, QtGui  from mercurial import extensions   @@ -12,6 +16,17 @@
 from tortoisehg.hgqt.i18n import _  from hgext.color import _styles   +tmproot = None +def gettempdir(): + global tmproot + def cleanup(): + try: shutil.rmtree(tmproot) + except: pass + if not tmproot: + tmproot = tempfile.mkdtemp(prefix='thg.') + atexit.register(cleanup) + return tmproot +  # _styles maps from ui labels to effects  # _effects maps an effect to font style properties. We define a limited  # set of _effects, since we convert color effect names to font style