Merge lp:~wgrant/bzr-git/tree-by-id into lp:bzr-git

Proposed by William Grant
Status: Merged
Approved by: Richard Wilbur
Approved revision: 1637
Merged at revision: 1632
Proposed branch: lp:~wgrant/bzr-git/tree-by-id
Merge into: lp:bzr-git
Diff against target: 113 lines (+24/-25)
3 files modified
NEWS (+3/-0)
object_store.py (+20/-23)
tests/test_push.py (+1/-2)
To merge this branch: bzr merge lp:~wgrant/bzr-git/tree-by-id
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+258716@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Thanks for fixing the known failure!
+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2015-05-08 02:22:21 +0000
3+++ NEWS 2015-05-10 01:02:14 +0000
4@@ -7,6 +7,9 @@
5
6 * Fix compatibility with and depend on dulwich 0.9.6. (William Grant)
7
8+ * Correctly handle all moves when converting bzr trees to git.
9+ (William Grant, #818318)
10+
11 0.6.12 2013-09-22
12
13 FEATURES
14
15=== modified file 'object_store.py'
16--- object_store.py 2013-08-21 04:02:54 +0000
17+++ object_store.py 2015-05-10 01:02:14 +0000
18@@ -173,7 +173,7 @@
19 in empty directories. None to skip empty directories
20 :return: Yields (path, object, ie) entries
21 """
22- new_trees = {}
23+ dirty_dirs = set()
24 new_blobs = []
25 shamap = {}
26 try:
27@@ -219,7 +219,6 @@
28 shamap[file_id] = blob.id
29 if not file_id in shamap:
30 new_blobs.append((path[1], file_id))
31- new_trees[posixpath.dirname(path[1])] = parent[1]
32 elif kind[1] == "symlink":
33 if changed_content:
34 target = tree.get_symlink_target(file_id)
35@@ -229,14 +228,11 @@
36 find_unchanged_parent_ie(file_id, kind[1], target, other_parent_trees)
37 except KeyError:
38 yield path[1], blob, (file_id, tree.get_file_revision(file_id, path[1]))
39- new_trees[posixpath.dirname(path[1])] = parent[1]
40 elif kind[1] not in (None, "directory"):
41 raise AssertionError(kind[1])
42- if (path[0] not in (None, "") and
43- tree.has_id(parent[0]) and
44- tree.kind(parent[0]) == "directory"):
45- # Removal
46- new_trees[posixpath.dirname(path[0])] = parent[0]
47+ for p in parent:
48+ if p and tree.has_id(p) and tree.kind(p) == "directory":
49+ dirty_dirs.add(p)
50
51 # Fetch contents of the blobs that were changed
52 for (path, file_id), chunks in tree.iter_files_bytes(
53@@ -250,18 +246,24 @@
54 parent_path = posixpath.dirname(path)
55 file_id = tree.path2id(parent_path)
56 assert file_id is not None, "Unable to find file id for %r" % parent_path
57- new_trees[parent_path] = file_id
58+ dirty_dirs.add(file_id)
59+
60+ try:
61+ inv = tree.root_inventory
62+ except AttributeError:
63+ inv = tree.inventory
64
65 trees = {}
66- while new_trees:
67- items = new_trees.items()
68- new_trees = {}
69- for path, file_id in items:
70- if path != "":
71- parent_path = urlutils.dirname(path)
72- parent_id = tree.path2id(parent_path)
73- new_trees[parent_path] = parent_id
74- trees[path] = file_id
75+ while dirty_dirs:
76+ new_dirs = set()
77+ for file_id in dirty_dirs:
78+ if file_id is None or not inv.has_id(file_id):
79+ continue
80+ trees[inv.id2path(file_id)] = file_id
81+ ie = inv[file_id]
82+ if ie.parent_id is not None:
83+ new_dirs.add(ie.parent_id)
84+ dirty_dirs = new_dirs
85
86 def ie_to_hexsha(ie):
87 try:
88@@ -287,11 +289,6 @@
89 else:
90 raise AssertionError
91
92- try:
93- inv = tree.root_inventory
94- except AttributeError:
95- inv = tree.inventory
96-
97 for path in sorted(trees.keys(), reverse=True):
98 file_id = trees[path]
99 assert tree.kind(file_id) == 'directory'
100
101=== modified file 'tests/test_push.py'
102--- tests/test_push.py 2012-01-20 13:33:01 +0000
103+++ tests/test_push.py 2015-05-10 01:02:14 +0000
104@@ -109,8 +109,7 @@
105 commit = store[gitid]
106 tree = store[commit.tree]
107 tree.check()
108- self.expectFailure("fails with KeyError (bug 818318)",
109- self.assertTrue, tree["baz"][1] in store)
110+ self.assertTrue(tree["baz"][1] in store)
111 baz = store[tree["baz"][1]]
112 baz.check()
113 ircdotnet = store[baz["IrcDotNet"][1]]

Subscribers

People subscribed via source and target branches

to all changes: