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
=== modified file 'bzrlib/tests/test_transform.py'
--- bzrlib/tests/test_transform.py 2012-02-06 23:38:33 +0000
+++ bzrlib/tests/test_transform.py 2012-02-26 05:32:20 +0000
@@ -1556,6 +1556,27 @@
1556 self.addCleanup(wt.unlock)1556 self.addCleanup(wt.unlock)
1557 self.assertEqual(wt.kind(wt.path2id("foo")), "symlink")1557 self.assertEqual(wt.kind(wt.path2id("foo")), "symlink")
15581558
1559 def test_no_target_symlink(self):
1560 def symlink_eperm(source, link_name):
1561 e = OSError()
1562 e.errno = errno.EPERM
1563 raise e
1564 self.requireFeature(SymlinkFeature)
1565 wt = self.make_branch_and_tree('.')
1566 self.build_tree(['foo'])
1567 wt.add(['foo'])
1568 wt.commit("one")
1569 tt = TreeTransform(wt)
1570 self.addCleanup(tt.finalize)
1571 foo_trans_id = tt.trans_id_tree_path("foo")
1572 tt.delete_contents(foo_trans_id)
1573 os_symlink = getattr(os, 'symlink', None)
1574 os.symlink = symlink_eperm
1575 try:
1576 tt.create_symlink("bar", foo_trans_id)
1577 finally:
1578 os.symlink = os_symlink
1579
1559 def test_dir_to_file(self):1580 def test_dir_to_file(self):
1560 wt = self.make_branch_and_tree('.')1581 wt = self.make_branch_and_tree('.')
1561 self.build_tree(['foo/', 'foo/bar'])1582 self.build_tree(['foo/', 'foo/bar'])
15621583
=== modified file 'bzrlib/transform.py'
--- bzrlib/transform.py 2012-02-06 23:38:33 +0000
+++ bzrlib/transform.py 2012-02-26 05:32:20 +0000
@@ -1382,7 +1382,13 @@
1382 See also new_symlink.1382 See also new_symlink.
1383 """1383 """
1384 if has_symlinks():1384 if has_symlinks():
1385 os.symlink(target, self._limbo_name(trans_id))1385 try:
1386 os.symlink(target, self._limbo_name(trans_id))
1387 except OSError, e:
1388 if e.errno != errno.EPERM:
1389 raise
1390 path = FinalPaths(self).get_path(trans_id)
1391 trace.warning('Unable to create symlink "%s".' % (path,))
1386 unique_add(self._new_contents, trans_id, 'symlink')1392 unique_add(self._new_contents, trans_id, 'symlink')
1387 else:1393 else:
1388 try:1394 try:
13891395
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- doc/en/release-notes/bzr-2.6.txt 2012-02-25 14:13:19 +0000
+++ doc/en/release-notes/bzr-2.6.txt 2012-02-26 05:32:20 +0000
@@ -47,6 +47,11 @@
47* Fix ``bzr config`` display for ``RegistryOption`` values.47* Fix ``bzr config`` display for ``RegistryOption`` values.
48 (Vincent Ladeuil, #930182)48 (Vincent Ladeuil, #930182)
4949
50* Operations like ``branch`` and ``push`` no longer crash with ``OSError``
51 when the target file system does not support symlinks. Symlinks are
52 not created on the target and warning is shown.
53 (Parth Malwankar, #242522)
54
50Documentation55Documentation
51*************56*************
5257