Perforce command line only showing local users/cha

rajeshkumar created the topic: Perforce command line only showing local users/cha
Perforce command line only showing local users/changelists/workspaces, but P4V shows all

We are using P4 for free with two users. In the P4V admin gui I can see both myself and my partner as users, and in the P4V gui I can see all workspaces (clients) and all changelists (both mine and my partner’s). From the command line, ‘p4 users’ only shows me, ‘p4 clients’ only shows my local workspace, etc. Is there some mode, environment setting, or special directory from which I have to use the p4 command line to see those global objects? I believe I am a p4 superuser (since I read this is the default on installation and we didn’t change anything). I’m obviously missing something very basic about the relationship between p4 command line and P4V.

The reason I need to use the command line is to delete an old client workspace (used on a different machine) that has an empty changelist associated with it. I therefore need to use ‘p4 client -d -f old-workspace-name’ from the command line. But when I do it tells me client ‘old-workspace-name’ doesn’t exist.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

mnanjala replied the topic: Re:Perforce command line only showing local users/cha
My first suggestion would be to check the P4PORT environment variable,or any other way of pointing Perforce at the correct server. P4V may be making the correct connection but the p4 command-line program may not.

That is, in P4V, look at the initial Open Connection window show, or
within P4V Connections -> Open Connection. Then, on the command line,
in the local workspace, try
p4 info
and compare the lines that start with the word “Server”.

Tagged :

Continuous Build Integration using Perforce and Hudson

scmuser created the topic: Continuous Build Integration using Perforce and Hu
Continuous Build Integration using Perforce and Hudson

A little background

The basic premise of Continuous Build Integration is simple. You want to know, as soon as possible, whether the the code that you just checked into the source control is breaking anything or not. So, as soon as you checkin your code, the build server gets all your latest code and all other code that depends on your code and builds all the affected projects. Compilation error or failure of any of the test cases should raise an alarm (i.e. send an email to the group).

We are using Perforce as the source control and Hudson as our build server. All of our projects are Mavenized. We have set up a trigger on our Depo in Perforce such that whenever anything is committed to our Depo, it makes an HTTP request with parameters such as the changelist number, clientspec, and userid.

When I joined this project, I inherited a small but a very smartly written servlet that handled the HTTP requests made by Perforce upon any commit. This servlet would:

1. get the changelist number (from the HTTP parameters)
2. get the list of files committed under that changelist by executing the perforce client (p4.exe): p4.exe -p p4server:port -u p4userid -P p4passwd fstat @1234,@1234
3. Identify the projects affected by these files, and
4. Kickoff Hudson build projects to do the build(s).

The catch was that this small code was written in Groovy (apparantly, it was small because it was written in Groovy) and nobody knew Groovy in our team. All of our projects are in Java and it doesn’t make sense to add a completely new programming language to the mix just to save a about 50 lines of code, when there is 1000s of lines of Java code base lying around. So we wanted to convert this Groovy servlet into Java.

This post is about the problem that I faced in step 2 above (retrieving file names committed under a given change list id).

The problem

Even after setting the userid and password flags ( -u and -P) while calling p4.exe and even after setting P4USER and P4PASSWD environment variable, Perforce would not return any data. It would just send back an error message saying: “P4PASSWD is wrong or is unset.”

As it turns out, for some reason, you need first execute p4 login command before calling the p4 fstat command. And p4 client does not accept the password provide in the -P flag or P4PASSWD env variable. When you call p4 login, it asks for the password and waits on the stdin for the user to enter the password. Obviously, this is no good for the continuous build integration. This process must execute without any manual intervention.

The solution

The following is the code snippet that did the trick for me.

//the following code is executed once to login
StringBuilder sb = new StringBuilder();
String loginCmd = "p4 -u " + this.userid + " -P " + this.passwd + " -p " + this.host + " login";

Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(loginCmd);
OutputStream os = p.getOutputStream();
os.write(this.passwd.getBytes());
os.write(“\r\n”.getBytes());
os.flush();
int returncode = p.waitFor();
getOutput(stringBuilder, p.getInputStream());

if (returncode != 0) {
throw new Exception(“Problem in login. Return code: ” + returncode + ” Output:” + sb);
}

