scm: change the order of dvc diff with one argument

Now the dvc diff reference command will return
the difference betweent from specified commit to current HEAD.
This commit is contained in:
Zhanibek
2019-04-05 15:02:28 +06:00
parent 5f68b8e5a0
commit c235850540
2 changed files with 20 additions and 20 deletions
+2 -2
View File
@@ -254,8 +254,8 @@ class Git(Base):
commits.append(str(a_commit))
commits.append(str(b_commit))
else:
a_commit = self.git.head.commit
b_commit = self.git.commit(a_ref)
a_commit = self.git.commit(a_ref)
b_commit = self.git.head.commit
commits.append(str(a_commit))
commits.append(str(b_commit))
trees[DIFF_A_TREE] = self.get_tree(commits[0])
+18 -18
View File
@@ -27,22 +27,22 @@ class TestDiff(TestDvc):
def test(self):
out = self.dvc.scm.get_diff_trees(self.a_ref)
self.assertFalse(out[git.DIFF_EQUAL])
self.assertEqual(str(self.a_ref), out[git.DIFF_B_REF])
self.assertEqual(str(self.git.head.commit), out[git.DIFF_A_REF])
self.assertEqual(str(self.a_ref), out[git.DIFF_A_REF])
self.assertEqual(str(self.git.head.commit), out[git.DIFF_B_REF])
class TestDiffRepo(TestDiff):
def test(self):
result = self.dvc.diff(self.new_file, a_ref=self.a_ref)
test_dct = {
git.DIFF_B_REF: str(self.a_ref),
git.DIFF_A_REF: str(self.git.head.commit),
git.DIFF_A_REF: str(self.a_ref),
git.DIFF_B_REF: str(self.git.head.commit),
git.DIFF_LIST: [
{
git.DIFF_TARGET: self.new_file,
git.DIFF_OLD_FILE: self.new_file,
git.DIFF_OLD_CHECKSUM: "c81fec3d710806070bcd67f182d1279c",
git.DIFF_SIZE: -13,
git.DIFF_NEW_FILE: self.new_file,
git.DIFF_NEW_CHECKSUM: "c81fec3d710806070bcd67f182d1279c",
git.DIFF_SIZE: 13,
}
],
}
@@ -76,34 +76,34 @@ class TestDiffDir(TestDvc):
def test(self):
out = self.dvc.scm.get_diff_trees(self.a_ref)
self.assertFalse(out[git.DIFF_EQUAL])
self.assertEqual(str(self.a_ref), out[git.DIFF_B_REF])
self.assertEqual(str(self.git.head.commit), out[git.DIFF_A_REF])
self.assertEqual(str(self.a_ref), out[git.DIFF_A_REF])
self.assertEqual(str(self.git.head.commit), out[git.DIFF_B_REF])
class TestDiffDirRepo(TestDiffDir):
def test(self):
result = self.dvc.diff(self.DATA_DIR, a_ref=self.a_ref)
test_dct = {
git.DIFF_B_REF: str(self.a_ref),
git.DIFF_A_REF: str(self.git.head.commit),
git.DIFF_A_REF: str(self.a_ref),
git.DIFF_B_REF: str(self.git.head.commit),
git.DIFF_LIST: [
{
git.DIFF_CHANGE: 0,
git.DIFF_DEL: 1,
git.DIFF_DEL: 0,
git.DIFF_IDENT: 2,
git.DIFF_MOVE: 0,
git.DIFF_NEW: 0,
git.DIFF_NEW: 1,
git.DIFF_IS_DIR: True,
git.DIFF_TARGET: self.DATA_DIR,
git.DIFF_OLD_FILE: self.DATA_DIR,
git.DIFF_OLD_CHECKSUM: (
"d5782f3072167ad3a53ee80b92b30718.dir"
),
git.DIFF_NEW_FILE: self.DATA_DIR,
git.DIFF_NEW_CHECKSUM: (
"d5782f3072167ad3a53ee80b92b30718.dir"
),
git.DIFF_OLD_FILE: self.DATA_DIR,
git.DIFF_OLD_CHECKSUM: (
"bff5a787d16460f32e9f2e62b183b1cc.dir"
),
git.DIFF_SIZE: -30,
git.DIFF_SIZE: 30,
}
],
}