How to link to the same workspace? - perforce

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.

Related

How can I update my perforce have list to reflect my empty workspace on a new PC?

Recently our development team received new pc's. In an effort to make this transition smoother, I would like to be able to explain to my co-workers how to continue using the client they already have set up to pull files to and from the new pc while eventually ignoring the old pc workspace altogether.
I know about adjusting the attributes of the client itself and allowing the client to be accessed by different hosts. What I'm looking to do now is update the perforce have list for the given client to reflect the files (or lack thereof) that are on the new pc's file system (in the correctly mapped location, obviously).
I'm not sure if it is possible with the p4 flush command for perforce to know which revision of an existing workspace file i have without explicitly telling perforce which revision it is...? (this seems like its asking a lot)
Apart from files that Do exist in the workspace, is there a command that will update the have list to #0 for files that don't exist in the workspace?
OR
Is the sledgehammer approach:
submit any pending changes in the old and/or new workspace
remove any files that may have already been forced into the (new) workspace
$:p4 flush [workspace root]/...#0
appropriate in this situation?
If using the existing workspaces is an option, then this should be pretty easy. It sounds like you already know how to make a workspace accessible from a different host (you can leave it blank to make it accessible by any host). If you copy the workspace folder to the new PC, and update the root of the workspace as necessary, it should "just work" without any additional changes.
If I'm understanding your question correctly, I believe that using a workspace name as your revision modifier will do what you want. For example p4 flush //depot/path/some/file#workspacename. For new machines, we often go through these basic steps to avoid having to resync files.
Copy the files in the workspace from machine 1 to machine 2
Create a client that matches the old client's mappings
In the new client, run:
p4 flush //depot/...#oldclientname

Deploy Mercurial Changes to Website Hosting Account

I want to move only the website files changed since the published revision to a hosting account using SSH or FTP. The hosting account is Linux based but does have have any version control installed, so I can't simply do an update there, and the solution must run on the local development machines.
I'm essentially trying to do what http://www.deployhq.com/ does, but for free. I want to publish changes without having to re-upload everything or manually choose the files to move. I'm open to simply using a bash script that compares versions and copies each file (how? not that great with bash) since we'll be using Linux for development, but something with a web interface would be nice.
Thanks in advance for the help!
This seems more like a job for rsync than one for hg, given that that target doesn't have hg installed.
Something like so:
rsync -avz /path/to/local/files/ remote_host:/remote/path/
This would transfer all files, recursively (-r), from .../local/files/ and place them in /remote/path. The -az compresses and perserves file attributes.
rsync takes care of only transferring files that have changed. Be sure to watch for trailing slashed when specifying source paths, they matter (see the link above).

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

What's the best way to move to a new Perforce server?

My home Perforce server died. I set up a new one.
The project I set it up to support died in the planning phase. The contents of the depot at that point were some prototype code and we never got to setting up a disaster recovery plan.
The dev machines still have the existing code on them. As much as possible, I'd like the change of servers to be transparent to the developers--use the same depositories and the same directories, just change the name of the server to connect to and get back to work.
What do I need to do in order to make this happen?
I assume you don't have access to the perforce depot files from your dead server? I assume you know that you will lose all your history.
If that's the case all you need to do is setup the new server, create a user / client with the same root clientspec path as your original clientspec was using on your dev machine and checkin all the files into perforce. Pretty simple really...
You may need to rebind is SCM binding that you may have in tools like Visual Studio but that's about it.
What Shane suggested will populate the depot with one person's version of the files. But if you have another user who also has a copy then you'll need a couple of extra steps.
Firstly, just set one machine up as suggested by Shane.
You now need to get the second user set up. If you are confident that the version of the code user 2 has exactly matches what you put in the new server, then just create a client spec (probably same name as used before), and then sync using the "Force" flag. This will overwrite all the files on user 2's machine, and - more importantly - ensure Perforce knows which versions you really have.
However, if you are in any doubt as to any differences in code, then do not do the initial sync from the second user's machine. Instead, set up the client spec, then use the "Reconcile offline work" option - from P4V select the workspace, then it's a right click option. Then just walk through the subsequent dialog to sort out what you need.
Finally, if you want a very quick & dirty backup system for your server, I've posted some notes on my blog here - should take you just a couple of minutes to set up.

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