Jump to content


Multiple Workspaces


  • Please log in to reply
27 replies to this topic

#21 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 947 posts

Posted 24 July 2019 - 07:39 PM

Yes, that's exactly how it's supposed to work!  Each stream depot represents a different project and each project should have its own mainline.

#22 GeorgeH

GeorgeH

    Member

  • Members
  • PipPip
  • 13 posts

Posted 24 July 2019 - 07:44 PM

Finally!

Thank you so much for your help - I really appreciate it!

#23 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 947 posts

Posted 24 July 2019 - 09:32 PM

You're welcome!

<gripe>
It's kind of amazing to me that the UE plugin doesn't just do this automatically when you create a new project as a single "add to source control" operation.  It has all the information (it knows what the project's name is and it knows where it is on the local disk) and just needs to execute a few very simple commands directly against the server to get everything set up for you.  If it already has the infrastructure set up to get your connection info and authenticate against the server (which I think it does), this is something like five more lines of code.  Instead the plugin makes everyone hunt through P4V dialogs to try to figure out where to input that information to get things configured correctly, and based on the volume of questions I see about it, this is clearly not a frictionless process.
</gripe>

I might just write a quick Python script that does this and can be set up to run as a P4V custom tool.  Of course then people have to figure out how to install a custom tool and deal with P4V to input the information manually, so I don't think it actually solves the problem of "this should just work from UE automatically," but I want to see how far off my "five lines of code" estimate is.  :P

#24 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 947 posts

Posted 25 July 2019 - 07:07 AM

Okay, in Python the meat of it is ten lines, not counting the extra credit work I did of setting up a config file.

"""
new_project.py -- creates a new stream depot for a project.
Usage: new_project.py project_name local_path
  project_name: The name of the project, e.g. 'Widget'.
  local_path:   The absolute path to the project on the local disk.
"""

import os
import sys
from P4 import P4

try:
  depot_name = sys.argv[1]
  local_path = sys.argv[2]
except:
  sys.exit("Usage: new_project.py name path")

p4 = P4()
p4.connect()

config_name = p4.env("P4CONFIG")
client_name = "%s-%s" % (depot_name, p4.host)  # e.g. Widget-MYHOST
stream_name = "//%s/main" % depot_name		 # e.g. //Widget/main

if config_name:
  # Write a P4CONFIG file to the project path.
  # Do this first so we'll raise if the user gave us a bogus path
  # and they can fix it before we start writing to the server.
  with open(os.path.join(local_path, config_name), "w+") as f:
	f.write("P4PORT=%s" % p4.port)
	f.write("P4USER=%s" % p4.user)
	f.write("P4CLIENT=%s" % client_name)

# Create the new stream depot.
depot = p4.fetch_depot(depot_name)
depot["Type"] = "stream"
p4.save_depot(depot)

# Create the new mainline stream.
stream = p4.fetch_stream(stream_name)
stream["Type"] = "mainline"
if config_name:
  stream["Ignored"] = config_name
p4.save_stream(stream)

# Create a client of that stream.
client = p4.fetch_client(client_name)
client["Root"] = local_path
client["Stream"] = stream_name
p4.save_client(client)

print("Created %s with a workspace at %s." % (stream_name, local_path))

Set that up in P4V as a custom tool with arguments of "$D $D" (so you can manually enter in the project name and the local path) and you're off to the races.

If anyone happens to know whoever it is maintains the UE plugin (I don't even know if that's something that's maintained by Perforce or not), tell them they're free to compile this script into it.  They don't even have to credit me.

#25 GeorgeH

GeorgeH

    Member

  • Members
  • PipPip
  • 13 posts

Posted 25 July 2019 - 02:53 PM

Thanks for that!

I've noticed something with how I've set things up though.
When I connect a project to Perforce, make a change, submit it etc, close the project then reopen it's not connected to perforce. I have to manually keep reconnecting it every time. Any ideas? :)

#26 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 947 posts

Posted 25 July 2019 - 03:02 PM

By "connect a project to Perforce" you mean you do something in the UE plugin that tells it what the Perforce connection settings are for a project, and when you reopen UE it's forgotten it?  If so I have no idea.  If I had a copy of UE to play with, I'd try to debug by figuring out where it stores that info (I'd assume some kind of config file in the project).

#27 GeorgeH

GeorgeH

    Member

  • Members
  • PipPip
  • 13 posts

Posted 25 July 2019 - 03:05 PM

Yeah pretty much.

I'll connect to it within UE4's Source Controls section, which connects fine, but it's not connected when I reopen the project after closing it.

Edit: Managed to solve it. The Settings that save Source control details was set to Read-Only. Unticking this has solved the issue. :)

#28 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 947 posts

Posted 25 July 2019 - 04:19 PM

View PostGeorgeH, on 25 July 2019 - 03:05 PM, said:

Edit: Managed to solve it. The Settings that save Source control details was set to Read-Only. Unticking this has solved the issue. :)

If that's a file that got added to Perforce, you might want to change its filetype to "+w" so that its writable-ness will persist.  If it's something that shouldn't be shared (i.e. it contains configuration that's specific to your machine and would mess someone else up if they synced it), you might instead want to add it to the "Ignored" section of the stream definition.

<gripe part=2>
This is something that the UE plugin could very easily do for you if it were setting up the streams itself.  There are probably a bunch of standard best practices around what should and shouldn't be checked in to source control (any local settings that are specific to your machine should not be checked in); if you looked over the script I posted above you might have noticed that it adds the P4CONFIG file (if one exists) to the "Ignored" section of the stream, which is to make sure that doesn't get checked in.  If the UE plugin was doing this, it could do the exact same thing to exclude its own local settings files, compiled assets, etc. where relevant, and everything would just automatically work more smoothly with zero user effort (with nothing more than extremely minimal coding effort in the plugin to add in an appropriate list of file names/paths/types).
</gripe>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users