…..
//In another method that gets the fstat output for a given changelist
Runtime runtime = Runtime.getRuntime();
String fstatCmd = “p4 fstat @” + changeListId + “,@” + changeListId;
Process p = runtime.exec(fstatCmd);
getOutput(sb, p.getInputStream());
int returncode = p.waitFor();
if (returncode != 0) {
throw new Exception(“Problem in running fstat. Return code: ” + returncode + ” Output:” + sb);
}

Tagged :

P4 shelve

rajeshkumar created the topic: p4 shelve
Store files from a pending changelist in the depot, without submitting them.

Shelving is the process of temporarily storing work in progress on a Perforce Server without submitting a changelist. Shelving is useful when you need to perform multiple development tasks (such as interruptions from higher-priority work, testing across multiple platforms) on the same set of files, or share files for code review before committing your work to the depot.
The p4 shelve command creates, modifies, or discards shelved files in a pending changelist. Shelved files persist in the depot until they are discarded (by means of p4 shelve -d) or replaced by subsequent p4 shelve commands.
After shelving files, you can revert or modify them in your client workspace, and restore the shelved versions of those files to your workspace with the p4 unshelve command.
While files are shelved, other users can unshelve the shelved files into their own workspaces, or into other client workspaces.
Files that have been shelved can also be accessed with the p4 diff, p4 diff2, p4 files, and p4 print commands, using the revision specifier @=change, where change is the pending changelist number.
If no arguments are specified, p4 shelve creates a new changelist, adds files from the user’s default changelist, and (after the user completes a form similar to that used by p4 submit), shelves the specified files into the depot. If a file pattern is given, p4 shelve shelves only the files that match the pattern.

For More Info…
www.perforce.com/perforce/doc.current/ma…s/cmdref/shelve.html
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Find perforce Label info from Workspace

scmuser created the topic: Find perforce Label info from Workspace
Hi,

I have perforce workspace which is synced with p4 label specification. i want to know which label has been sync here in my workspace.

Could you please let me know the command for this?

mnanjala replied the topic: Re:Find perforce Label info from Workspace
It’s not easy, especially when you consider that the workspace might be only partly synced to that label. i.e, the label was used with a more restrictive path than that in the label itself.

One rather crude method is to take each label that might apply to the workspace (you can determine this by the view in the labels, or if you use a meaningful naming convention) and do a test sync (p4 sync -n) of each one in the workspace. With luck, only one of them will show zero actions. However, it’s possible that more than one will seem correct, or that none of them will.Essentially, you’re trying to access label information backwards.
They are aliases for a particular state of the repository, but are not a state in and of themselves. (I.e., “synced to which label” isn’t really meaningful in Perforce.)

If you need to duplicate the state of a workspace into another workspace, are you aware that workspace names are also labels?
You can sync one workspace to the same state as another by using the other workspace’s name. (Assuming the views are compatible.)

Tagged :

Command Line to Sync Perforce Code

rajeshkumar created the topic: Command Line to Sync Perforce Code
Hi,

if you are workspace and client is setup successfully, you can use following command to sync the perforce code in your clientSpec

p4 -p :1666 sync //depot/branch1
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re:Command Line to Sync Perforce Code
Sorry for Typo..

Correct Syntax is:
p4 -p :1666 sync //depot/branch1/…
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Release and license information in Perforce

rajeshkumar created the topic: Release and license information in Perforce
Perforce servers are licensed according to how many users they support.
Licensing information is contained in a file called license in the server root directory.
The license file is a plain text file supplied by Perforce Software. Without the license
file, the Perforce server limits itself to two users and two client workspaces.

To view current licensing information, invoke p4d -V from the server root directory
where the license file resides, or by specifying the server root directory either on the
command line (p4d -V -r server_root) or in the P4ROOT environment variable.

If the server is running, you can also use p4 info to view your licensing information.
The server version is also displayed when invoking p4d -V or p4 -V.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

How to Backup Perforce Server

rajeshkumar created the topic: How to Backup Perforce Server
How to Backup Perforce Server

Regular backups of your Perforce data are vital. The key concepts are:

1. Make sure journaling is active

2. Create checkpoints regularly, and

3. Use p4 verify regularly

4. Versioned files

A checkpoint is a snapshot or copy of the database at a particular moment in time.

A journal is a log that records updates made to the database since the last snapshot was taken.

How to Make sure journaling is active

For UNIX installations, journaling is also automatically enabled. If P4JOURNAL is left unset (and no location is specified on the command line), the default location for the journal is $P4ROOT/journal.

How to create a checkpoints

To create a checkpoint, invoke the p4d program with the -jc (journal-create) flag:

