Merge lp:~parthm/bzr/242522-symlink-repo-to-usb-stick into lp:bzr

Proposed by Parth Malwankar
Status: Work in progress
Proposed branch: lp:~parthm/bzr/242522-symlink-repo-to-usb-stick
Merge into: lp:bzr
Diff against target: 65 lines (+33/-1)
3 files modified
bzrlib/tests/test_transform.py (+21/-0)
bzrlib/transform.py (+7/-1)
doc/en/release-notes/bzr-2.6.txt (+5/-0)
To merge this branch: bzr merge lp:~parthm/bzr/242522-symlink-repo-to-usb-stick
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+94679@code.launchpad.net

Description of the change

This patch updates updates transform.create_symlink to issue a warning in case the target filesystem (e.g. fat mounted on Linux) does not support symlinks. It catches OSError EPERM and issues a warning to the user. The branch is created / updated but the symlink is not created.

This patch along with https://code.launchpad.net/~parthm/bzr/81689-win-symlink-warning/+merge/93784 allow bzr to work with repos containing symlinks on file systems that don't allow symlinks by ignoring symlinks (i.e. not creating them at all).

To post a comment you must log in.
Revision history for this message
Parth Malwankar (parthm) wrote :

Marking as in-progress at the moment. Will resubmit along with 81689 patch to ensure that both patches have consistent behavior and messages.

Unmerged revisions

6478. By Parth Malwankar

updated release notes

6477. By Parth Malwankar

added test

6476. By Parth Malwankar

symlink skipped if target filesystem does not support symlinks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_transform.py'
2--- bzrlib/tests/test_transform.py 2012-02-06 23:38:33 +0000
3+++ bzrlib/tests/test_transform.py 2012-02-26 05:32:20 +0000
4@@ -1556,6 +1556,27 @@
5 self.addCleanup(wt.unlock)
6 self.assertEqual(wt.kind(wt.path2id("foo")), "symlink")
7
8+ def test_no_target_symlink(self):
9+ def symlink_eperm(source, link_name):
10+ e = OSError()
11+ e.errno = errno.EPERM
12+ raise e
13+ self.requireFeature(SymlinkFeature)
14+ wt = self.make_branch_and_tree('.')
15+ self.build_tree(['foo'])
16+ wt.add(['foo'])
17+ wt.commit("one")
18+ tt = TreeTransform(wt)
19+ self.addCleanup(tt.finalize)
20+ foo_trans_id = tt.trans_id_tree_path("foo")
21+ tt.delete_contents(foo_trans_id)
22+ os_symlink = getattr(os, 'symlink', None)
23+ os.symlink = symlink_eperm
24+ try:
25+ tt.create_symlink("bar", foo_trans_id)
26+ finally:
27+ os.symlink = os_symlink
28+
29 def test_dir_to_file(self):
30 wt = self.make_branch_and_tree('.')
31 self.build_tree(['foo/', 'foo/bar'])
32
33=== modified file 'bzrlib/transform.py'
34--- bzrlib/transform.py 2012-02-06 23:38:33 +0000
35+++ bzrlib/transform.py 2012-02-26 05:32:20 +0000
36@@ -1382,7 +1382,13 @@
37 See also new_symlink.
38 """
39 if has_symlinks():
40- os.symlink(target, self._limbo_name(trans_id))
41+ try:
42+ os.symlink(target, self._limbo_name(trans_id))
43+ except OSError, e:
44+ if e.errno != errno.EPERM:
45+ raise
46+ path = FinalPaths(self).get_path(trans_id)
47+ trace.warning('Unable to create symlink "%s".' % (path,))
48 unique_add(self._new_contents, trans_id, 'symlink')
49 else:
50 try:
51
52=== modified file 'doc/en/release-notes/bzr-2.6.txt'
53--- doc/en/release-notes/bzr-2.6.txt 2012-02-25 14:13:19 +0000
54+++ doc/en/release-notes/bzr-2.6.txt 2012-02-26 05:32:20 +0000
55@@ -47,6 +47,11 @@
56 * Fix ``bzr config`` display for ``RegistryOption`` values.
57 (Vincent Ladeuil, #930182)
58
59+* Operations like ``branch`` and ``push`` no longer crash with ``OSError``
60+ when the target file system does not support symlinks. Symlinks are
61+ not created on the target and warning is shown.
62+ (Parth Malwankar, #242522)
63+
64 Documentation
65 *************
66