Merge lp:~jelmer/brz/supports-storing-branch-nick into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6823
Proposed branch: lp:~jelmer/brz/supports-storing-branch-nick
Merge into: lp:brz
Diff against target: 91 lines (+26/-11)
5 files modified
breezy/repository.py (+3/-0)
breezy/tests/per_branch/test_branch.py (+5/-3)
breezy/tests/per_branch/test_commit.py (+5/-2)
breezy/tests/per_repository/test_repository.py (+4/-0)
breezy/tests/per_repository/test_revision.py (+9/-6)
To merge this branch: bzr merge lp:~jelmer/brz/supports-storing-branch-nick
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+334009@code.launchpad.net

Commit message

Add and use a ``RepositoryFormat.supports_storing_branch_nick`` property.

Description of the change

Add a ``RepositoryFormat.supports_storing_branch_nick`` property, that can be used to determine whether a revision records the nick of the branch it is on. This would be set to True for bzr, svn and mercurial branches, but e.g. to False for git.

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

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/repository.py'
2--- breezy/repository.py 2017-11-14 01:20:51 +0000
3+++ breezy/repository.py 2017-11-21 00:36:15 +0000
4@@ -1295,6 +1295,9 @@
5 # Is it possible for revisions to be present without being referenced
6 # somewhere ?
7 supports_unreferenced_revisions = None
8+ # Does this format store the current Branch.nick in a revision when
9+ # creating commits?
10+ supports_storing_branch_nick = True
11
12 def __repr__(self):
13 return "%s()" % self.__class__.__name__
14
15=== modified file 'breezy/tests/per_branch/test_branch.py'
16--- breezy/tests/per_branch/test_branch.py 2017-11-12 17:53:35 +0000
17+++ breezy/tests/per_branch/test_branch.py 2017-11-21 00:36:15 +0000
18@@ -303,9 +303,11 @@
19 branch.nick = "My happy branch"
20 wt.commit('My commit respect da nick.')
21 committed = branch.repository.get_revision(branch.last_revision())
22- # TODO(jelmer): Only set branch nick on bzr branches
23- self.assertEqual(committed.properties["branch-nick"],
24- "My happy branch")
25+ if branch.repository._format.supports_storing_branch_nick:
26+ self.assertEqual(committed.properties["branch-nick"],
27+ "My happy branch")
28+ else:
29+ self.assertNotIn("branch-nick", committed.properties)
30
31 def test_create_colocated(self):
32 try:
33
34=== modified file 'breezy/tests/per_branch/test_commit.py'
35--- breezy/tests/per_branch/test_commit.py 2017-11-17 03:06:50 +0000
36+++ breezy/tests/per_branch/test_commit.py 2017-11-21 00:36:15 +0000
37@@ -36,8 +36,11 @@
38 branch.nick = "My happy branch"
39 wt.commit('My commit respect da nick.')
40 committed = branch.repository.get_revision(branch.last_revision())
41- self.assertEqual(committed.properties["branch-nick"],
42- "My happy branch")
43+ if branch.repository._format.supports_storing_branch_nick:
44+ self.assertEqual(committed.properties["branch-nick"],
45+ "My happy branch")
46+ else:
47+ self.assertNotIn("branch-nick", committed.properties)
48
49
50 class TestCommitHook(per_branch.TestCaseWithBranch):
51
52=== modified file 'breezy/tests/per_repository/test_repository.py'
53--- breezy/tests/per_repository/test_repository.py 2017-11-19 19:01:00 +0000
54+++ breezy/tests/per_repository/test_repository.py 2017-11-21 00:36:15 +0000
55@@ -118,6 +118,10 @@
56 self.assertFormatAttribute('supports_setting_revision_ids',
57 (True, False))
58
59+ def test_attribute_format_supports_storing_branch_nick(self):
60+ self.assertFormatAttribute('supports_storing_branch_nick',
61+ (True, False))
62+
63 def test_format_is_deprecated(self):
64 repo = self.make_repository('repo')
65 self.assertSubset([repo._format.is_deprecated()], (True, False))
66
67=== modified file 'breezy/tests/per_repository/test_revision.py'
68--- breezy/tests/per_repository/test_revision.py 2017-11-19 18:57:05 +0000
69+++ breezy/tests/per_repository/test_revision.py 2017-11-21 00:36:15 +0000
70@@ -37,12 +37,15 @@
71 rev = b.repository.get_revision(rev1)
72 self.assertTrue('flavor' in rev.properties)
73 self.assertEqual(rev.properties['flavor'], 'choc-mint')
74- self.assertEqual([('branch-nick', 'Nicholas'),
75- ('condiment', 'orange\n mint\n\tcandy'),
76- ('empty', ''),
77- ('flavor', 'choc-mint'),
78- ('non_ascii', u'\xb5'),
79- ], sorted(rev.properties.items()))
80+ expected_revprops = {
81+ 'condiment': 'orange\n mint\n\tcandy',
82+ 'empty': '',
83+ 'flavor': 'choc-mint',
84+ 'non_ascii': u'\xb5',
85+ }
86+ if b.repository._format.supports_storing_branch_nick:
87+ expected_revprops['branch-nick'] = 'Nicholas'
88+ self.assertEqual(expected_revprops, rev.properties)
89
90 def test_invalid_revprops(self):
91 """Invalid revision properties"""

Subscribers

People subscribed via source and target branches