p4d -r root -jc

You can create a checkpoint while the Perforce server (p4d) is running. The checkpoint is created in your server root directory (P4ROOT).

To make the checkpoint, p4d locks the database and then dumps its contents to a file named checkpoint.n in the P4ROOT directory, where n is a sequence number.

To create a checkpoint without being logged in to the machine running the Perforce server, use the command:

p4 admin checkpoint [-z] [prefix]

Versioned files

Your checkpoint and journal files are used to reconstruct the Perforce database files only. Your versioned files are stored in directories under the Perforce server root, and must be backed up separately.

Backup Procedures

1. Verify the integrity of your server and add MD5 digests and file length metadata to any new files:

p4 verify //…

You may wish to pass the -q (quiet) option to p4 verify. If called with the -q option, p4 verify produces output only when errors are detected.

2. Make a checkpoint by invoking p4d with the -jc (journal-create) flag, or by using the p4 admin command. Use one of:

p4d -jc
or:
p4 admin checkpoint

3. Ensure that the checkpoint has been created successfully before backing up any files. (After a disk crash, the last thing you want to discover is that the checkpoints you’ve been backing up for the past three weeks were incomplete!) You can tell that the checkpoint command has completed successfully by examining the error code returned from p4d -jc, or by observing the truncation of the current journal file.

4. Once the checkpoint has been created successfully, back up the checkpoint file, the old journal file, and your versioned files.

Tips:

Use separate physical drives for server root and journal

Use protections and passwords: Until you define a Perforce superuser, every Perforce user is a Perforce superuser, and can run any Perforce command on any file. After starting a new Perforce server, use:> p4 protect and To set (or reset) a user’s password, use p4 passwd username (as a Perforce superuser),

Allocate disk space for anticipated growth

Reference: How to Backup Perforce Server
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Recovery Procedures in Perforce

rajeshkumar created the topic: Recovery Procedures in Perforce
If the database files become corrupted or lost, either because of disk errors, a hardware failure such as a disk crash, the database can be recreated with your stored checkpoint and journal.

it can at least provide a general guideline for recovery from the two most common situations, specifically:
1. corruption of your Perforce database only, without damage to your versioned files, and
2. corruption to both your database and versioned files.

Case 1: Database corruption, versioned files unaffected

You will need:
1. The last checkpoint file, which should be available from the latest P4ROOT directory backup.

2. The current journal file, which should be on a separate filesystem from your P4ROOT
directory, and which should therefore have been unaffected by any damage to the
filesystem where your P4ROOT directory was held.

You will not need:
1. Your backup of your versioned files; if they weren’t affected by the crash, they’re already up to date.

To recover the database

1. Stop the current instance of p4d:
p4 admin stop
(You must be a Perforce superuser to use p4 admin.)

2. Rename (or move) the database (“db.*”) files:
mv your_root_dir/db.* /tmp

There can be no db.* files in the $P4ROOT directory when you start recovery from a checkpoint. Although the old db.* files are never used during recovery, it’s good practice not to delete them until you’re certain your restoration was successful.

3. Invoke p4d with the -jr (journal-restore) flag, specifying your most recent checkpoint and current journal. If you explicitly specify the server root ($P4ROOT), the -r $P4ROOT argument must precede the -jr flag:
p4d -r $P4ROOT -jr checkpoint_file journal_file

This recovers the database as it existed when the last checkpoint was taken, and then apply the changes recorded in the journal file since the checkpoint was taken.

Case 2: Both database and versioned files lost or damaged

You will need:
1. The last checkpoint file, which should be available from the latest P4ROOT directory backup.
2. Your versioned files, which should be available from the latest P4ROOT directory backup.

You will not need:

Your current journal file. The journal contains a record of changes to the metadata and versioned files that occurred between the last backup and the crash; because you’ll be restoring a set of versioned files from a backup taken before that crash, the checkpoint alone contains the metadata useful for the recovery, and the information in the journal is of limited or no use.

To recover the database

1. Stop the current instance of p4d:
p4 admin stop
(You must be a Perforce superuser to use p4 admin.)

2. Rename (or move) the corrupt database (“db.”) files:
mv your_root_dir/db.* /tmp

The corrupt db.* files aren’t actually used in the restoration process, but it’s safe practice not to delete them until you’re certain your restoration was successful.

3. Invoke p4d with the -jr (journal-restore) flag, specifying only your most recent checkpoint:
p4d -r $P4ROOT -jr checkpoint_file

