Rollback

From PDWiki

Jump to: navigation, search

Contents

About this project

Rollback is a P4API implementation of p4rollback.pl. It offers the following advantages over the Perl implementation:

  • It runs on a single connection and is therefore much faster.
  • It can be integrated very easily into other apps that use P4API. (See px for an example.)

Command line usage

Usage: rollback [ -c pendChange -d -D<flags> ] submittedChange

If provided, the files will be opened in the existing numbered pending changelist pendChange. submittedChange is the changelist to roll back.

By default, any given file revision will not be rolled back if rolling back that revision would implicitly roll back other revisions. For example, rolling back an edit of a file that has subsequently been deleted would roll back not only the edit but the delete (re-adding the file). The -d/-Di/-Ds/-Dt flags override this behavior, with each -Dx flag overriding a specific case and -d overriding them all:

-d/-Di

With this option, rolling back a delete of a file that was subsequently re-added will open it for edit at the revision prior to the delete, requiring a resolve against the re-added revision(s).

-d/-Ds

With this option, rolling back an edit of a file that was subsequently deleted will open it for add at the revision prior to the edit, implicitly rolling back the delete.

-d/-Dt

With this option, rolling back an add of a file that was subsequently edited will open it for delete, implicitly rolling back the edits.

API usage

The "rollback" command can be executed in a P4API application almost exactly as if it were a normal server-side command by instantiating a RollBack object (declared in RollBack.h) and calling the following function:

void RollBack::Run( ClientApi* c, ClientUser* ui, int argc, char** argv );

This function call behaves very much like a call to ClientApi::Run(). It requires that the supplied ClientApi object passed in have an initialized connection (as before a normal Run()), and all of the output from the command will be passed back through the supplied ClientUser. If the "tag" protocol is enabled on the ClientApi, output will be passed back in tagged form via OutputStat() as with most server commands.

Note that the command arguments are passed in via RollBack::Run() rather than being passed beforehand via ClientApi::SetArgv() as with real server commands; this is because arguments set with SetArgv() are not readily accessible on the client.

Recent Changes RSS_Feed.gif

License

Copyright (c) 2008, Sam Stafford. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Personal tools