How can I tell which workspace a directory is in? - perforce

I need to know which workspace the directory I am running the batch script is in, so I can get a list of files that are checked out in that workspace.
Is there an easy way to do this?
I am hoping I don't need to get a list of all workspaces and then manually go through them trying to figure out which one my current directory is a child of.
I am doing this on Windows.

The name of your client is set by your P4CLIENT definition or the '-c' argument, not by your current directory. Your current directory might, however, influence the choice of a P4CONFIG file with client-side settings. Try 'p4 set' to see your client-side configuration settings.

Related

Can I get the start-up arguments in Neutralinojs?

I'm trying go make an application able to run a file type, I want to get the path to the file which the user opened the app with.
You can use NL_CWD to get the current working directory. See more information about Neutralinojs global variables here.

How to link to the same workspace?

I have two computers: Work, and Home.
My workspace in my Work Laptop is synced in a Dropbox. That's why I could access my work at home.
But when I try to setup my Perforce at home, I don't know how to link or detect that I have an existing workspace in my Dropbox.
How?
First, I'll assume you can access your Perforce server from home, since you don't mention this in your problem statement.
Next, I'll assume you're able to use the same directory structure at home that you use at work (e.g. C:\Dropbox\projx).
When you create your client spec at work, be sure to edit out the HOST: line, since you'll be using it on two machines.
Use the same client name at home that you use at work.
If for some reason you are unable to use the same directory structure on both machines, you may have to use "p4 client" to change the ROOT: line of your client spec every time you switch between home and work.
Alternatively, you could use two different clients, and use "p4 shelve" to move files to the server when you're done for the day.
You basically just need to tell Perforce the name of your client. Usually you'll do this by adding a .p4config file in your Perforce client's root directory (or in one of its parent directories) that contains the line:
P4CLIENT=your-perforce-client-name
You might also need to add an environment variable that points to this file: P4CONFIG=.p4config.
If the local path to your client's root is different between your work and home machines, you'll also need to set AltRoots in your Perforce client specification and add the path for your home machine.

Issue while creating workspace in perforce

I am not able to create a workspace in perforce. I go to Connection --> New Workspace and then give desired workspace name and workspaceroot and then click "OK". And also it does not give any error. But when I try to access the workspace to add files in it,I am not able to access it, it gives error as "the path is not found". This means workspace has not been created in my local system. Can you please help here? I am new to perforce so please answer accordingly.
In perforce a workspace (aka client) defines the mapping of depot files to the files in your workspace (this is called the "clientview").
Most probably you made a mistake in your client view or when adding the files so that they don't fit (e.g. you can't add a file to perforce when the client does not contain a mapping for the local path it is located to a location in the depot).
In order to give better advice you need to post the content your client and the path of the files you want to add.

How do I delete a file from depot, but leave local copy in tact?

I'm trying to learn Perforce and want to delete a file from the depot(easy to do with p4 delete, p4 submit), but that deletes it from the client machine dir structure as well. I want to keep my local file in my directory intact.
The only way I can see to do this would be to move it out of the hierarchy that is under Perforce control before deleting. I was able to get my file back by syncing an earlier version.
Maybe I set up my client workspace wrong? Or am I misunderstanding a fundamental concept of source control? The client workspace is /home/user and I did it this way so I could add any file under my home directory without getting an error about the file not being under client's root.
FYI - Linux client and server running P4D/LINUX26X86/2009.1/222893 (2009/11/12)
Any advice appreciated.
Thanks.
There is a way to do this, by going behind Perforce's back. Do the following:
Rename the file you want to delete to something new
Run p4 delete on the original filename
p4 submit the change
Rename the file back to the original name
I don't believe there is any way to keep a file you are deleting under Perforce. There is good reason for this, as if the file is deleted in the depot there is no reason (from a source code control perspective) to keep a copy in the client workspace.
I suspect the issue is the way you are using Perforce.
From what you have written it seems that you are using Perforce to backup/track files in your home directory structure. So the way you are using Perforce the "master" is in your home directory and the "copies" are in the depot.
This is not the intended use of a source control system as I understand it.
The master copy of all files are actually what is in the depot. From the depot, multiple clients (views) are made for purposes such as making changes, testing, and so on. The clients are transitory and can be created and deleted as required.
To do what you want to do you may need to rethink how you are using Perforce.
some of the other commands take a parameter that lets you fake the action, but delete doesn't. You could always make a new client, do the delete in that workspace.
In the Workspace tab go to folder containing file(s) to remove from source
Right-click on that directory (or from File menu) and choose Open command window here
Note - If you open your own command prompt in the source directory you may encounter this error:
"Client 'your-client' unknown - use 'client' command to create it."
Enter command p4 delete -k <file_to_delete>
Change will be added to your P4V Helix changelist ready to check in

Perforce Setup Issue

I've got a Perforce server set up, and installed the P4V client. I've created a new depot and a new workspace. Per the documentation, I've mapped the workspace to the depot. So far so good.
I now have a .SQL script that was created by an external application that I wish to check in for the first time. I copied the file into my workspace and can see the file in the client's workspace tree window. Yet when I attempt to mark the file for add, I get a "file(s) not opened on this client" error. I've tried editing a changelist to include the file, but the changelist editor does not "see" the file.
I've read through the documentation (PDF files), but I just do not see what I'm missing. I've worked with other RCS software in a commercial setting, but this is my first stab at trying to set up and administer and RCS system up for personal use.
I think your problem is likely to be with the mappings. This is a reasonably common issue.
Taking your details
Workspace root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666
File dir under root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel_files
View mappings:
//tunnel/... //wtansill_localhost_1666/tunnel/...
//tunnel/* //wtansill_localhost_1666/tunnel/*
With the details above, the line
//tunnel/... //wtansill_localhost_1666/tunnel/...
means that you need to place the files you wish to add into the root of your workspace plus the directory tunnel eg.
C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel
rather than
C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel_files
where you seem to have put them. A way around this is
Create the tunnel folder in the correct place (and any subfolders)
Remove the final folder from your workspace mapping so
//tunnel/... //wtansill_localhost_1666/tunnel/...
becomes
//tunnel/... //wtansill_localhost_1666/...
this would mean anything under
C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel_files
would be mapped to //tunnel/tunnel_files which is I think what you want.
Hope this helps.
Are you sure your filespec includes the directory you have added your file in?
Perhaps you could post your ClientSpec, and the directory in which your file is located?
Workspace root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666
File dir under root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel_files
View mappings:
//tunnel/... //wtansill_localhost_1666/tunnel/...
//tunnel/* //wtansill_localhost_1666/tunnel/*
It's sort of a moot point though. The above workspace was the default set up by Perforce when I installed it. I deleted that workspace and created a new one using the P4V client, retraced my original steps, and now, lo, it works! Go figure.

Resources