Merge lp:~therve/landscape-client/duplicate-sources into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 496
Merged at revision: 509
Proposed branch: lp:~therve/landscape-client/duplicate-sources
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 44 lines (+21/-2)
2 files modified
landscape/package/facade.py (+4/-0)
landscape/package/tests/test_facade.py (+17/-2)
To merge this branch: bzr merge lp:~therve/landscape-client/duplicate-sources
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Geoff Teale (community) Approve
Review via email: mp+97047@code.launchpad.net

Description of the change

It's almost a trivial, but I wanted at least a second look.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

As mentioned on IRC, I believe we should not leave the _landscape-internal-facade.list file around when our job is done. Fixing that should make this one unnecessary.

review: Needs Information
Revision history for this message
Geoff Teale (tealeg) wrote :

Not withstanding Free's comment above, the change itself looks good to me.

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Okay, the thing I don't like is that it introduces logic that we wouldn't strictly need if we fixed the unused _landscape-internal-facade.list (which imo we should do, because admins can be picky about conffiles), so people reading that code in the future might wonder why it's there. Said that, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/package/facade.py'
2--- landscape/package/facade.py 2012-03-06 15:59:11 +0000
3+++ landscape/package/facade.py 2012-03-12 16:03:19 +0000
4@@ -252,6 +252,10 @@
5 sources_line = "deb %s %s" % (url, codename)
6 if components:
7 sources_line += " %s" % " ".join(components)
8+ if os.path.exists(sources_file_path):
9+ current_content = read_file(sources_file_path).split("\n")
10+ if sources_line in current_content:
11+ return
12 sources_line += "\n"
13 append_file(sources_file_path, sources_line)
14
15
16=== modified file 'landscape/package/tests/test_facade.py'
17--- landscape/package/tests/test_facade.py 2012-03-06 15:59:11 +0000
18+++ landscape/package/tests/test_facade.py 2012-03-12 16:03:19 +0000
19@@ -170,8 +170,23 @@
20
21 If no components are given, nothing is written after the dist.
22 """
23- self.facade.add_channel_apt_deb(
24- "http://example.com/ubuntu", "lucid")
25+ self.facade.add_channel_apt_deb("http://example.com/ubuntu", "lucid")
26+ list_filename = (
27+ self.apt_root +
28+ "/etc/apt/sources.list.d/_landscape-internal-facade.list")
29+ sources_contents = read_file(list_filename)
30+ self.assertEqual(
31+ "deb http://example.com/ubuntu lucid\n",
32+ sources_contents)
33+
34+ def test_add_channel_apt_deb_no_duplicate(self):
35+ """
36+ C{add_channel_apt_deb} doesn't put duplicate lines in the landscape
37+ internal apt sources list.
38+ """
39+ self.facade.add_channel_apt_deb("http://example.com/ubuntu", "lucid")
40+ self.facade.add_channel_apt_deb("http://example.com/ubuntu", "lucid")
41+ self.facade.add_channel_apt_deb("http://example.com/ubuntu", "lucid")
42 list_filename = (
43 self.apt_root +
44 "/etc/apt/sources.list.d/_landscape-internal-facade.list")

Subscribers

People subscribed via source and target branches

to all changes: