Skip to contentSkip to conversation

perforce.py: fix the perforce fetcher

PATCH In review Robert Yang 2 participants 4 messages Feb 4, 2013 – Feb 5, 2013

lore
Share & tools
lore
#0 lore raw

cover perforce.py: fix the perforce fetcher

The following changes since commit 75f470cd18d693a9a96d9849291c2c8de4dcbeb8:

qt4: Add space for _appends (2013-02-01 22:49:47 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib robert/p4
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/p4

Robert Yang (1):
perforce.py: fix the perforce fetcher

 bitbake/lib/bb/fetch2/perforce.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.7.11.2
#1 lore raw

PATCH 1/1 perforce.py: fix the perforce fetcher

The bb.process.run() will return one tuple, e.g:

p4file = ('strA\nStrB\nstrC\n'), then there will be an iteration on p4file:

for i in p4file:

	[snip]

The i will be 's t r A ...', this is incorrect. use:

p4file = p4file.splitlines()

will fix the problem.

[YOCTO #3619]

---
 bitbake/lib/bb/fetch2/perforce.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/perforce.py +1 -1
index df3a3a3..86ec9ba 100644
@@ -170,7 +170,7 @@ class Perforce(FetchMethod):
         logger.info("Fetch " + loc)
         logger.info("%s%s files %s", p4cmd, p4opt, depot)
         p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt, depot))
-        p4file = p4file.strip()
+        p4file = p4file.splitlines()
 
         if not p4file:
             raise FetchError("Fetch: unable to get the P4 files from %s" % depot, loc)
Signature · 1 line
1.7.11.2
#2 lore raw
Quoted 26 lines · Robert Yang

The bb.process.run() will return one tuple, e.g:

p4file = ('strA\nStrB\nstrC\n'), then there will be an iteration on p4file:

for i in p4file:

        [snip]

The i will be 's t r A ...', this is incorrect. use:

p4file = p4file.splitlines()

will fix the problem.

[YOCTO #3619]

---
 bitbake/lib/bb/fetch2/perforce.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/perforce.py +0 -0
index df3a3a3..86ec9ba 100644

bitbake/lib/bb/fetch2/perforce.py class Perforce(FetchMethod): · line 175

Quoted 7 lines
bitbake/lib/bb/fetch2/perforce.py +1 -1
@@ -170,7 +170,7 @@ class Perforce(FetchMethod):
         logger.info("Fetch " + loc)
         logger.info("%s%s files %s", p4cmd, p4opt, depot)
         p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt,
 depot))
-        p4file = p4file.strip()
+        p4file = p4file.splitlines()
 

Note that splitlines doesn't chop off the trailing newlines from the individual strings. It *probably* wont cause an issue in this case due to how it's passed to the shell in the subsequent subprocess call, but from a correctness standpoint, I'd suggest changing this to something like p4files = [f.rstrip() for f in p4file.splitlines], or doing an rstrip on the individual files in the later iteration.

Signature · 1 line
Christopher Larson
#3 lore raw

Hi Chris,

Thank you very much, I've updated the pull request:

git://git.pokylinux.org/poky-contrib robert/p4
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/p4

bitbake/lib/bb/fetch2/perforce.py +1 -1
index df3a3a3..fc4074d 100644
@@ -170,7 +170,7 @@ class Perforce(FetchMethod):
         logger.info("Fetch " + loc)
         logger.info("%s%s files %s", p4cmd, p4opt, depot)
         p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt, depot))
-        p4file = p4file.strip()
+        p4file = [f.rstrip() for f in p4file.splitlines()]
 
         if not p4file:
             raise FetchError("Fetch: unable to get the P4 files from %s" % 

depot, loc)

// Robert

Quoted 43 lines · Chris Larson
Quoted 26 lines · Robert Yang

The bb.process.run() will return one tuple, e.g:

p4file = ('strA\nStrB\nstrC\n'), then there will be an iteration on p4file:

for i in p4file:

         [snip]

The i will be 's t r A ...', this is incorrect. use:

p4file = p4file.splitlines()

will fix the problem.

[YOCTO #3619]

---
  bitbake/lib/bb/fetch2/perforce.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/perforce.py +0 -0
index df3a3a3..86ec9ba 100644

bitbake/lib/bb/fetch2/perforce.py class Perforce(FetchMethod): · line 175

Quoted 7 lines
bitbake/lib/bb/fetch2/perforce.py +1 -1
@@ -170,7 +170,7 @@ class Perforce(FetchMethod):
          logger.info("Fetch " + loc)
          logger.info("%s%s files %s", p4cmd, p4opt, depot)
          p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt,
 depot))
-        p4file = p4file.strip()
+        p4file = p4file.splitlines()
 

Note that splitlines doesn't chop off the trailing newlines from the individual strings. It *probably* wont cause an issue in this case due to how it's passed to the shell in the subsequent subprocess call, but from a correctness standpoint, I'd suggest changing this to something like p4files = [f.rstrip() for f in p4file.splitlines], or doing an rstrip on the individual files in the later iteration.