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, Comparable

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: 2002/08/05 $ $Revision: #8 $
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(Env env)
           
static Iterator getBranchIterator(Env env)
           
static Enumeration getBranchNames(Env env)
          Returns list of all branch names.
 HashDecay getCache()
          Returns the HashDecay instance for this class
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.
 Change integrate(String source, StringBuffer sb, Change c)
          Class method for integrating using the instantiated 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 sync()
          Brings this object back into sync with Perforce.
 void sync(String name)
          Synchronizes the Branch with the latest information from P4.
 String toXML()
          Returns a string containing the object in XML form.
 
Methods inherited from class com.perforce.api.Mapping
addView, addView, compareTo, getDescription, getName, getOwner, getView, getViews, lookupMappings, setDescription, setName, setOwner, toString
 
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(Env env)
Parameters:
env - Source control environment.
Returns:
Enumeration of Branches.

getBranchIterator

public static Iterator getBranchIterator(Env env)
Parameters:
env - Source control environment.
Returns:
Iterator 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()
Description copied from class: SourceControlObject
Returns the HashDecay instance for this class
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

integrate

public Change integrate(String source,
                        StringBuffer sb,
                        Change c)
                 throws PerforceException
Class method for integrating using the instantiated Branch.
Parameters:
source - source files to integrate from.
sb - buffer that will contain a log of the integration.
c - Change to be used to contain the integrated files.
See Also:
integrate(Env,String,String,StringBuffer,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.

sync

public void sync()
Description copied from class: SourceControlObject
Brings this object back into sync with Perforce. This also sets the sets the update and sync time for this object.
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.

toXML

public String toXML()
Description copied from class: SourceControlObject
Returns a string containing the object in XML form.
Overrides:
toXML in class Mapping

Perforce

Copyright © 2001, Perforce Software, All rights reserved.