Merge lp:~songofacandy/bzr-git/fix-unusualmode into lp:bzr-git

Proposed by INADA Naoki on 2010-02-09
Status: Rejected
Rejected by: Jelmer Vernooij on 2010-04-07
Proposed branch: lp:~songofacandy/bzr-git/fix-unusualmode
Merge into: lp:bzr-git
Diff against target: 92 lines (+34/-8)
2 files modified
fetch.py (+15/-8)
tests/test_fetch.py (+19/-0)
To merge this branch: bzr merge lp:~songofacandy/bzr-git/fix-unusualmode
Reviewer Review Type Date Requested Status
Bazaar Developers 2010-02-09 Pending
Review via email: mp+18901@code.launchpad.net
To post a comment you must log in.
Jelmer Vernooij (jelmer) wrote :

The fetch code has been rewritten to avoid inventory walking; this should address this problem as well.

Unmerged revisions

705. By INADA Naoki on 2010-02-09

Support unusual mode in continuous revisions.

704. By INADA Naoki on 2010-02-09

Add test for unusual mode.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'fetch.py'
2--- fetch.py 2010-01-27 10:13:34 +0000
3+++ fetch.py 2010-02-09 03:44:11 +0000
4@@ -216,6 +216,7 @@
5 :return: Inventory delta for this subtree
6 """
7 invdelta = []
8+ sameinv = False
9 file_id = mapping.generate_file_id(path)
10 # We just have to hope this is indeed utf-8:
11 ie = InventoryDirectory(file_id, urlutils.basename(path.decode("utf-8")),
12@@ -229,13 +230,11 @@
13 # See if this has changed at all
14 try:
15 base_sha = shagitmap.lookup_tree(file_id, base_inv.revision_id)
16+ if base_sha == hexsha:
17+ sameinv = True
18 except KeyError:
19 pass
20- else:
21- if base_sha == hexsha:
22- # If nothing has changed since the base revision, we're done
23- return [], {}, []
24- if base_ie.kind != "directory":
25+ if not sameinv and base_ie.kind != "directory":
26 ie.revision = revision_id
27 texts.insert_record_stream([FulltextContentFactory((ie.file_id, ie.revision), (), None, "")])
28 invdelta.append((base_inv.id2path(ie.file_id), path, ie.file_id, ie))
29@@ -252,6 +251,13 @@
30 basename = name.decode("utf-8")
31 existing_children.add(basename)
32 child_path = osutils.pathjoin(path, name)
33+
34+ if mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE,
35+ stat.S_IFLNK, DEFAULT_FILE_MODE|0111):
36+ child_modes[child_path] = mode
37+ if sameinv:
38+ continue
39+
40 if stat.S_ISDIR(mode):
41 subinvdelta, grandchildmodes, subshamap = import_git_tree(
42 texts, mapping, child_path, child_hexsha, base_inv,
43@@ -277,9 +283,10 @@
44 mode_is_executable(mode), stat.S_ISLNK(mode))
45 invdelta.extend(subinvdelta)
46 shamap.extend(subshamap)
47- if mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE,
48- stat.S_IFLNK, DEFAULT_FILE_MODE|0111):
49- child_modes[child_path] = mode
50+
51+ if sameinv:
52+ return [], child_modes, []
53+
54 # Remove any children that have disappeared
55 if base_ie is not None and base_ie.kind == "directory":
56 invdelta.extend(remove_disappeared_children(base_inv.id2path(file_id),
57
58=== modified file 'tests/test_fetch.py'
59--- tests/test_fetch.py 2009-06-20 19:10:49 +0000
60+++ tests/test_fetch.py 2010-02-09 03:44:11 +0000
61@@ -61,6 +61,7 @@
62 )
63 from bzrlib.plugins.git.tests import (
64 GitBranchBuilder,
65+ run_git,
66 )
67
68
69@@ -258,6 +259,24 @@
70 tree = newrepo.revision_tree(revid)
71 self.assertTrue(tree.has_filename(u"foĊ‘bar"))
72
73+ def test_unusualmode(self):
74+ source_url = 'http://github.com/methane/bzr_git_test.git'
75+ r2sha = '858380a95be9ca85ab4076f67f1b881e1317f19a'
76+ r3sha = '014b52ec1d752dbf0c2ebd0f7abfcd24c2539ffd'
77+
78+ run_git('clone', source_url, 'd')
79+ oldrepo = self.open_git_repo('d')
80+ newrepo = self.clone_git_repo('d', 'f')
81+ mapping = oldrepo.get_mapping()
82+ r2id = mapping.revision_id_foreign_to_bzr(r2sha)
83+ rev2 = newrepo.get_revision(r2id)
84+ r3id = mapping.revision_id_foreign_to_bzr(r3sha)
85+ rev3 = newrepo.get_revision(r3id)
86+ unusual_mode = mapping.export_unusual_file_modes(rev2)
87+ self.assertEquals({'foo': 0100700, 'bar': 0120777}, unusual_mode)
88+ unusual_mode = mapping.export_unusual_file_modes(rev3)
89+ self.assertEquals({'foo': 0100700, 'bar': 0120777}, unusual_mode)
90+
91
92 class LocalRepositoryFetchTests(RepositoryFetchTests, TestCaseWithTransport):
93

Subscribers

People subscribed via source and target branches

to all changes: