Merge lp:~jelmer/brz/transform-canonical-path into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/brz/transform-canonical-path
Merge into: lp:brz/3.1
Diff against target: 85 lines (+16/-18)
5 files modified
breezy/bzr/transform.py (+1/-16)
breezy/bzr/workingtree.py (+1/-1)
breezy/tests/per_workingtree/test_canonical_path.py (+1/-1)
breezy/tests/test_tree.py (+11/-0)
breezy/tree.py (+2/-0)
To merge this branch: bzr merge lp:~jelmer/brz/transform-canonical-path
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+386858@code.launchpad.net

This proposal has been superseded by a proposal from 2022-07-07.

Commit message

Use Tree.get_canonical_path in TreeTransform.

Description of the change

Use Tree.get_canonical_path in TreeTransform.

To post a comment you must log in.
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/transform.py'
2--- breezy/bzr/transform.py 2020-09-02 17:00:38 +0000
3+++ breezy/bzr/transform.py 2021-02-19 22:55:45 +0000
4@@ -1448,22 +1448,7 @@
5
6 def canonical_path(self, path):
7 """Get the canonical tree-relative path"""
8- # don't follow final symlinks
9- abs = self._tree.abspath(path)
10- if abs in self._relpaths:
11- return self._relpaths[abs]
12- dirname, basename = os.path.split(abs)
13- if dirname not in self._realpaths:
14- self._realpaths[dirname] = os.path.realpath(dirname)
15- dirname = self._realpaths[dirname]
16- abs = osutils.pathjoin(dirname, basename)
17- if dirname in self._relpaths:
18- relpath = osutils.pathjoin(self._relpaths[dirname], basename)
19- relpath = relpath.rstrip('/\\')
20- else:
21- relpath = self._tree.relpath(abs)
22- self._relpaths[abs] = relpath
23- return relpath
24+ return self._tree.get_canonical_path(path)
25
26 def tree_kind(self, trans_id):
27 """Determine the file kind in the working tree.
28
29=== modified file 'breezy/bzr/workingtree.py'
30--- breezy/bzr/workingtree.py 2020-09-02 15:11:17 +0000
31+++ breezy/bzr/workingtree.py 2021-02-19 22:55:45 +0000
32@@ -1802,7 +1802,7 @@
33 normalize = None
34 for path in paths:
35 if normalize is None or self.is_versioned(path):
36- yield path
37+ yield path.strip('/')
38 else:
39 yield get_canonical_path(self, path, normalize)
40
41
42=== modified file 'breezy/tests/per_workingtree/test_canonical_path.py'
43--- breezy/tests/per_workingtree/test_canonical_path.py 2018-11-11 04:08:32 +0000
44+++ breezy/tests/per_workingtree/test_canonical_path.py 2021-02-19 22:55:45 +0000
45@@ -70,7 +70,7 @@
46 def test_canonical_path_root(self):
47 work_tree = self._make_canonical_test_tree()
48 self.assertEqual('', work_tree.get_canonical_path(''))
49- self.assertEqual('/', work_tree.get_canonical_path('/'))
50+ self.assertEqual('', work_tree.get_canonical_path('/'))
51
52 def test_canonical_path_invalid_all(self):
53 work_tree = self._make_canonical_test_tree()
54
55=== modified file 'breezy/tests/test_tree.py'
56--- breezy/tests/test_tree.py 2020-07-05 00:45:13 +0000
57+++ breezy/tests/test_tree.py 2021-02-19 22:55:45 +0000
58@@ -239,3 +239,14 @@
59 self.assertEqual(
60 'a/C',
61 get_canonical_path(tree, 'A/C', lambda x: x.lower()))
62+
63+ def test_trailing_slash(self):
64+ tree = self.make_branch_and_tree('tree')
65+ self.build_tree(['tree/a/', 'tree/a/b'])
66+ tree.add(['a', 'a/b'])
67+ self.assertEqual(
68+ 'a',
69+ get_canonical_path(tree, 'a', lambda x: x))
70+ self.assertEqual(
71+ 'a',
72+ get_canonical_path(tree, 'a/', lambda x: x))
73
74=== modified file 'breezy/tree.py'
75--- breezy/tree.py 2020-08-22 15:44:15 +0000
76+++ breezy/tree.py 2021-02-19 22:55:45 +0000
77@@ -959,6 +959,8 @@
78 cur_path = ''
79 bit_iter = iter(path.split("/"))
80 for elt in bit_iter:
81+ if not elt:
82+ continue
83 lelt = normalize(elt)
84 new_path = None
85 try:

Subscribers

People subscribed via source and target branches