Merge lp:~nuclearbob/utah/bzr-symlink into lp:utah

Proposed by Max Brustkern
Status: Merged
Approved by: Joe Talbott
Approved revision: 791
Merged at revision: 791
Proposed branch: lp:~nuclearbob/utah/bzr-symlink
Merge into: lp:utah
Diff against target: 23 lines (+12/-1)
1 file modified
utah/url.py (+12/-1)
To merge this branch: bzr merge lp:~nuclearbob/utah/bzr-symlink
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Max Brustkern (community) Needs Resubmitting
Joe Talbott (community) Approve
Review via email: mp+139557@code.launchpad.net

Description of the change

To post a comment you must log in.
lp:~nuclearbob/utah/bzr-symlink updated
791. By Max Brustkern

Throw an exception for absolute paths

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Now throws an exception when used on a symlink to an absolute path (i.e. lp:~nuclearbob/+junk/test/blarg)

Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks good to me.

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

Looks nice. I've tested it and works fine as well.

Please fix the pep8 error in the exception message:
url.py:225:21: E128 continuation line under-indented for visual indent

Aside from that, may I suggest to create a link to the file returned by the
recursive call to `url_argument`?

=== modified file 'utah/url.py'
--- utah/url.py 2012-12-12 20:21:28 +0000
+++ utah/url.py 2012-12-13 08:32:33 +0000
@@ -225,7 +225,9 @@
                     'path in a bazaar branch: {}'.format(url))
             dirname = os.path.dirname(url)
             link_url = os.path.join(dirname, link_path)
- return url_argument(link_url)
+ target_path = url_argument(link_url)
+ os.remove(full_url)
+ os.link(target_path, full_url)
         elif not os.path.isfile(full_url):
             raise ArgumentTypeError("URL doesn't point to a file "
                                     'in a bazaar branch: {}'

Isn't really important, but this will preserve the original filename, so when
we look at the logs, we don't have the feeling that the preseed doesn't look
like the good one (I've used `os.link`, but `os.symlink` should work as well).

review: Needs Fixing
lp:~nuclearbob/utah/bzr-symlink updated
792. By Max Brustkern

Addressed Javier's suggestions

Revision history for this message
Max Brustkern (nuclearbob) wrote :

What version of pep8 are you using? That didn't come up in mine, so I may need to update. I think I have the issue addressed now, and I do like the idea of linking to the target path.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Regarding pep8, I've got version 1.3.3 that is higher than the one currently
available in the archive.

To get the latest version use:
sudo pip install --upgrade pep8

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Since I made the changes Javier mentioned, I'm going to go ahead and merge this so we can get it into the lab.

Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/url.py'
2--- utah/url.py 2012-12-03 14:02:18 +0000
3+++ utah/url.py 2012-12-13 13:50:24 +0000
4@@ -218,7 +218,18 @@
5 raise ArgumentTypeError('Bazaar export error: {}'
6 .format(exception))
7 full_url = os.path.join(tmp_dir, os.path.basename(url))
8- if not os.path.isfile(full_url):
9+ if os.path.islink(full_url):
10+ link_path = os.readlink(full_url)
11+ if link_path.startswith('/'):
12+ raise ArgumentTypeError('URL points to a link to an absolute '
13+ 'path in a bazaar branch: {}'
14+ .format(url))
15+ dirname = os.path.dirname(url)
16+ link_url = os.path.join(dirname, link_path)
17+ target_path = url_argument(link_url)
18+ os.remove(full_url)
19+ os.link(target_path, full_url)
20+ elif not os.path.isfile(full_url):
21 raise ArgumentTypeError("URL doesn't point to a file "
22 'in a bazaar branch: {}'
23 .format(url))

Subscribers

People subscribed via source and target branches