Search code examples
perforcep4python

when I try to add files to the changelist I keep getting error files not in files(s) not in client view


When I am trying to add files from the command line I get the error saying files not in client view what does it mean ?

createdCLNumber = p4.save_change(changeList)[0].split()[1]
>>> createdCLNumber
'1157539'
>>> p4.run_add("-c", createdCLNumber, "/Users/ciasto/ciasto_piekarz/sandbox/main/upgrade_tools/upgrade_gitlab")
Traceback (most recent call last):

P4.P4Exception: [P4#run] Warnings during command execution( "p4 add -c 1157539 /Users/ciasto/ciasto_piekarz/sandbox/main/upgrade_tools/upgrade_gitlab" )

        [Warning]: '/Users/ciasto/ciasto_piekarz/sandbox/main/upgrade_tools/upgrade_gitlab - file(s) not in client view.'

Solution

  • The error means that the file you are trying to add is not in your client view.

    According to the error message, the local file is:

    /Users/ciasto/ciasto_piekarz/sandbox/main/upgrade_tools/upgrade_gitlab
    

    Is this path under your client's Root, and does the View map it to a depot path? If not, there's no defined depot path for it to be added to.


    Unsolicited advice time: I would highly recommend gaining some basic familiarity with Perforce from the command line before trying to automate Perforce workflows with P4Python! It's much easier to make corrections for simple beginner mistakes like this and gain an understanding of the core concepts (e.g. how to define client workspaces and use them to interact with depot files) if you're entering commands at an interactive prompt than if you have to modify a script and start over from scratch for each debugging session. Everything you learn at the command line has a 1:1 mapping to the Python API, so the knowledge will transfer extremely well. The API is designed for people who already have familiarity with Perforce commands and data models, so people who dive into it without knowing Perforce beforehand always end up feeling very lost. I've seen it a hundred times.

    (Almost every time I give this advice people ignore it because they "don't have time" to learn how to use the CLI before diving into writing their script, but I can guarantee you're going to end up spending about a month learning how to use Perforce via P4Python when you could have mastered it in a single afternoon of messing around in the terminal.)