git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] git-p4: filter for {'code':'info'} in p4CmdList

From
Miguel Torroja <miguel.torroja@gmail.com>
Date
Jul 13, 2017, 07:00 UTC
Message-ID
<20170713070035.12731-3-miguel.torroja@gmail.com>
In-Reply-To
<20170713070035.12731-1-miguel.torroja@gmail.com>

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>
---
 git-p4.py                  | 9 ++++++---
 t/t9831-git-p4-triggers.sh | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index e3a2791e0..2fa581789 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -313,7 +313,7 @@ def p4_move(src, dest):
     p4_system(["move", "-k", wildcard_encode(src), wildcard_encode(dest)])
 
 def p4_last_change():
-    results = p4CmdList(["changes", "-m", "1"])
+    results = p4CmdList(["changes", "-m", "1"], skip_info=True)
     return int(results[0]['change'])
 
 def p4_describe(change):
@@ -321,7 +321,7 @@ def p4_describe(change):
        the presence of field "time".  Return a dict of the
        results."""
 
-    ds = p4CmdList(["describe", "-s", str(change)])
+    ds = p4CmdList(["describe", "-s", str(change)], skip_info=True)
     if len(ds) != 1:
         die("p4 describe -s %d did not return 1 result: %s" % (change, str(ds)))
 
@@ -509,7 +509,7 @@ def isModeExec(mode):
 def isModeExecChanged(src_mode, dst_mode):
     return isModeExec(src_mode) != isModeExec(dst_mode)
 
-def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
+def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False):
 
     if isinstance(cmd,basestring):
         cmd = "-G " + cmd
@@ -545,6 +545,9 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
     try:
         while True:
             entry = marshal.load(p4.stdout)
+            if skip_info:
+                if 'code' in entry and entry['code'] == 'info':
+                    continue
             if cb is not None:
                 cb(entry)
             else:
diff --git a/t/t9831-git-p4-triggers.sh b/t/t9831-git-p4-triggers.sh
index 871544b1c..bbcf14c66 100755
--- a/t/t9831-git-p4-triggers.sh
+++ b/t/t9831-git-p4-triggers.sh
@@ -20,7 +20,7 @@ test_expect_success 'init depot' '
 	)
 '
 
-test_expect_failure 'clone with extra info lines from verbose p4 trigger' '
+test_expect_success 'clone with extra info lines from verbose p4 trigger' '
 	test_when_finished cleanup_git &&
 	(
 		p4 triggers -i <<-EOF
@@ -38,7 +38,7 @@ test_expect_failure 'clone with extra info lines from verbose p4 trigger' '
 	)
 '
 
-test_expect_failure 'import with extra info lines from verbose p4 trigger' '
+test_expect_success 'import with extra info lines from verbose p4 trigger' '
 	test_when_finished cleanup_git &&
 	(
 		cd "$cli" &&
-- 
2.11.0
Previous: Miguel TorrojaNext: Miguel Torroja
Message 29 of 31 in “git-p4: changelist template with p4 -G change -o”
  1. git-p4: changelist template with p4 -G change -oMiguel Torroja, Jun 20, 2017
  2. Junio C HamanoJun 22, 2017
  3. Luke DiamandJun 24, 2017
  4. miguel torrojaJun 24, 2017
  5. Lars SchneiderJun 24, 2017
  6. miguel torrojaJun 27, 2017
  7. git-p4: parse marshal output "p4 -G" in p4 changesMiguel Torroja, Jun 27, 2017
  8. Junio C HamanoJun 28, 2017
  9. Luke DiamandJun 28, 2017
  10. miguel torrojaJun 28, 2017
  11. miguel torrojaJun 29, 2017
  12. Luke DiamandJun 30, 2017
  13. miguel torrojaJun 30, 2017
  14. git-p4: parse marshal output "p4 -G" in p4 changesMiguel Torroja, Jun 29, 2017
  15. Lars SchneiderJun 30, 2017
  16. Miguel TorrojaJun 30, 2017
  17. Lars SchneiderJun 30, 2017
  18. Miguel TorrojaJun 30, 2017
  19. Miguel TorrojaJul 3, 2017
  20. git-p4: parse marshal output "p4 -G" in p4 changesMiguel Torroja, Jul 3, 2017
  21. Luke DiamandJul 11, 2017
  22. Miguel TorrojaJul 11, 2017
  23. git-p4: parse marshal output "p4 -G" in p4 changesMiguel Torroja, Jul 11, 2017
  24. Luke DiamandJul 12, 2017
  25. Miguel TorrojaJul 12, 2017
  26. Junio C HamanoJul 12, 2017
  27. 1/3 git-p4: git-p4 tests with p4 triggersMiguel Torroja, Jul 13, 2017
  28. 2/3 git-p4: parse marshal output "p4 -G" in p4 changesMiguel Torroja, Jul 13, 2017
  29. 3/3 git-p4: filter for {'code':'info'} in p4CmdListMiguel Torroja, Jul 13, 2017
  30. Miguel TorrojaJul 13, 2017
  31. Junio C HamanoJul 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.