Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Perforce unopened modified files

Tags:

perforce

I'm trying to figure out a way to detect files that are not opened for editing but have nevertheless been modified locally. p4 fstat returns a value headModTime for any given file, but this is the change time in the depot, which should not be equal to the filesystem's stat last modified time.

I'm hoping that there exists a more lightweight operation than backing up the original file, forcing a sync of the file, and then running a diff. Ideas?

like image 540
cdleary Avatar asked Nov 05 '08 21:11

cdleary


People also ask

What does p4 reconcile do?

The p4 reconcile command produces output in depot syntax. To see file names and paths in local syntax, use the -l option with p4 reconcile or use p4 status . When called without arguments, p4 reconcile opens the files in a changelist. To preview an operation, use the -n option with p4 reconcile or use p4 status .

What is depot in perforce?

The Helix Server stores files in shared repositories called depots. By default, there is one local depot named depot on every Helix Server installation. To create or edit a depot, use p4 depot depotname and edit the fields in the depot spec form.

What does p4 status do?

The p4 status command finds unopened files in a client's workspace and detects the following three types of inconsistencies between your workspace and the depot: Files present in the depot, present in your have list, but missing from your workspace. By default, these files are then opened for delete .

What is checkout in p4v?

Check-out ( p4 edit ) is about getting the latest version from the depot for editing. When files are checked out for edit, their permissions are set to read-write. When files are not checked out, Perforce sets them to read-only.


2 Answers

From: http://answers.perforce.com/articles/KB/3481/?q=disconnected&l=en_US&fs=Search&pn=1

See step 2 specifically:


2 . Next, open for "edit" any files that have changed:

p4 diff -se //myclient/... | p4 -x - edit 

p4 diff -se returns the names of depot files whose corresponding client file differs in any way from the clients #have revision.

like image 79
grieve Avatar answered Oct 08 '22 12:10

grieve


This SO question gives a way to do this in the P4V GUI:

In the Jan 2009 version of P4V, you can right-click on any folder in your workspace tree and click "reconcile offline work..."

This will do a little processing then bring up a split-tree view of files that are not checked out but have differences from the depot version, or not checked in at all. There may even be a few other categories it brings up.

You can right-click on files in this view and check them out, add them, or even revert them.

Later EDIT:

In the "Reconcile..." window, you can click 'Advanced Reconcile' and be presented with a two-pane, folder hierarchy diff window which is especially useful for finding files you need to add.

PROS: This whole P4V feature is more user-friendly than the command-line version (because it allows utmost granularity in selecting what to reconcile)

CONS: It is in dire need of a subversion/git/hg .ignore-like list, to spare you the pain of manually skipping all the dll's and other cruft in your projects.

like image 22
Cristian Diaconescu Avatar answered Oct 08 '22 13:10

Cristian Diaconescu