Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29aa1b8

Browse files
LeResKPByron
authored andcommitted
Add change in type support
1 parentc8fd910 commit29aa1b8

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

‎git/diff.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ class DiffIndex(list):
165165
# A = Added
166166
# D = Deleted
167167
# R = Renamed
168-
# M = modified
169-
change_type= ("A","D","R","M")
168+
# M = Modified
169+
# T = Changed in the type
170+
change_type= ("A","D","R","M","T")
170171

171172
defiter_change_type(self,change_type):
172173
"""
@@ -179,7 +180,9 @@ def iter_change_type(self, change_type):
179180
* 'A' for added paths
180181
* 'D' for deleted paths
181182
* 'R' for renamed paths
182-
* 'M' for paths with modified data"""
183+
* 'M' for paths with modified data
184+
* 'T' for changed in the type paths
185+
"""
183186
ifchange_typenotinself.change_type:
184187
raiseValueError("Invalid change type: %s"%change_type)
185188

@@ -499,6 +502,9 @@ def handle_diff_line(line):
499502
a_path=a_path.encode(defenc)
500503
b_path=b_path.encode(defenc)
501504
rename_from,rename_to=a_path,b_path
505+
elifchange_type=='T':
506+
# Nothing to do
507+
pass
502508
# END add/remove handling
503509

504510
diff=Diff(repo,a_path,b_path,a_blob_id,b_blob_id,old_mode,new_mode,

‎git/test/fixtures/diff_change_in_type

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff --git a/this b/this
2+
deleted file mode 100644
3+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
4+
diff --git a/this b/this
5+
new file mode 120000
6+
index 0000000000000000000000000000000000000000..42061c01a1c70097d1e4579f29a5adf40abdec95
7+
--- /dev/null
8+
+++ b/this
9+
@@ -0,0 +1 @@
10+
+that
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:100644 120000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 42061c01a1c70097d1e4579f29a5adf40abdec95 T this

‎git/test/test_diff.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,33 @@ def test_diff_with_rename(self):
112112
self.assertEqual(diff.score,100)
113113
self.assertEqual(len(list(diffs.iter_change_type('R'))),1)
114114

115+
deftest_diff_with_change_in_type(self):
116+
output=StringProcessAdapter(fixture('diff_change_in_type'))
117+
diffs=Diff._index_from_patch_format(self.rorepo,output)
118+
self._assert_diff_format(diffs)
119+
assert_equal(2,len(diffs))
120+
121+
diff=diffs[0]
122+
self.assertIsNotNone(diff.deleted_file)
123+
assert_equal(diff.a_path,'this')
124+
assert_equal(diff.b_path,'this')
125+
assertisinstance(str(diff),str)
126+
127+
diff=diffs[1]
128+
assert_equal(diff.a_path,None)
129+
assert_equal(diff.b_path,'this')
130+
self.assertIsNotNone(diff.new_file)
131+
assertisinstance(str(diff),str)
132+
133+
output=StringProcessAdapter(fixture('diff_change_in_type_raw'))
134+
diffs=Diff._index_from_raw_format(self.rorepo,output)
135+
self.assertEqual(len(diffs),1)
136+
diff=diffs[0]
137+
self.assertEqual(diff.rename_from,None)
138+
self.assertEqual(diff.rename_to,None)
139+
self.assertEqual(diff.change_type,'T')
140+
self.assertEqual(len(list(diffs.iter_change_type('T'))),1)
141+
115142
deftest_diff_of_modified_files_not_added_to_the_index(self):
116143
output=StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color'))
117144
diffs=Diff._index_from_raw_format(self.rorepo,output)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp