aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2007-05-23 18:49:35 -0300
committerHan-Wen Nienhuys <hanwen@google.com>2007-05-31 11:29:25 -0300
commitd2c6dd30eff648aef30d003ef327ab9415f86db0 (patch)
tree2056700fc2a000b58d283858e5510416100f0fb2 /contrib
parentf2eda79f6967363f9377ef3b137a35d0c86aca2c (diff)
downloadgit-d2c6dd30eff648aef30d003ef327ab9415f86db0.tar.gz
git-d2c6dd30eff648aef30d003ef327ab9415f86db0.tar.xz
use p4CmdList() to get file contents in Python dicts. This is more robust.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/fast-import/git-p456
1 files changed, 21 insertions, 35 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 76bbe3fdb..1d799708f 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -580,7 +580,8 @@ class P4Sync(Command):
optparse.make_option("--silent", dest="silent", action="store_true"),
optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
optparse.make_option("--verbose", dest="verbose", action="store_true"),
- optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false"),
+ optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false",
+ help="Import into refs/heads/ , not refs/remotes"),
optparse.make_option("--max-changes", dest="maxChanges"),
optparse.make_option("--keep-path", dest="keepRepoPath", action='store_true')
]
@@ -680,41 +681,22 @@ class P4Sync(Command):
if not specs:
return
- data = read_pipe('p4 print %s' % ' '.join(['"%s"' % path
- for (path, info) in specs]))
+ filedata = p4CmdList('print %s' % ' '.join(['"%s"' % path
+ for (path, info) in specs]))
- idx = 0
- for j in range(0, len(specs)):
- (pathrev, info) = specs[j]
+ j = 0;
+ contents = {}
+ while filedata[j:]:
+ stat = filedata[j]
+ text = filedata[j+1]
+ j += 2
- assert idx < len(data)
- if data[idx:idx + len(pathrev)] != pathrev:
- assert False
- idx = data.find ('\n', idx)
- assert idx > 0
- idx += 1
+ assert stat['code'] == 'stat' and text['code'] == 'text'
+ contents[stat['depotFile']] = text['data']
- start = idx
-
- end = -1
- if j < len(specs)-1:
- (next_pathrev, next_info) = specs[j+1]
- end = data.find(next_pathrev, start)
-
- if end < 0:
- print 'j'
- print 'PATHREV', pathrev, specs[j]
- print 'nextpathrev', next_pathrev, specs[j+1]
- print 'start', start, len(data)
- print 'end', end
-
- assert end >= 0
- else:
- end = len(data)
-
- info['data'] = data[start:end]
- idx = end
- assert idx == len(data)
+ for f in files:
+ assert not f.has_key('data')
+ f['data'] = contents[f['path']]
def commit(self, details, files, branch, branchPrefixes, parent = ""):
epoch = details["time"]
@@ -1158,8 +1140,12 @@ class P4Sync(Command):
% (p, self.revision)
for p in self.depotPaths])):
- if not info.has_key("change"):
- print info
+ if info['code'] == 'error':
+ sys.stderr.write("p4 returned an error: %s\n"
+ % info['data'])
+ sys.exit(1)
+
+
change = int(info["change"])
if change > newestRevision:
newestRevision = change