20 public class File
: IComparable
<File
>
22 protected string m_mode
;
23 public string Mode { get { return m_mode; }
set { m_mode = value; }
}
25 protected string m_hash
;
26 public string ID { get { return m_hash; }
}
28 protected string m_repoPath
;
30 protected string m_relPath
;
31 public string RelativePath { get { return m_relPath; }
}
33 protected string m_pathWithName
;
34 public string PathWithName { get { return m_pathWithName; }
}
36 protected string m_name
;
37 public string Name { get { return m_name; }
}
39 protected int m_stage
;
49 if (value < 0 || value > 3)
57 protected FileState m_state
= FileState
.Unknown
;
58 public FileState State
72 public File(string repoPath
, string relativePath
)
74 m_repoPath
= repoPath
;
75 int idx
= relativePath
.LastIndexOf(Repo
.DirectorySeparator
);
79 m_name
= relativePath
;
83 m_relPath
= relativePath
.Substring(0, idx
);
84 m_name
= relativePath
.Substring(idx
+ 1);
86 m_pathWithName
= relativePath
;
89 public bool SetStage(string val
)
92 if (!int.TryParse(val
, out i
))
96 if (m_stage
< 0 || m_stage
> 3)
104 public int CompareTo(File other
)
106 return m_name
.CompareTo(other
.m_name
);
111 * Copied (C) Has 2 Files, source, dest
114 * Renamed (R) Has 2 Files, source, dest
120 public void SetState(string val
)
126 m_state
= FileState
.Added
;
129 m_state
= FileState
.Copied
;
132 m_state
= FileState
.Deleted
;
135 m_state
= FileState
.Modified
;
138 m_state
= FileState
.Renamed
;
141 m_state
= FileState
.ModeChanged
;
144 m_state
= FileState
.Unmerged
;
147 m_state
= FileState
.Unknown
;
150 m_state
= FileState
.Broken
;
153 m_state
= FileState
.Unknown
;
158 public static string GetStateName(FileState state
)
162 case FileState
.Normal
:
164 case FileState
.Deleted
:
166 case FileState
.Modified
:
168 case FileState
.Unknown
:
170 case FileState
.Unmerged
:
172 case FileState
.Added
:
174 case FileState
.Copied
:
176 case FileState
.ModeChanged
:
177 return "modechanged";
178 case FileState
.Broken
:
180 case FileState
.Renamed
:
186 public bool GetRevision(out string contents
)
188 return GetRevision("HEAD", out contents
);
191 public bool GetRevision(string commitish
, out string contents
)
193 if (String
.IsNullOrEmpty(commitish
))
198 Executioner e
= Executioner
.GetExecutioner(m_repoPath
, true);
201 return 0 == e
.Execute("git-show", commitish
+ ":" + m_pathWithName
, "", out contents
, out error
);