[p4] Taking work offline from P4 cli?

Johan Nilsson r.johan.nilsson at gmail.com
Mon Aug 30 00:49:48 PDT 2010

Gabor Maghera wrote:
> I've been wanting to do the same but I haven't really tried to do
> this.  Have not found any docs about using cli to go offline, but I
> did notice that P4V creates a local server (with librarian files et
> al). There might be a way to take the server offline via P4V, and then
> pointing the cli P4 client to it.  I'd love to be able to do this, I
> hope someone has figured it out.

After some initial hinting from Robert Cowham (thanks!), and later contact 
with Perforce Support, I've been using the P4 CLI when working offline a 
couple of times. AFAIK you need to go offline using P4V initially, but once 
that's done you can use the CLI for offline work on that specific workspace.

IIRC, when you go offline, P4V will create a special P4CONFIG file for you 
in your workspace root directory. In order to work offline from the CLI you 
can just set your P4CONFIG variable to point to that file. At this point you 
can also try "p4 offline help" for some hints. The output from this command 
seems to indicate that you can subsequently switch the workspace between 
offline/online using the CLI once the initial setup is done:

p4 offline help
    offline -- Manage offline connections
    offlines -- Display list of known offline connections

    p4 offline help
    p4 offline -i [ <port> [ <user> ]]
    p4 offline -o [ <port> [ <user> ]]
    p4 offline offline [ -f ] [ -L <file> ] [ <port> [ <user> ]]
    p4 offline online [ -a ] [ -f ] [ -L <file> ] [ <port> [ <user> ]]
    p4 offline changed
    p4 offlines

        All commands take a [ <port> [ <user> ]] pair, which
        identifies the offline connection. If <user> omitted, p4 users
        current user. If <port> omitted, p4 uses the port specified in
        p4ob's -o<port> launch argument. <user> must be omitted when
        omitting <port>.

        'p4 offline help' displays this message.

        -i causes p4 to read an offline connection specification from
        standard input. P4 does not invoke the user's editor.

        -o causes p4 to write an offline connection specification to
        standard output. P4 does not invoke the user's editor.

        -f causes 'p4 offline offline' to switch to offline mode, even
        if already offline, or 'p4 offline online' to switch to online
        mode, even if already online.

        -L <file> writes a log of commands run during this command.

        'p4 offline offline' switches a connection to offline mode.
        P4 records file and perforce state in offline support files.

        'p4 offline online' switches a connection to online mode.
        All files changed while offline are opened online.

        -a causes 'p4 offline online' to attempt an automatic switch
        to online mode. p4 will copy each offline changelist to online,
        then submit, if there are no conflicts.

        'p4 offline changed' returns a list of all changes submitted
        offline since most recent 'p4 offline offline'.

        'p4 offlines' reports the list of all known offline
        connections. The report includes the online/offline stat of
        each connection.

Regards / Johan

More information about the perforce-user mailing list