git-p4: replace each tab with 8 spaces for consistency
Note that the majority of git-p4 uses spaces, not tabs, for indentation. Consistent indentation is a good hygiene for Python scripts, and mixing tabs and spaces in Python can lead to hard-to-find bugs. Signed-off-by: Andrew Garber <andrew@andrewgarber.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Andrew Garber committed
Apr 7, 2011 at 02:01 UTC
c3f6163b0b6e2cfae1422050c9607db1130cded0
1 file changed
+32
-32
contrib/fast-import/git-p4
+32
-32
@@ -222,10 +222,10 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
222
try:
223
while True:
224
entry = marshal.load(p4.stdout)
225
- if cb is not None:
226
- cb(entry)
227
- else:
228
- result.append(entry)
225
+ if cb is not None:
226
+ cb(entry)
227
+ else:
228
+ result.append(entry)
229
except EOFError:
230
pass
231
exitCode = p4.wait()
@@ -449,8 +449,8 @@ def p4ChangesForPaths(depotPaths, changeRange):
449
450
changes = {}
451
for line in output:
452
- changeNum = int(line.split(" ")[1])
453
- changes[changeNum] = True
452
+ changeNum = int(line.split(" ")[1])
453
+ changes[changeNum] = True
454
455
changelist = changes.keys()
456
changelist.sort()
@@ -1033,10 +1033,10 @@ class P4Sync(Command):
1033
# - helper for streamP4Files
1034
1035
def streamOneP4File(self, file, contents):
1036
- if file["type"] == "apple":
1037
- print "\nfile %s is a strange apple file that forks. Ignoring" % \
1038
- file['depotFile']
1039
- return
1036
+ if file["type"] == "apple":
1037
+ print "\nfile %s is a strange apple file that forks. Ignoring" % \
1038
+ file['depotFile']
1039
+ return
1040
1041
relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
1042
relPath = self.wildcard_decode(relPath)
@@ -1085,22 +1085,22 @@ class P4Sync(Command):
1085
# handle another chunk of streaming data
1086
def streamP4FilesCb(self, marshalled):
1087
1088
- if marshalled.has_key('depotFile') and self.stream_have_file_info:
1089
- # start of a new file - output the old one first
1090
- self.streamOneP4File(self.stream_file, self.stream_contents)
1091
- self.stream_file = {}
1092
- self.stream_contents = []
1093
- self.stream_have_file_info = False
1088
+ if marshalled.has_key('depotFile') and self.stream_have_file_info:
1089
+ # start of a new file - output the old one first
1090
+ self.streamOneP4File(self.stream_file, self.stream_contents)
1091
+ self.stream_file = {}
1092
+ self.stream_contents = []
1093
+ self.stream_have_file_info = False
1094
1095
- # pick up the new file information... for the
1096
- # 'data' field we need to append to our array
1097
- for k in marshalled.keys():
1098
- if k == 'data':
1099
- self.stream_contents.append(marshalled['data'])
1100
- else:
1101
- self.stream_file[k] = marshalled[k]
1095
+ # pick up the new file information... for the
1096
+ # 'data' field we need to append to our array
1097
+ for k in marshalled.keys():
1098
+ if k == 'data':
1099
+ self.stream_contents.append(marshalled['data'])
1100
+ else:
1101
+ self.stream_file[k] = marshalled[k]
1102
1103
- self.stream_have_file_info = True
1103
+ self.stream_have_file_info = True
1104
1105
# Stream directly from "p4 files" into "git fast-import"
1106
def streamP4Files(self, files):
@@ -1132,14 +1132,14 @@ class P4Sync(Command):
1132
self.stream_contents = []
1133
self.stream_have_file_info = False
1134
1135
- # curry self argument
1136
- def streamP4FilesCbSelf(entry):
1137
- self.streamP4FilesCb(entry)
1135
+ # curry self argument
1136
+ def streamP4FilesCbSelf(entry):
1137
+ self.streamP4FilesCb(entry)
1138
1139
- p4CmdList("-x - print",
1140
- '\n'.join(['%s#%s' % (f['path'], f['rev'])
1139
+ p4CmdList("-x - print",
1140
+ '\n'.join(['%s#%s' % (f['path'], f['rev'])
1141
for f in filesToRead]),
1142
- cb=streamP4FilesCbSelf)
1142
+ cb=streamP4FilesCbSelf)
1143
1144
# do the last chunk
1145
if self.stream_file.has_key('depotFile'):
@@ -1148,7 +1148,7 @@ class P4Sync(Command):
1148
def commit(self, details, files, branch, branchPrefixes, parent = ""):
1149
epoch = details["time"]
1150
author = details["user"]
1151
- self.branchPrefixes = branchPrefixes
1151
+ self.branchPrefixes = branchPrefixes
1152
1153
if self.verbose:
1154
print "commit into %s" % branch
@@ -1253,7 +1253,7 @@ class P4Sync(Command):
1253
1254
s = ''
1255
for (key, val) in self.users.items():
1256
- s += "%s\t%s\n" % (key.expandtabs(1), val.expandtabs(1))
1256
+ s += "%s\t%s\n" % (key.expandtabs(1), val.expandtabs(1))
1257
1258
open(self.getUserCacheFilename(), "wb").write(s)
1259
self.userMapFromPerforceServer = True