public void Pull_FromOtherWithRevisionSpecification_OnlyPullsInRelevantChanges() { WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true); WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents", "2nd commit", false); WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents again", "3rd commit", false); Repo2.Pull( Repo1.Path, new PullCommand { Revisions = { RevSpec.Single(1), }, }); Changeset[] pulledChangesets = Repo2.Log().OrderBy(c => c.RevisionNumber).ToArray(); Changeset[] originalChangesets = Repo1.Log( new LogCommand { Revisions = { RevSpec.Range(0, 1), }, }).OrderBy(c => c.RevisionNumber).ToArray(); CollectionAssert.AreEqual(pulledChangesets, originalChangesets); }
public void ByHash_UppercaseHash_ReturnsLowercaseHash() { string output = RevSpec.Single("123ABC").ToString(); const string expected = "123abc"; Assert.That(output, Is.EqualTo(expected)); }
public void ByHash_CorrectHashSurroundedByWhitespace_ReturnsTrimmedHash() { string output = RevSpec.Single(" 123abc ").ToString(); const string expected = "123abc"; Assert.That(output, Is.EqualTo(expected)); }
public void Log_WithMultipleRevisionFilters_OnlyIncludeMatchingChangesets() { Repo.Init(); foreach (string filename in new[] { "test1.txt", "test2.txt", "test3.txt" }) { File.WriteAllText(Path.Combine(Repo.Path, filename), "dummy content"); Repo.Commit( filename + " added", new CommitCommand { AddRemove = true, }); } Changeset[] log = Repo.Log( new LogCommand { Revisions = { RevSpec.Range(RevSpec.Single(0), RevSpec.Single(0)), RevSpec.Range(RevSpec.Single(2), RevSpec.Single(2)), }, }).ToArray(); Assert.That(log.Length, Is.EqualTo(2)); }
public void Except_ProducesCorrectRevisionSpecification() { RevSpec include = RevSpec.Range(2, 7); RevSpec exclude = RevSpec.Single(5); RevSpec result = include.Except(exclude); Assert.That(result.ToString(), Is.EqualTo("2:7 - 5")); }
/// <summary> /// Returns a <see cref="HgLogQuery"/> that selects a commit based on its unique hash number. /// </summary> /// <param name="hash">The commit unique hash.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="hash"/> is <c>null</c> or empty.</para> /// </exception> public HgLogQuery Single(string hash) { if (string.IsNullOrEmpty(hash)) { throw new ArgumentNullException(nameof(hash)); } return(RevSpec.Single(hash)); }
public void UpdateWithoutRevisionParameter_ToNonExistantRevision_ThrowsMercurialExecutionException() { Repo.Init(); Assert.Throws <MercurialExecutionException>( () => Repo.Update( new UpdateCommand { Revision = RevSpec.Single(2) })); }
private static void CheckRevSpecMethod(PropertyInfo property, Type type, MethodInfo method) { var input = new[] { RevSpec.Single(42), RevSpec.Range(RevSpec.Single(17), RevSpec.Single(42)) }; foreach (RevSpec value in input) { object instance = CreateInstance(type); method.Invoke( instance, new object[] { value }); object output = property.GetValue(instance, null); Assert.That(output, Is.EqualTo(value)); } }
private static void CheckRevSpecCollectionMethod(PropertyInfo property, Type type, MethodInfo method) { var input = new[] { RevSpec.Single(42), RevSpec.Range(RevSpec.Single(17), RevSpec.Single(42)) }; foreach (RevSpec value in input) { object instance = CreateInstance(type); method.Invoke( instance, new object[] { value }); var output = (Collection <RevSpec>)property.GetValue(instance, null); CollectionAssert.AreEqual( output, new[] { value }); } }
public void ByRevision_WithNegativeRevisionNumber_ThrowsArgumentOutOfRangeException() { Assert.Throws <ArgumentOutOfRangeException>(() => RevSpec.Single(-1)); }
public void ByHash_WithWhitespaceHash_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => RevSpec.Single("\t \t \r \n")); }
public void ByHash_WithNullHash_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => RevSpec.Single(null)); }
public void ByHash_WithInvalidHexDigits_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => RevSpec.Single("x")); }
public void ByRevision_WithZeroOrHigherRevisionNumbers_ReturnsRevisionNumberAsString(int revision, string expected) { string output = RevSpec.Single(revision).ToString(); Assert.That(output, Is.EqualTo(expected)); }
public void ByHash_WithEmptyHash_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => RevSpec.Single(string.Empty)); }
/// <summary> /// Create a <see cref="HgLogQuery" /> that includes a range /// of commits between <paramref name="fromHash"/> and <paramref name="toHash"/>. /// </summary> /// <param name="fromHash">Hash of first commit to include.</param> /// <param name="toHash">Hash of last commit to include.</param> public HgLogQuery Range(string fromHash, string toHash) { return(RevSpec.Range( RevSpec.Single(fromHash), RevSpec.Single(toHash))); }