git-p4: filter for {'code':'info'} in p4CmdList

The function p4CmdList accepts a new argument: skip_info. When set to True it ignores any 'code':'info' entry (skip_info=False by default). That allows us to fix some of the tests in t9831-git-p4-triggers.sh known to be broken with verobse p4 triggers Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Miguel Torroja committed Jul 13, 2017 at 09:00 UTC 1997e91f4b36649e7e4f693ca9f35c7a6219de8c
2 files changed +8 -5
git-p4.py
+6 -3
@@ -313,7 +313,7 @@ def p4_move(src, dest):
313 p4_system(["move", "-k", wildcard_encode(src), wildcard_encode(dest)])
314
315 def p4_last_change():
316 - results = p4CmdList(["changes", "-m", "1"])
316 + results = p4CmdList(["changes", "-m", "1"], skip_info=True)
317 return int(results[0]['change'])
318
319 def p4_describe(change):
@@ -321,7 +321,7 @@ def p4_describe(change):
321 the presence of field "time". Return a dict of the
322 results."""
323
324 - ds = p4CmdList(["describe", "-s", str(change)])
324 + ds = p4CmdList(["describe", "-s", str(change)], skip_info=True)
325 if len(ds) != 1:
326 die("p4 describe -s %d did not return 1 result: %s" % (change, str(ds)))
327
@@ -509,7 +509,7 @@ def isModeExec(mode):
509 def isModeExecChanged(src_mode, dst_mode):
510 return isModeExec(src_mode) != isModeExec(dst_mode)
511
512 -def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
512 +def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False):
513
514 if isinstance(cmd,basestring):
515 cmd = "-G " + cmd
@@ -545,6 +545,9 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
545 try:
546 while True:
547 entry = marshal.load(p4.stdout)
548 + if skip_info:
549 + if 'code' in entry and entry['code'] == 'info':
550 + continue
551 if cb is not None:
552 cb(entry)
553 else:
t/t9831-git-p4-triggers.sh
+2 -2
@@ -20,7 +20,7 @@ test_expect_success 'init depot' '
20 )
21 '
22
23 -test_expect_failure 'clone with extra info lines from verbose p4 trigger' '
23 +test_expect_success 'clone with extra info lines from verbose p4 trigger' '
24 test_when_finished cleanup_git &&
25 (
26 p4 triggers -i <<-EOF
@@ -38,7 +38,7 @@ test_expect_failure 'clone with extra info lines from verbose p4 trigger' '
38 )
39 '
40
41 -test_expect_failure 'import with extra info lines from verbose p4 trigger' '
41 +test_expect_success 'import with extra info lines from verbose p4 trigger' '
42 test_when_finished cleanup_git &&
43 (
44 cd "$cli" &&