Perforce

com.perforce.api
Class Branch

java.lang.Object
  |
  +--com.perforce.api.SourceControlObject
        |
        +--com.perforce.api.Mapping
              |
              +--com.perforce.api.Branch
All Implemented Interfaces:
Cacheable

public class Branch
extends Mapping

Representation of a source control branch. There are static class methods that can be used to list all P4 branches or to get a particular branch.

Version:
$Date: 2001/11/02 $ $Revision: #1 $
Author:
David Markley

Constructor Summary
Branch()
          Default no-argument constructor.
Branch(String name)
          Constructor that is passed the branch name.
 
Method Summary
 void commit()
          Stores this object back into Perforce, creating it if it didn't already exist.
static Branch getBranch(Env env, String name, boolean force)
          Returns a Branch with the specified name, or null if not found.
static Branch getBranch(String name)
          Returns a Branch with the specified name, or null if not found.
static Enumeration getBranches()
          Returns list of all branches.
static Enumeration getBranches(Env env)
          Returns list of all branches.
static Enumeration getBranchNames(Env env)
          Returns list of all branch names.
 HashDecay getCache()
           
static Change integrate(Env env, String source, String branch, StringBuffer sb, Change c)
          Integrate a set of files using the named branch.
static Change integrate(Env env, Vector fents, String branch, StringBuffer sb, Change c)
          Integrate a set of files using the named branch.
static Change integrate(Env env, Vector fents, String branch, StringBuffer sb, String description)
          Integrate a set of files using the named branch.
static void loadBranches()
          Loads the list of branches using the default environment.
static void loadBranches(Env env)
          Loads a list of all the branches into an internal class HashDecay.
static Enumeration lookupBranches(String prefix)
          Returns a list of branches that begin with the specified prefix.
 void store()
          Stores the branch information back into p4, creating the branch if it didn't already exist.
 void sync()
          Brings this object back into sync with Perforce.
 void sync(String name)
          Synchronizes the Branch with the latest information from P4.
 
Methods inherited from class com.perforce.api.Mapping
addView, addView, getDescription, getName, getOwner, getView, getViews, lookupMappings, setDescription, setName, setOwner, toString, toXML
 
Methods inherited from class com.perforce.api.SourceControlObject
clearCache, getEnv, getSyncTime, getUpdateTime, inSync, invalidate, outOfSync, refreshUpdateTime, setEnv
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Branch

public Branch()
Default no-argument constructor.

Branch

public Branch(String name)
Constructor that is passed the branch name.
Method Detail

commit

public void commit()
            throws CommitException
Description copied from class: SourceControlObject
Stores this object back into Perforce, creating it if it didn't already exist.
Overrides:
commit in class Mapping

getBranch

public static Branch getBranch(Env env,
                               String name,
                               boolean force)
Returns a Branch with the specified name, or null if not found.
Parameters:
env - Environment to use when working with P4.
name - Name of the branch to find.
force - Indicates that the Branch should be sync'd.

getBranch

public static Branch getBranch(String name)
Returns a Branch with the specified name, or null if not found.
Parameters:
name - Name of the branch to find.

getBranches

public static Enumeration getBranches()
Returns list of all branches.
Returns:
Enumeration of Branches.

getBranches

public static Enumeration getBranches(Env env)
Returns list of all branches.
Parameters:
env - Source control environment.
Returns:
Enumeration of Branches.

getBranchNames

public static Enumeration getBranchNames(Env env)
Returns list of all branch names.
Returns:
Enumeration of Strings containing branch names.

getCache

public HashDecay getCache()
Overrides:
getCache in class SourceControlObject

integrate

public static Change integrate(Env env,
                               String source,
                               String branch,
                               StringBuffer sb,
                               Change c)
                        throws PerforceException
Integrate a set of files using the named branch. Uses the Change passed in to contain the integraed files. The change will be *PENDING* after this completes.
Parameters:
env - environment to use when working with P4.
source - source files to integrate from.
branch - name of the branch to integrate with.
sb - buffer that will contain a log of the integration.
c - Change to be used to contain the integrated files.
Returns:
Change containing the files integrated.
See Also:
Change

integrate

public static Change integrate(Env env,
                               Vector fents,
                               String branch,
                               StringBuffer sb,
                               Change c)
                        throws PerforceException
Integrate a set of files using the named branch. Uses the Change passed in to contain the integraed files. The change will be *PENDING* after this completes.
Parameters:
env - environment to use when working with P4.
fents - list of FileEntries to be integrated.
branch - name of the branch to integrate with.
sb - buffer that will contain a log of the integration.
c - Change to be used to contain the integrated files.
Returns:
Change containing the files integrated.
See Also:
Change

integrate

public static Change integrate(Env env,
                               Vector fents,
                               String branch,
                               StringBuffer sb,
                               String description)
                        throws CommitException,
                               PerforceException
Integrate a set of files using the named branch. Creates a Change that contains the integraed files. The change will be *PENDING* after this completes.
Parameters:
env - environment to use when working with P4.
fents - list of FileEntries to be integrated.
branch - name of the branch to integrate with.
sb - buffer that will contain a log of the integration.
description - description to be used for the Change created.
Returns:
Change containing the files integrated.
See Also:
Change

loadBranches

public static void loadBranches()
Loads the list of branches using the default environment.
See Also:
Env

loadBranches

public static void loadBranches(Env env)
Loads a list of all the branches into an internal class HashDecay. This method will only be called by the class itself if the HashDecay is empty. Users should call this method if they believe the p4 branch information needs to be brought up to date.
Parameters:
env - Environment to use when working with P4
See Also:
HashDecay

lookupBranches

public static Enumeration lookupBranches(String prefix)
Returns a list of branches that begin with the specified prefix.
Parameters:
prefix - Prefix for all branches to be returned
Returns:
List of branches matching the prefix.

store

public void store()
           throws CommitException
Stores the branch information back into p4, creating the branch if it didn't already exist.

sync

public void sync()
Description copied from class: SourceControlObject
Brings this object back into sync with Perforce.
Overrides:
sync in class SourceControlObject

sync

public void sync(String name)
Synchronizes the Branch with the latest information from P4. This method forces the Branch to contain the latest, correct information if it didn't already.
Overrides:
sync in class Mapping
Parameters:
name - Name of the Branch to synchronize.

Perforce

Copyright © 2001, Perforce Software, All rights reserved.