Some Tips While Setting up Perforce Server Configuration to have best Backup & Recovery methodology

1. Make sure you are using Symbolic Links for storing versioned files in another drive
2. Make sure you are Storing Journal files in differnet directory
2. Make sure you are storing check points in different directory
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re: Recovery Procedures in Perforce
Reference can be found in following link…
community.scmgalaxy.com/pg/blog/rajeshku…s-in-perforce-server
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Basic Perforce Administration

rajeshkumar created the topic: Basic Perforce Administration
Basic Perforce Administration

A. User maintenance tasks

1. Resetting passwords
2. Creating users / Deleting users / Setting user access
3. Disabling the automatic creation of users
4. Cleaning up files left open by former users

B. Administrative operations

1. Setting the server security level
2. Obliterating files to reclaim disk space
3. Editing submitted changelists
4. Verifying server integrity
5. Defining files types to control Perforce’s file type detection mechanism
6. Use of the -f flag to force operation

In perforce, There are 2 Types of authentication menthods.
1. passwords
2. tickets

Login to Perforce
p4 login

Logout to the perforce
p4 logout

Server security levels

Perforce superusers can configure server-wide password usage requirements, password strength enforcement, and supported methods of user/server authentication by setting
the security counter. To change the security counter, issue the command:
p4 counter -f security seclevel

where seclevel is 0, 1, 2, or 3. After setting the counter, stop and restart the server.

The default security level is 0: passwords are not required, and password strength is not enforced.

To ensure that all users have passwords, use security level 1. Users of old client programs may still enter weak passwords.

To ensure that all users have strong passwords, use security level 2.

To require that all users have strong passwords, and to require the use of session-based authentication, use security level 3 and current Perforce client software.

Resetting user passwords
p4 passwd username

Creating users
p4 user -f username

Preventing creation of users

1. Create a New p4 group or existing groups
p4 group p4users
2. Set P4 access to that Groups using
p4 protect
and add following..
write group p4users * //…

Deleting obsolete users
p4 user -d -f username

Reverting files left open by obsolete users

For example, if the output of p4 opened shows:
//depot/main/code/file.c#8 – edit default change (txt) by jim@stlouis
you can delete the “stlouis” client workspace specification with:
p4 client -d -f stlouis
Deleting a client workspace specification automatically reverts all files opened in that workspace, and also removes that workspace’s “have list”.

Running from inetd on UNIX

To have p4d start up only when connections are
made to it, using inetd and p4d -i, add the following line to /etc/inetd.conf:

p4dservice stream tcp nowait username /usr/local/bin/p4d p4d -i -rp4droot

and add the following to /etc/services:

p4dservice nnnn/tcp

where:
–> p4dservice is the service name you choose for this Perforce server
–> /usr/local/bin is the directory holding your p4d binary
–> p4droot is the root directory (P4DROOT) to use for this Perforce server (for example, /usr/local/p4d)
–> username is the UNIX user name to use for running this Perforce server
–> nnnn is the port number for this Perforce server to use
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re: Basic Perforce Administration
Reference links can be found here…

community.scmgalaxy.com/pg/blog/rajeshku…force-administration
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Perforce Server Installation and Configuration

rajeshkumar created the topic: Perforce Server Installation and Configuration
p4d – Perforce Server
p4 – Perforce Client
p4win – Perforce Windows Client

Install P4 Server in Unix
1. Copy p4d & p4 in /usr/local/bin
2. Give permission such as chmod +x p4 & chmod +xp4d
3. Create Perforce ROOT directory such as P4ROOT=/usr/local/p4_directory
4. Give permission to P4 root directory and sub directory
5. Tell perforce server to use which port such as P4PORT=servername:1666 or p4d -p 1666
6. Startting Server with Command Line Setup. p4d -r /usr/local/p4root -J /var/log/journal -L /var/log/p4err -p 1666 &
7. Tellin perforce client to which port to listen such as p4_server_hostname:1666
8. Stopping Server e.g. p4 admin stop

Reference: perforce
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

tpatil replied the topic: Re: Perforce Server Installation and Configuration
Do you have any information on how to set up P4 proxy server?

rajeshkumar replied the topic: Re: Perforce Server Installation and Configuration
Hi Tushar,

Soon i will publish one article on this.. Meanwhile if you want it in urgent, please refer Perforce Server Admin Guide…
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :