@matheusbsbs / matheus-bagliano / commits / 4fe2ca17f7
Fork 0

Split up the cache commandline options into (command) cache and data cache.

Signed-off-by: Simon Hausmann <hausmann@kde.org>

Simon Hausmann committed Mar 10, 2007 at 21:30 UTC 4fe2ca17f779e14554ebca1208310ae4eb0806b5
1 file changed +12 -8
contrib/fast-import/p4-fast-export.py
+12 -8
@@ -15,7 +15,8 @@ import os, string, sys, time, os.path
15 import marshal, popen2, getopt, sha
16 from sets import Set;
17
18 -cacheDebug = False
18 +dataCache = False
19 +commandCache = False
20
21 silent = False
22 knownBranches = Set()
@@ -30,7 +31,7 @@ if len(globalPrefix) != 0:
31
32 try:
33 opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=", "detect-branches", "changesfile=", "silent", "known-branches=",
33 - "cache-debug" ])
34 + "cache", "command-cache" ])
35 except getopt.GetoptError:
36 print "fixme, syntax error"
37 sys.exit(1)
@@ -47,8 +48,11 @@ for o, a in opts:
48 elif o == "--known-branches":
49 for branch in open(a).readlines():
50 knownBranches.add(branch[:-1])
50 - elif o == "--cache-debug":
51 - cacheDebug = True
51 + elif o == "--cache":
52 + dataCache = True
53 + commandCache = True
54 + elif o == "--command-cache":
55 + commandCache = True
56
57 if len(args) == 0 and len(globalPrefix) != 0:
58 if not silent:
@@ -103,12 +107,12 @@ def p4File(depotPath):
107
108 data = 0
109 try:
106 - if not cacheDebug:
110 + if not dataCache:
111 raise
112 data = open(cacheKey, "rb").read()
113 except:
114 data = os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
111 - if cacheDebug:
115 + if dataCache:
116 open(cacheKey, "wb").write(data)
117
118 return data
@@ -122,7 +126,7 @@ def p4CmdList(cmd):
126 cached = True
127 pipe = 0
128 try:
125 - if not cacheDebug:
129 + if not commandCache:
130 raise
131 pipe = open(cacheKey, "rb")
132 except:
@@ -138,7 +142,7 @@ def p4CmdList(cmd):
142 pass
143 pipe.close()
144
141 - if not cached and cacheDebug:
145 + if not cached and commandCache:
146 pipe = open(cacheKey, "wb")
147 for r in result:
148 marshal.dump(r, pipe)