using System;
using System.Collections.Generic;
namespace Perforce.P4
{
///
/// Describes the pending or completed action related to open,
/// resolve, or integration for a specific file.
///
public enum FileAction : long
{
///
/// None.
///
None = 0x0000,
///
/// Opened for add.
///
Add = 1,
///
/// Opened for branch.
///
Branch = 2,
///
/// Opened for edit.
///
Edit = 3,
///
/// Opened for integrate.
///
Integrate = 4,
///
/// File has been deleted.
///
Delete = 5,
///
/// file was integrated from partner-file, and partner-file
/// had been previously deleted.
///
DeleteFrom = 6,
///
/// file was integrated into partner-file, and file had been
/// previously deleted.
///
DeleteInto = 7,
///
/// File has been synced.
///
Sync = 8,
///
/// File has been updated.
///
Updated = 9,
///
/// File has been added.
///
Added = 10,
///
/// file was integrated into previously nonexistent partner-file,
/// and partner-file was reopened for add before submission.
///
AddInto = 11,
///
/// File has been refreshed.
///
Refreshed = 12,
///
/// File was integrated from partner-file, accepting yours.
///
Ignored = 13,
///
/// File was integrated into partner-file, accepting yours.
///
IgnoredBy = 14,
///
/// File has been abandoned.
///
Abandoned = 15,
///
/// None.
///
EditIgnored = 16,
///
/// File is opened for move.
///
Move = 17,
///
/// File has been added as part of a move.
///
MoveAdd = 18,
///
/// File has been deleted as part of a move.
///
MoveDelete = 19,
///
/// File was integrated from partner-file, accepting theirs
/// and deleting the original.
///
MovedFrom = 20,
///
/// File was integrated into partner-file, accepting merge.
///
MovedInto = 21,
///
/// File has not been resolved.
///
Unresolved = 22,
///
/// File was integrated from partner-file, accepting theirs.
///
CopyFrom = 23,
///
/// File was integrated into partner-file, accepting theirs.
///
CopyInto = 24,
///
/// File was integrated from partner-file, accepting merge.
///
MergeFrom = 25,
///
/// File was integrated into partner-file, accepting merge.
///
MergeInto = 26,
///
/// file was integrated from partner-file, and file was edited
/// within the p4 resolve process. This allows you to determine
/// whether the change should ever be integrated back; automated
/// changes (merge from) needn't be, but original user edits
/// (edit from) performed during the resolve should be.
///
EditFrom = 27,
///
/// File was integrated into partner-file, and partner-file was
/// reopened for edit before submission.
///
EditInto = 28,
///
/// File was purged.
///
Purge = 29,
///
/// File was imported.
///
Import = 30,
///
/// File did not previously exist; it was created as a copy of
/// partner-file.
///
BranchFrom = 31,
///
/// Partner-file did not previously exist; it was created as a
/// copy of file.
///
BranchInto = 32,
///
/// File was reverted.
///
Reverted = 33,
///
/// File was archived.
///
Archive = 34,
}
///
/// Class summarizing the use of this file by another user.
///
public class OtherFileUser
{
private string _client;
///
/// Property for Client name
///
public string Client
{
get { return _client; }
set
{
_client = value;
string[] parts = value.Split('@');
if (parts.Length > 0)
UserName = parts[0];
if (parts.Length > 1)
ClientName = parts[1];
}
}
///
/// User Name
///
public string UserName {get; set;}
///
/// File Action
///
public FileAction Action { get; set; }
///
/// Is File Locked?
///
public bool hasLock { get; set; }
///
/// Client Name
///
public string ClientName { get; set; }
///
/// Change List Number
///
public int ChangelistId { get; set; }
}
///
/// Specifies other users who have a particular file open.
///
public class OtherUsers : Dictionary
{
///
/// Get OtherFileUser info from OtherUsers
/// given a key
///
/// name of user to return
/// OtherFileUser
public new OtherFileUser this[string key]
{
get
{
if (base.ContainsKey(key) == false)
{
OtherFileUser newEntry = new OtherFileUser();
newEntry.Client = key;
base.Add(key, newEntry);
}
return base[key];
}
set
{
base[key] = value;
}
}
}
///
/// Metadata for a specific file stored in a Perforce repository.
///
public class FileMetaData
{
///
/// Default constructor
///
public FileMetaData()
{
MovedFile = null;
IsMapped = false;
Shelved = false;
HeadAction = FileAction.None;
HeadChange = -1;
HeadRev = -1;
HeadType = null;
HeadTime = DateTime.MinValue;
HeadModTime = DateTime.MinValue;
MovedRev = -1;
HaveRev = -1;
Desc = null;
Digest = null;
FileSize = -1;
Action = FileAction.None;
Type = null;
ActionOwner = null;
Change = -1;
Resolved = false;
Unresolved = false;
Reresolvable = false;
OtherOpen = 0;
OtherOpenUserClients = null;
OtherLock = false;
OtherLockUserClients = null;
OtherActions = null;
OtherChanges = null;
OurLock = false;
ResolveRecords = null;
Attributes = null;
AttributesProp = null;
AttributeDigests = null;
OpenAttributes = null;
OpenAttributesProp = null;
TotalFileCount = -1;
Directory = null;
}
///
/// Parameterized constructor
///
/// was file moved?
/// is file in workspace?
/// is file shelved
/// Last Action to File
/// Change ID
/// Head Revision
/// Type of File
/// Time file created
/// Last modified time
/// Revision which was moved
/// Revision we have
/// Description of File
/// Digest for file
/// size of file
/// current action on file
/// file type
/// owner of file
/// current change ID
/// Resolved
/// Unresolved
/// Re-Resolvable
/// How many others have file open?
/// List of other clients with file open
/// true if other user has file locked
/// List of other clients locking this file
/// List of other FileActions
/// List of other change ID's
/// This file is locked by us
/// List of resolve records
/// Dictionary of attributes
/// Dictionary of attribute properties
/// Dictionary of attribute digests
/// Dictionary of open attributes
/// Dictionary of open attribute properties
/// count of files
/// location of file
public FileMetaData( DepotPath movedfile,
bool ismapped,
bool shelved,
FileAction headaction,
int headchange,
int headrev,
FileType headtype,
DateTime headtime,
DateTime headmodtime,
int movedrev,
int haverev,
string desc,
string digest,
int filesize,
FileAction action,
FileType type,
string actionowner,
int change,
bool resolved,
bool unresolved,
bool reresolvable,
int otheropen,
List otheropenuserclients,
bool otherlock,
List otherlockuserclients,
List otheractions,
List otherchanges,
bool ourlock,
List resolverecords,
Dictionary attributes,
Dictionary attributesprop,
Dictionary attributedigests,
Dictionary openattributes,
Dictionary openattributesprop,
long totalfilecount,
string directory
)
{
MovedFile = movedfile;
IsMapped = ismapped;
Shelved = shelved;
HeadAction = headaction;
HeadChange = headchange;
HeadRev = headrev;
HeadType = headtype;
HeadTime = headtime;
HeadModTime = headmodtime;
MovedRev = movedrev;
HaveRev = haverev;
Desc = desc;
Digest = digest;
FileSize = filesize;
Action = action;
Type = type;
ActionOwner = actionowner;
Change = change;
Resolved = resolved;
Unresolved = unresolved;
Reresolvable = reresolvable;
OtherOpen = otheropen;
OtherOpenUserClients = otheropenuserclients;
OtherLock = otherlock;
OtherLockUserClients = otherlockuserclients;
OtherActions = otheractions;
OtherChanges = otherchanges;
OurLock = ourlock;
ResolveRecords = resolverecords;
Attributes = attributes;
AttributesProp = attributesprop;
AttributeDigests = attributedigests;
OpenAttributes = openattributes;
OpenAttributesProp = openattributesprop;
TotalFileCount = totalfilecount;
Directory = directory;
}
///
/// Constructor for FileMetaData given a File
/// This command is "lossy" not all FileMetaData will be valid
///
/// File
public FileMetaData(File f)
{
MovedFile = null;
IsMapped = false;
Shelved = false;
HeadAction = FileAction.None;
HeadChange = -1;
HeadRev = -1;
HeadType = null;
HeadTime = DateTime.MinValue;
HeadModTime = DateTime.MinValue;
MovedRev = -1;
Revision rev = f.Version as Revision;
if (rev != null)
{
HaveRev = rev.Rev;
}
else
{
HaveRev = -1;
}
Desc = null;
Digest = null;
FileSize = -1;
Action = f.Action;
Type = f.Type;
ActionOwner = f.User;
Change = f.ChangeId;
Resolved = false;
Unresolved = false;
Reresolvable = false;
OtherOpen = 0;
OtherOpenUserClients = null;
OtherLock = false;
OtherLockUserClients = null;
OtherActions = null;
OtherChanges = null;
OurLock = false;
ResolveRecords = null;
Attributes = null;
AttributesProp = null;
AttributeDigests = null;
OpenAttributes = null;
OpenAttributesProp = null;
Directory = null;
TotalFileCount = -1;
DepotPath = f.DepotPath;
ClientPath = f.ClientPath;
}
///
/// Constructor for FileMetaData given a FileSpec
/// This command is "lossy" not all FileMetaData will be valid
///
/// FileSpec
public FileMetaData(FileSpec f)
{
MovedFile = null;
IsMapped = false;
Shelved = false;
HeadAction = FileAction.None;
HeadChange = -1;
HeadRev = -1;
HeadType = null;
HeadTime = DateTime.MinValue;
HeadModTime = DateTime.MinValue;
MovedRev = -1;
Revision rev = f.Version as Revision;
if (rev != null)
{
HaveRev = rev.Rev;
}
else
{
HaveRev = -1;
}
Desc = null;
Digest = null;
FileSize = -1;
Action = FileAction.None;
Type = null;
ActionOwner = null;
Change = -1;
Resolved = false;
Unresolved = false;
Reresolvable = false;
OtherOpen = 0;
OtherOpenUserClients = null;
OtherLock = false;
OtherLockUserClients = null;
OtherActions = null;
OtherChanges = null;
OurLock = false;
ResolveRecords = null;
Attributes = null;
AttributesProp = null;
AttributeDigests = null;
OpenAttributes = null;
OpenAttributesProp = null;
Directory = null;
TotalFileCount = -1;
DepotPath = f.DepotPath;
ClientPath = f.ClientPath;
}
///
/// The location of the file in the depot
///
public DepotPath DepotPath { get; set; }
///
/// Check if there is a non-empty Depot Path
///
public bool IsInDepot
{
get
{
return ((DepotPath !=null) && (string.IsNullOrEmpty(DepotPath.Path) == false));
}
}
///
/// The location of the file in the client's file system,
/// a LocalPath
///
public LocalPath LocalPath { get; set; }
///
/// The location of the file relative to client root
/// a ClientPath
///
public ClientPath ClientPath { get; set; }
///
/// Check if there is a non empty ClientPath
///
public bool IsInClient
{
get
{
return ((ClientPath != null) && (string.IsNullOrEmpty(ClientPath.Path) == false));
}
}
///
/// Access the DepotPath of the Moved File
///
public DepotPath MovedFile { get; set; }
///
/// Is this file mapped in the client/workspace?
///
public bool IsMapped { get; set; }
///
/// Is this file shelved
///
public bool Shelved { get; set; }
private StringEnum _headAction = FileAction.None;
///
/// What was the last action done on this file?
///
public FileAction HeadAction
{
get { return (_headAction == null)? FileAction.None : (FileAction) _headAction; }
set {_headAction = value; }
}
///
/// What Change Id is associated with Head revision
///
public int HeadChange { get; set; }
///
/// What revision is the Head revision
///
public int HeadRev { get; set; }
///
/// What is the FileType of the Head Revision
///
public FileType HeadType { get; set; }
///
/// What is the creation time of the head revision
///
public DateTime HeadTime { get; set; }
///
/// What is the last modification time of the head revision
///
public DateTime HeadModTime { get; set; }
///
/// What revision was moved?
///
public int MovedRev { get; set; }
///
/// What revision do you have?
///
public int HaveRev { get; set; }
///
/// Description
///
public string Desc { get; set; }
///
/// MD5 Digest for this file
///
public string Digest { get; set; }
///
/// Size of the file
///
public long FileSize { get; set; }
private StringEnum _action;
///
/// What is the current Action being performed on this file
///
public FileAction Action
{
get { return (_action == null)? FileAction.None : (FileAction) _action; }
set { _action = value; }
}
///
/// What is the File Type of this file
///
public FileType Type { get; set; }
///
/// Who is causing the current action to this file
///
public string ActionOwner { get; set; }
///
/// Change ID
///
public int Change { get; set; }
///
/// Is this file Resolved?
///
public bool Resolved { get; set; }
///
/// Is this file Unresolved?
///
public bool Unresolved { get; set; }
///
/// Is this file Re Resolvable?
///
public bool Reresolvable { get; set; }
///
/// How many others have this file open?
///
public int OtherOpen { get; set; }
///
/// List of other clients which have this file open
///
public IList OtherOpenUserClients { get; set; }
///
/// Does someone else have this file locked?
///
public bool OtherLock { get; set; }
///
/// List of Other Locks Clients
///
public IList OtherLockUserClients { get; set; }
///
/// List of Actions by other users
///
public IList OtherActions { get; set; }
///
/// List of other change IDs
///
public IList OtherChanges { get; set; }
///
/// Do we have this file locked?
///
public bool OurLock { get; set; }
///
/// List of Resolve records
///
public IList ResolveRecords { get; set; }
///
/// Dictionary of Attributes
///
public Dictionary Attributes { get; set; }
///
/// Dictionary of Attribute Properties
///
public Dictionary AttributesProp { get; set; }
///
/// Dictionary of Attribute MD5 Digests
///
public Dictionary AttributeDigests { get; set; }
///
/// Dictionary of Open Attributes
///
public Dictionary OpenAttributes { get; set; }
///
/// Dictionary of Open Attributes Properties
///
public Dictionary OpenAttributesProp { get; set; }
///
/// Total File count
///
public long TotalFileCount { get; set; }
///
/// Other Users of this file
///
public OtherUsers OtherUsers { get; set; }
///
/// Directory containing this file
///
public string Directory { get; set; }
///
/// Given tagged output from an "fstat" command instantiate this object.
///
/// Tagged output from fstat
public void FromFstatCmdTaggedData(TaggedObject obj)
{
if (obj.ContainsKey("clientFile"))
{
string path = obj["clientFile"];
if (path.StartsWith("//"))
{
ClientPath = new ClientPath(obj["clientFile"]);
}
else
{
ClientPath = new ClientPath(obj["clientFile"]);
LocalPath = new LocalPath(obj["clientFile"]);
}
}
if (obj.ContainsKey("path"))
{
LocalPath = new LocalPath(obj["path"]);
}
if (obj.ContainsKey("depotFile"))
{
string p = PathSpec.UnescapePath(obj["depotFile"]);
DepotPath = new DepotPath(p);
}
if (obj.ContainsKey("movedFile"))
{
MovedFile = new DepotPath(obj["movedFile"]);
if (obj.ContainsKey("movedRev"))
{
int movedrev = -1;
if (int.TryParse(obj["movedRev"], out movedrev))
{
MovedRev = movedrev;
}
}
}
if (obj.ContainsKey("isMapped"))
{ IsMapped = true; }
if (obj.ContainsKey("shelved"))
{ Shelved = true; }
if (obj.ContainsKey("headAction"))
{
_headAction = obj["headAction"];
}
if (obj.ContainsKey("headChange"))
{
int r = -1;
if (int.TryParse(obj["headChange"], out r))
{
HeadChange = r;
}
}
if (obj.ContainsKey("headRev"))
{
int r = -1;
if (int.TryParse(obj["headRev"], out r))
{
HeadRev = r;
}
}
if (obj.ContainsKey("headType"))
{
HeadType = new FileType(obj["headType"]);
}
if (obj.ContainsKey("headTime"))
{
HeadTime = FormBase.ConvertUnixTime(obj["headTime"]);
}
if (obj.ContainsKey("headModTime"))
{
HeadModTime = FormBase.ConvertUnixTime(obj["headModTime"]);
}
if (obj.ContainsKey("haveRev"))
{
int r = -1;
if ((int.TryParse(obj["haveRev"], out r)) && (r > 0))
{
HaveRev = r;
}
}
if (obj.ContainsKey("desc"))
{ Desc = obj["desc"]; }
if (obj.ContainsKey("digest"))
{ Digest = obj["digest"]; }
if (obj.ContainsKey("fileSize"))
{
long s = -1;
if (long.TryParse(obj["fileSize"], out s))
{
FileSize = s;
}
}
if (obj.ContainsKey("action"))
{
_action = obj["action"];
}
if (obj.ContainsKey("type"))
{
Type = new FileType(obj["type"]);
}
else if (obj.ContainsKey("headType"))
{
// If not on mapped in current client, will not have
//the Type filed so User the HeadType
Type = new FileType(obj["headType"]);
}
else
{
Type = new FileType(BaseFileType.Text, FileTypeModifier.None);
}
if (obj.ContainsKey("actionOwner"))
{
ActionOwner = obj["actionOwner"];
}
if (obj.ContainsKey("change"))
{
int c = -1;
if (int.TryParse(obj["change"], out c))
{
Change = c;
}
else
{
Change = 0;
}
}
if (obj.ContainsKey("resolved"))
{ Resolved = true; }
if (obj.ContainsKey("unresolved"))
{ Unresolved = true; }
if (obj.ContainsKey("reresolvable"))
{ Reresolvable = true; }
if (obj.ContainsKey("otherLock"))
{
OtherLock = true;
}
if (obj.ContainsKey("otherOpen"))
{
int cnt = 0;
if (int.TryParse(obj["otherOpen"], out cnt))
{
OtherOpen = cnt;
OtherLockUserClients = new List();
}
if (cnt > 0)
{
OtherUsers = new OtherUsers();
OtherOpenUserClients = new List();
OtherActions = new List();
OtherChanges = new List();
for (int idx=0; idx < cnt; idx++)
{
string key = String.Format("otherOpen{0}", idx);
string otherClientName = null;
OtherFileUser ofi = null;
if (obj.ContainsKey(key))
{
otherClientName = obj[key];
OtherOpenUserClients.Add(otherClientName);
}
ofi = OtherUsers[otherClientName];
ofi.Client = otherClientName;
key = String.Format("otherAction{0}", idx);
if (obj.ContainsKey(key))
{
StringEnum otheraction = obj[key];
OtherActions.Add(otheraction);
ofi.Action = otheraction;
}
key = String.Format("otherChange{0}", idx);
if (obj.ContainsKey(key))
{
int otherchange;
if (!int.TryParse(obj[key], out otherchange))
{
otherchange = 0;
}
OtherChanges.Add(otherchange);
ofi.ChangelistId = otherchange;
}
key = String.Format("otherLock{0}", idx);
if (obj.ContainsKey(key))
{
string s = obj[key];
OtherLockUserClients.Add(s);
OtherUsers[s].hasLock = true;
}
}
}
}
if (obj.ContainsKey("ourLock"))
{
OurLock = true;
}
if (obj.ContainsKey("resolved") || obj.ContainsKey("unresolved"))
{
int idx = 0;
StringEnum resolveaction = ResolveAction.Unresolved;
FileSpec resolvebasefile = null;
FileSpec resolvefromfile = null;
int resolvestartfromrev = -1;
int resolveendfromrev = -1;
FileResolveAction resolverecord = null;
ResolveRecords = new List();
while (true)
{
string key = String.Format("resolveAction{0}", idx);
if (obj.ContainsKey(key))
{ resolveaction = obj[key]; }
else break;
key = String.Format("resolveBaseFile{0}", idx);
if (obj.ContainsKey(key))
{
string basefile = obj[key];
int resolvebaserev = -1;
int.TryParse(obj[String.Format("resolveBaseRev{0}",idx)], out resolvebaserev);
resolvebasefile = new FileSpec(new DepotPath(basefile), new Revision(resolvebaserev));
}
else break;
key = String.Format("resolveFromFile{0}", idx);
if (obj.ContainsKey(key))
{
string fromfile = obj[key];
int startfromrev, endfromrev = -1;
int.TryParse(obj[String.Format("resolveStartFromRev{0}",idx)], out startfromrev);
int.TryParse(obj[String.Format("resolveEndFromRev{0}",idx)], out endfromrev);
resolvefromfile = new FileSpec(new DepotPath(fromfile),
new VersionRange(new Revision(startfromrev), new Revision(endfromrev)));
}
else break;
resolverecord = new FileResolveAction
(resolveaction, resolvebasefile, resolvefromfile, resolvestartfromrev, resolveendfromrev);
ResolveRecords.Add(resolverecord);
idx++;
}
}
Attributes = new Dictionary();
foreach (string key in obj.Keys)
{
if (key.StartsWith("attr-"))
{
object val = obj[key];
string atrib = key.Replace("attr-", "");
Attributes.Add(atrib, val);
}
}
AttributesProp = new Dictionary();
foreach (string key in obj.Keys)
{
if (key.StartsWith("attrProp-"))
{
object val = obj[key];
string atrib = key.Replace("attrProp-", "");
AttributesProp.Add(atrib, val);
}
}
AttributeDigests = new Dictionary();
foreach (string key in obj.Keys)
{
if (key.StartsWith("attrDigest-"))
{
object val = obj[key];
string atribDigest = key.Replace("attrDigest-", "");
AttributeDigests.Add(atribDigest, val);
}
}
OpenAttributes = new Dictionary();
foreach (string key in obj.Keys)
{
if (key.StartsWith("openattr-"))
{
object val = obj[key];
string atrib = key.Replace("openattr-", "");
OpenAttributes.Add(atrib, val);
}
}
OpenAttributesProp = new Dictionary();
foreach (string key in obj.Keys)
{
if (key.StartsWith("openattrProp-"))
{
object val = obj[key];
string atrib = key.Replace("openattrProp-", "");
OpenAttributesProp.Add(atrib, val);
}
}
if (obj.ContainsKey("totalFileCount"))
{
long s = -1;
if (long.TryParse(obj["totalFileCount"], out s))
{
TotalFileCount = s;
}
}
if (obj.ContainsKey("dir"))
{
Directory= PathSpec.UnescapePath(obj["dir"]);
}
}
///
/// Get the Filename by checking DepotPath, ClientPath and LocalPath as needed
///
/// File Name
public string GetFileName()
{
if ((DepotPath != null) && (string.IsNullOrEmpty(DepotPath.Path) == false))
{
return DepotPath.GetFileName();
}
else if ((ClientPath != null) && (string.IsNullOrEmpty(ClientPath.Path) == false))
{
return ClientPath.GetFileName();
}
else if ((LocalPath != null) && (string.IsNullOrEmpty(LocalPath.Path) == false))
{
return LocalPath.GetFileName();
}
return null;
}
///
/// Get the Directory this file is in by checking DepotPath, ClientPath and LocalPath as needed
///
/// Directory name
public string GetDirectoryName()
{
if ((DepotPath != null) && (string.IsNullOrEmpty(DepotPath.Path) == false))
{
return DepotPath.GetDirectoryName();
}
else if ((ClientPath != null) && (string.IsNullOrEmpty(ClientPath.Path) == false))
{
return ClientPath.GetDirectoryName();
}
else if ((LocalPath != null) && (string.IsNullOrEmpty(LocalPath.Path) == false))
{
return LocalPath.GetDirectoryName();
}
return null;
}
///
/// Operator to Create a FileSpec from FileMetaData
///
/// File Metadata
/// FileSpec
public static implicit operator FileSpec(FileMetaData s)
{
Revision r = null;
if (s.HaveRev > 0)
{
r = new Revision(s.HaveRev);
}
if ((s.DepotPath != null) && (string.IsNullOrEmpty(s.DepotPath.Path) == false))
{
return new FileSpec(s.DepotPath, r);
}
else if ((s.ClientPath != null) && (string.IsNullOrEmpty(s.ClientPath.Path) == false))
{
return new FileSpec(s.ClientPath, r);
}
else if ((s.LocalPath != null) && (string.IsNullOrEmpty(s.LocalPath.Path) == false))
{
return new FileSpec(s.LocalPath, r);
}
return null;
}
///
/// Cast a FileSpec to FileMetaData
/// This command is "lossy" not all FileMetaData will be valid
///
/// FileSpec
/// FileMetaData for FileSpec
public static implicit operator FileMetaData(FileSpec f)
{
FileMetaData s = new FileMetaData();
if (f.Version != null && f.Version is Revision)
{
s.HaveRev = ((Revision)f.Version).Rev;
}
s.DepotPath = f.DepotPath;
s.ClientPath = f.ClientPath;
s.LocalPath = f.LocalPath;
return s;
}
///
/// Cast a FileSpec to FileMetatData
/// This command is "lossy" not all FileMetaData will be valid
///
/// File
/// FileMetaData for File
public static implicit operator FileMetaData(File f)
{
FileMetaData s = new FileMetaData();
if (f.Version != null && f.Version is Revision)
{
s.HeadRev = ((Revision)f.Version).Rev;
}
s.DepotPath = f.DepotPath;
s.ClientPath = f.ClientPath;
s.LocalPath = f.LocalPath;
s.HaveRev = f.HaveRev.Rev;
s.Change = f.ChangeId;
s.Action = f.Action;
s.Type = f.Type;
return s;
}
///
/// Checks if the currently synced file is not at the latest revision
///
/// true if file is stale
public bool IsStale
{
get { return (HaveRev < HeadRev); }
}
}
///
/// Describes how, or if a file has been resolved.
///
public class FileResolveAction
{
///
/// Default Constructor
///
public FileResolveAction()
{
}
///
/// Parameterized Constructor
///
/// Resolve Action
/// Base File
/// From File
/// Start From Revision
/// End From Revision
public FileResolveAction
(ResolveAction resolveaction, FileSpec resolvebasefile, FileSpec resolvefromfile,
int resolvestartfromrev, int resolveendfromrev)
{
ResolveAction = resolveaction;
ResolveBaseFile = resolvebasefile;
ResolveFromFile = resolvefromfile;
ResolveStartFromRev = resolvestartfromrev;
ResolveEndFromRev = resolveendfromrev;
}
///
/// Action for the resolve
///
public ResolveAction ResolveAction { get; set; }
///
/// Base File
///
public FileSpec ResolveBaseFile { get; set; }
///
/// From File
///
public FileSpec ResolveFromFile { get; set; }
///
/// From File Start Revision
///
public int ResolveStartFromRev { get; set; }
///
/// From File End Revision
///
public int ResolveEndFromRev { get; set; }
}
///
/// The action used in resolving the file.
///
[Flags]
public enum ResolveAction
{
///
/// No Action
///
None = 0x0000,
///
/// UnResolved Action
///
Unresolved = 0x001,
///
/// Copy From Action
///
CopyFrom = 0x002,
///
/// Merge From Action
///
MergeFrom = 0x004,
///
/// Edit From Action
///
EditFrom = 0x008,
///
/// Ignored Action
///
Ignored = 0x010
}
}