0

I am trying to write some code to move sub-folders with specific names to another folder. I have used the change, copy, sync and delete commands but I am not sure what am I doing wrong.

When I run this code, my Perl Tk GUI spits out "Released xxx", but the folders haven't actually moved. At the same time, when I run these commands it fails to identify even that the file exists in P4V.

Here is the code snippet dealing with the move.

my $changelistnumber 
   = qx{(p4 change -o | findstr /C:Description: /C:Change: /C:Client: /C:User: /C:Status: & echo    Released $folder) | p4 change -i};

$changelistnumber =~ s/[^0-9]//g;

my $printOutput 
   = qx{p4 copy -c $changelistnumber -v //syseng/Libraries/Concept/request_for_approval/$libfolderUnreleased/$folder/...    //syseng/Libraries/Concept/released/$libfolder/$folder/...};

print "Hello!";

$printOutput 
   = qx{p4 sync -k //syseng/Libraries/Concept/request_for_approval/$libfolderUnreleased/$folder/...};

print "Hello1";

$printOutput 
   = qx{p4 delete -c $changelistnumber //syseng/Libraries/Concept/request_for_approval/$libfolderUnreleased/$folder/...};

print "Hello2";

$printOutput = qx{p4 submit -c $changelistnumber};

$d->Label(-text=> "Released $folder" )->pack();
Borodin
  • 126,100
  • 9
  • 70
  • 144
Shashank
  • 329
  • 4
  • 21

2 Answers2

2

Seeing the output of the various commands you're running would be helpful -- if your changelist isn't getting submitted there'll be an error message in there somewhere. I'd recommend trying this scenario out from the command line one command at a time so you have a good idea what the output of each command looks like before you try to script it.

I'd do the changelist part something like this (off the top of my head, you might need to escape some of those characters and/or double check that %change% is the right field to grab from the p4 -Ztag change output):

$changenumber = `p4 --field "Description=I moved it!" change -o | p4 -Ztag -F %change% change -i`;

I'd also suggest using move instead of copy -v+delete if you want to have a local copy of the files without having to do a redundant sync (the move command will just move the files client-side if they're already synced):

p4 sync //depot/oldpath/...
p4 edit //depot/oldpath/...
p4 move //depot/oldpath/... //depot/newpath/...
p4 submit -d "I moved it!"
Samwise
  • 68,105
  • 3
  • 30
  • 44
  • findstr is like grep for Windows batch file programming. Every line that matches one of the strings specified with a /C: flag gets printed. He takes advantage of the fact that Description: is the last one printed, tacks on his description at the end and feeds it to p4 client -i. – Drew Marold Mar 17 '17 at 18:34
  • oh I see, and rather than picking out the number the regex removes everything that's NOT a number. I guess that works? Using "-F" and "--field" is much easier though. :) – Samwise Mar 17 '17 at 20:01
0

Does any of this work at all? Does a changelist get created when you run it? You're capturing the output of each command, print it out and see what's happening. One thing to check is if the environment the script runs in has the correct values for P4PORT, P4USER, etc. I would also concur with what Sam said, a move makes more sense than a copy/delete. Even though you're deleting the files, they still exist on the server taking up space. Plus move retains history, which copy does not.

Drew Marold
  • 175
  • 6