read files before creating the commit.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Han-Wen Nienhuys committed
May 23, 2007 at 18:49 UTC
96e07dd23c570fe5e65e619c0f1e3c87be2a8352
1 file changed
+21
-14
contrib/fast-import/git-p4
+21
-14
@@ -697,6 +697,9 @@ class P4Sync(Command):
697
next_spec, next_info = specs[j+1]
698
end = data.find(next_spec, start)
699
700
+ if end < 0:
701
+ print spec, next_spec
702
+
703
assert end >= 0
704
else:
705
end = len(data)
@@ -712,6 +715,20 @@ class P4Sync(Command):
715
if self.verbose:
716
print "commit into %s" % branch
717
718
+ # start with reading files; if that fails, we should not
719
+ # create a commit.
720
+ new_files = []
721
+ for f in files:
722
+ if [p for p in branchPrefixes if f['path'].startswith(p)]:
723
+ new_files.append (f)
724
+ else:
725
+ sys.stderr.write("Ignoring file outside of prefix: %s\n" % path)
726
+ files = new_files
727
+ self.readP4Files(files)
728
+
729
+
730
+
731
+
732
self.gitStream.write("commit %s\n" % branch)
733
# gitStream.write("mark :%s\n" % details["change"])
734
self.committedChanges.add(int(details["change"]))
@@ -739,16 +756,6 @@ class P4Sync(Command):
756
print "parent %s" % parent
757
self.gitStream.write("from %s\n" % parent)
758
742
-
743
- new_files = []
744
- for f in files:
745
- if [p for p in branchPrefixes if f['path'].startswith(p)]:
746
- new_files.append (f)
747
- else:
748
- sys.stderr.write("Ignoring file outside of prefix: %s\n" % path)
749
- files = new_files
750
-
751
- self.readP4Files(files)
759
for file in files:
760
if file["type"] == "apple":
761
print "\nfile %s is a strange apple file that forks. Ignoring!" % file['path']
@@ -1030,9 +1037,6 @@ class P4Sync(Command):
1037
1038
settings = extractSettingsGitLog(logMsg)
1039
1033
- if self.verbose:
1034
- print "path %s change %s" % (','.join(depotPaths), change)
1035
-
1040
self.readOptions(settings)
1041
if (settings.has_key('depot-paths')
1042
and settings.has_key ('change')):
@@ -1145,6 +1149,9 @@ class P4Sync(Command):
1149
+ ' '.join(["%s...%s"
1150
% (p, self.revision)
1151
for p in self.depotPaths])):
1152
+
1153
+ if not info.has_key("change"):
1154
+ print info
1155
change = int(info["change"])
1156
if change > newestRevision:
1157
newestRevision = change
@@ -1154,7 +1161,7 @@ class P4Sync(Command):
1161
#fileCnt = fileCnt + 1
1162
continue
1163
1157
- for prop in [ "depotFile", "rev", "action", "type" ]:
1164
+ for prop in ["depotFile", "rev", "action", "type" ]:
1165
details["%s%s" % (prop, fileCnt)] = info[prop]
1166
1167
fileCnt = fileCnt + 1