Merge lp:~jelmer/brz/fix1799482 into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7144
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix1799482
Merge into: lp:brz
Diff against target: 150 lines (+38/-15)
4 files modified
breezy/git/workingtree.py (+3/-1)
breezy/mutabletree.py (+4/-4)
breezy/tests/per_workingtree/test_smart_add.py (+28/-10)
doc/en/release-notes/brz-3.0.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/fix1799482
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+357734@code.launchpad.net

Commit message

Report correct paths when running "brz add" in git repositories.

Description of the change

Report correct paths when running "brz add" in git repositories.

(based on a fix by Brian de Alwis)

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/workingtree.py'
2--- breezy/git/workingtree.py 2018-09-30 00:33:53 +0000
3+++ breezy/git/workingtree.py 2018-10-24 02:25:23 +0000
4@@ -432,6 +432,8 @@
5 ignored = {}
6 user_dirs = []
7 def call_action(filepath, kind):
8+ if filepath == '':
9+ return
10 if action is not None:
11 parent_path = posixpath.dirname(filepath)
12 parent_id = self.path2id(parent_path)
13@@ -501,7 +503,7 @@
14 continue
15 if subp in conflicts_related:
16 continue
17- call_action(filepath, kind)
18+ call_action(subp, kind)
19 if save:
20 self._index_add_entry(subp, kind)
21 added.append(subp)
22
23=== modified file 'breezy/mutabletree.py'
24--- breezy/mutabletree.py 2018-02-18 19:18:40 +0000
25+++ breezy/mutabletree.py 2018-10-24 02:25:23 +0000
26@@ -89,7 +89,7 @@
27 Note that the command line normally calls smart_add instead,
28 which can automatically recurse.
29
30- This adds the files to the inventory, so that they will be
31+ This adds the files to the tree, so that they will be
32 recorded by the next commit.
33
34 :param files: List of paths to add, relative to the base of the tree.
35@@ -343,12 +343,12 @@
36 interpreted relative to the process cwd, not relative to the
37 tree.* (Add and most other tree methods use tree-relative
38 paths.)
39- :param action: A reporter to be called with the inventory, parent_ie,
40+ :param action: A reporter to be called with the working tree, parent_ie,
41 path and kind of the path being added. It may return a file_id if
42 a specific one should be used.
43- :param save: Save the inventory after completing the adds. If False
44+ :param save: Save the changes after completing the adds. If False
45 this provides dry-run functionality by doing the add and not saving
46- the inventory.
47+ the changes.
48 :return: A tuple - files_added, ignored_files. files_added is the count
49 of added files, and ignored_files is a dict mapping files that were
50 ignored to the rule that caused them to be ignored.
51
52=== modified file 'breezy/tests/per_workingtree/test_smart_add.py'
53--- breezy/tests/per_workingtree/test_smart_add.py 2018-07-23 22:49:40 +0000
54+++ breezy/tests/per_workingtree/test_smart_add.py 2018-10-24 02:25:23 +0000
55@@ -20,6 +20,7 @@
56 import sys
57
58 from ... import (
59+ add as _mod_add,
60 errors,
61 ignores,
62 osutils,
63@@ -37,22 +38,30 @@
64 )
65
66
67+class RecordingAddAction(_mod_add.AddAction):
68+
69+ def __init__(self):
70+ self.adds = []
71+
72+ def __call__(self, wt, parent_ie, path, kind):
73+ self.adds.append((wt, path, kind))
74+
75+
76 class TestSmartAddTree(per_workingtree.TestCaseWithWorkingTree):
77
78 def test_single_file(self):
79 tree = self.make_branch_and_tree('tree')
80 self.build_tree(['tree/a'])
81- tree.smart_add(['tree'])
82+ action = RecordingAddAction()
83+ tree.smart_add(['tree'], action=action)
84
85- tree.lock_read()
86- try:
87+ with tree.lock_read():
88 files = [(path, status, kind)
89 for path, status, kind, file_id, parent_id
90 in tree.list_files(include_root=True)]
91- finally:
92- tree.unlock()
93 self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')],
94 files)
95+ self.assertEqual([(tree, 'a', 'file')], action.adds)
96
97 def assertFilenameSkipped(self, filename):
98 tree = self.make_branch_and_tree('tree')
99@@ -74,14 +83,11 @@
100 def test_save_false(self):
101 """Dry-run add doesn't permanently affect the tree."""
102 wt = self.make_branch_and_tree('.')
103- wt.lock_write()
104- try:
105+ with wt.lock_write():
106 self.build_tree(['file'])
107 wt.smart_add(['file'], save=False)
108 # the file should not be added - no id.
109 self.assertEqual(wt.path2id('file'), None)
110- finally:
111- wt.unlock()
112 # and the disk state should be the same - reopen to check.
113 wt = wt.controldir.open_workingtree()
114 self.assertFalse(wt.is_versioned('file'))
115@@ -91,9 +97,21 @@
116 paths = ("original/", "original/file1", "original/file2")
117 self.build_tree(paths)
118 wt = self.make_branch_and_tree('.')
119- wt.smart_add((u".",))
120+ action = RecordingAddAction()
121+ wt.smart_add((u".",), action=action)
122 for path in paths:
123 self.assertTrue(wt.is_versioned(path))
124+ if wt.has_versioned_directories():
125+ self.assertEqual(
126+ {(wt, 'original', 'directory'),
127+ (wt, 'original/file1', 'file'),
128+ (wt, 'original/file2', 'file')},
129+ set(action.adds))
130+ else:
131+ self.assertEqual(
132+ {(wt, 'original/file1', 'file'),
133+ (wt, 'original/file2', 'file')},
134+ set(action.adds))
135
136 def test_skip_nested_trees(self):
137 """Test smart-adding a nested tree ignors it and warns."""
138
139=== modified file 'doc/en/release-notes/brz-3.0.txt'
140--- doc/en/release-notes/brz-3.0.txt 2018-09-18 02:08:46 +0000
141+++ doc/en/release-notes/brz-3.0.txt 2018-10-24 02:25:23 +0000
142@@ -171,6 +171,9 @@
143
144 * Support '0' markers in fastimport plugin. (Jelmer Vernooń≥, #1744615)
145
146+* Report correct path in output of ``brz add``.
147+ (Brian de Alwis, Jelmer Vernooń≥, #1799482)
148+
149 Documentation
150 *************
151

Subscribers

People subscribed via source and target branches