| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 129f90a commit 55dcc17
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,8 @@ CHANGES | |||
| 6 | 6 | * ConcurrentWriteOperation was removed, and replaced by LockedFD | |
| 7 | 7 | * IndexFile.get_entries_key was renamed to entry_key | |
| 8 | 8 | * IndexEntry instances contained in IndexFile.entries now use binary sha's. Use | |
| 9 | - the .hexsha property to obtain the hexadecimal version | ||
| 9 | + the .hexsha property to obtain the hexadecimal version. The .sha property | ||
| 10 | + was removed to make the use of the respective sha more explicit. | ||
| 10 | 11 | * IndexFile.write_tree: removed missing_ok keyword, its always True now | |
| 11 | 12 | Instead of raising GitCommandError it raises UnmergedEntriesError | |
| 12 | 13 | * diff.Diff.null_hex_sha renamed to NULL_HEX_SHA, to be conforming with | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,6 +197,7 @@ class Diff(object): | |||
| 197 | 197 | """, re.VERBOSE | re.MULTILINE) | |
| 198 | 198 | # can be used for comparisons | |
| 199 | 199 | NULL_HEX_SHA = "0"*40 | |
| 200 | + NULL_BIN_SHA = "\0"*20 | ||
| 200 | 201 | ||
| 201 | 202 | __slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "new_file", "deleted_file", | |
| 202 | 203 | "rename_from", "rename_to", "diff") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -530,9 +530,7 @@ def write_tree(self): | |||
| 530 | 530 | :raise ValueError: if there are no entries in the cache | |
| 531 | 531 | :raise UnmergedEntriesError: """ | |
| 532 | 532 | # we obtain no lock as we just flush our contents to disk as tree | |
| 533 | - if not self.entries: | ||
| 534 | - raise ValueError("Cannot write empty index") | ||
| 535 | - | ||
| 533 | + # If we are a new index, the entries access will load our data accordingly | ||
| 536 | 534 | mdb = MemoryDB() | |
| 537 | 535 | entries = self._entries_sorted() | |
| 538 | 536 | binsha, tree_items = write_tree_from_cache(entries, mdb, slice(0, len(entries))) | |
@@ -892,7 +890,6 @@ def move(self, items, skip_errors=False, **kwargs): | |||
| 892 | 890 | ||
| 893 | 891 | return out | |
| 894 | 892 | ||
| 895 | - @default_index | ||
| 896 | 893 | def commit(self, message, parent_commits=None, head=True): | |
| 897 | 894 | """ | |
| 898 | 895 | Commit the current default index file, creating a commit object. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -283,7 +283,16 @@ def aggressive_tree_merge(odb, tree_shas): | |||
| 283 | 283 | elif theirs is None: | |
| 284 | 284 | # added in our branch | |
| 285 | 285 | out_append(_tree_entry_to_baseindexentry(ours, 0)) | |
| 286 | - # END hanle heads | ||
| 286 | + else: | ||
| 287 | + # both have it, except for the base, see whether it changed | ||
| 288 | + if ours[0] != theirs[0] or ours[1] != theirs[1]: | ||
| 289 | + out_append(_tree_entry_to_baseindexentry(ours, 2)) | ||
| 290 | + out_append(_tree_entry_to_baseindexentry(theirs, 3)) | ||
| 291 | + else: | ||
| 292 | + # it was added the same in both | ||
| 293 | + out_append(_tree_entry_to_baseindexentry(ours, 0)) | ||
| 294 | + # END handle two items | ||
| 295 | + # END handle heads | ||
| 287 | 296 | # END handle base exists | |
| 288 | 297 | # END for each entries tuple | |
| 289 | 298 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -114,6 +114,36 @@ def assert_entries(entries, num_entries, has_conflict=False): | |||
| 114 | 114 | trees = [tb, th, tm] | |
| 115 | 115 | assert_entries(aggressive_tree_merge(odb, trees), 2) | |
| 116 | 116 | ||
| 117 | + # same file added in both, differently | ||
| 118 | + fa = mkfile('1', shab) | ||
| 119 | + th = mktree(odb, [fa]) | ||
| 120 | + fb = mkfile('1', shac) | ||
| 121 | + tm = mktree(odb, [fb]) | ||
| 122 | + | ||
| 123 | + # expect conflict | ||
| 124 | + trees = [tb, th, tm] | ||
| 125 | + assert_entries(aggressive_tree_merge(odb, trees), 2, True) | ||
| 126 | + | ||
| 127 | + # same file added, different mode | ||
| 128 | + fa = mkfile('1', shab) | ||
| 129 | + th = mktree(odb, [fa]) | ||
| 130 | + fb = mkcommit('1', shab) | ||
| 131 | + tm = mktree(odb, [fb]) | ||
| 132 | + | ||
| 133 | + # expect conflict | ||
| 134 | + trees = [tb, th, tm] | ||
| 135 | + assert_entries(aggressive_tree_merge(odb, trees), 2, True) | ||
| 136 | + | ||
| 137 | + # same file added in both | ||
| 138 | + fa = mkfile('1', shab) | ||
| 139 | + th = mktree(odb, [fa]) | ||
| 140 | + fb = mkfile('1', shab) | ||
| 141 | + tm = mktree(odb, [fb]) | ||
| 142 | + | ||
| 143 | + # expect conflict | ||
| 144 | + trees = [tb, th, tm] | ||
| 145 | + assert_entries(aggressive_tree_merge(odb, trees), 1) | ||
| 146 | + | ||
| 117 | 147 | # modify same base file, differently | |
| 118 | 148 | fa = mkfile(bfn, shab) | |
| 119 | 149 | th = mktree(odb, [fa]) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments