Rev 6287: (gz) Support removing colocated branches in 'bzr rmbranch' (Martin Packman) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Nov 24 13:15:52 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6287 [merge]
revision-id: pqm at pqm.ubuntu.com-20111124131551-u7xzxgto1p1yfz57
parent: pqm at pqm.ubuntu.com-20111124125050-ltmdzdw0jabk998p
parent: martin.packman at canonical.com-20111124121156-s5b055v8gig16b02
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-11-24 13:15:51 +0000
message:
(gz) Support removing colocated branches in 'bzr rmbranch' (Martin Packman)
modified:
bzrlib/tests/blackbox/test_rmbranch.py test_rmbranch.py-20100131150653-auenl06hu4y2d9tr-1
bzrlib/tests/test_urlutils.py test_urlutils.py-20060502192900-46b1f9579987cf9c
bzrlib/transport/local.py local_transport.py-20050711165921-9b1f142bfe480c24
bzrlib/urlutils.py urlutils.py-20060502195429-e8a161ecf8fac004
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/tests/blackbox/test_rmbranch.py'
--- a/bzrlib/tests/blackbox/test_rmbranch.py 2011-11-22 23:22:08 +0000
+++ b/bzrlib/tests/blackbox/test_rmbranch.py 2011-11-24 12:11:56 +0000
@@ -27,14 +27,15 @@
class TestRemoveBranch(TestCaseWithTransport):
- def example_branch(self, path='.'):
- tree = self.make_branch_and_tree(path)
+ def example_branch(self, path='.', format=None):
+ tree = self.make_branch_and_tree(path, format=format)
self.build_tree_contents([(path + '/hello', 'foo')])
tree.add('hello')
tree.commit(message='setup')
self.build_tree_contents([(path + '/goodbye', 'baz')])
tree.add('goodbye')
tree.commit(message='setup')
+ return tree
def test_remove_local(self):
# Remove a local branch.
@@ -58,6 +59,16 @@
dir = bzrdir.BzrDir.open('a')
self.assertFalse(dir.has_branch())
+ def test_remove_colo(self):
+ # Remove a colocated branch.
+ tree = self.example_branch('a', format='development-colo')
+ tree.bzrdir.create_branch(name="otherbranch")
+ self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
+ self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
+ dir = bzrdir.BzrDir.open('a')
+ self.assertFalse(dir.has_branch('otherbranch'))
+ self.assertTrue(dir.has_branch())
+
class TestSmartServerRemoveBranch(TestCaseWithTransport):
=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py 2011-11-18 15:31:48 +0000
+++ b/bzrlib/tests/test_urlutils.py 2011-11-24 13:15:51 +0000
@@ -20,7 +20,12 @@
import sys
from bzrlib import osutils, urlutils, win32utils
-from bzrlib.errors import InvalidURL, InvalidURLJoin, InvalidRebaseURLs
+from bzrlib.errors import (
+ InvalidURL,
+ InvalidURLJoin,
+ InvalidRebaseURLs,
+ PathNotChild,
+ )
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
@@ -917,3 +922,107 @@
url3 = url.clone()
self.assertIsNot(url, url3)
self.assertEquals(url, url3)
+
+
+class TestFileRelpath(TestCase):
+
+ # GZ 2011-11-18: A way to override all path handling functions to one
+ # platform or another for testing would be nice.
+
+ def _with_posix_paths(self):
+ self.overrideAttr(urlutils, "local_path_from_url",
+ urlutils._posix_local_path_from_url)
+ self.overrideAttr(urlutils, "MIN_ABS_FILEURL_LENGTH", len("file:///"))
+ self.overrideAttr(osutils, "normpath", osutils._posix_normpath)
+ self.overrideAttr(osutils, "abspath", osutils._posix_abspath)
+ self.overrideAttr(osutils, "normpath", osutils._posix_normpath)
+ self.overrideAttr(osutils, "pathjoin", osutils.posixpath.join)
+ self.overrideAttr(osutils, "split", osutils.posixpath.split)
+ self.overrideAttr(osutils, "MIN_ABS_PATHLENGTH", 1)
+
+ def _with_win32_paths(self):
+ self.overrideAttr(urlutils, "local_path_from_url",
+ urlutils._win32_local_path_from_url)
+ self.overrideAttr(urlutils, "MIN_ABS_FILEURL_LENGTH",
+ urlutils.WIN32_MIN_ABS_FILEURL_LENGTH)
+ self.overrideAttr(osutils, "abspath", osutils._win32_abspath)
+ self.overrideAttr(osutils, "normpath", osutils._win32_normpath)
+ self.overrideAttr(osutils, "pathjoin", osutils._win32_pathjoin)
+ self.overrideAttr(osutils, "split", osutils.ntpath.split)
+ self.overrideAttr(osutils, "MIN_ABS_PATHLENGTH", 3)
+
+ def test_same_url_posix(self):
+ self._with_posix_paths()
+ self.assertEquals("",
+ urlutils.file_relpath("file:///a", "file:///a"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///a", "file:///a/"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///a/", "file:///a"))
+
+ def test_same_url_win32(self):
+ self._with_win32_paths()
+ self.assertEquals("",
+ urlutils.file_relpath("file:///A:/", "file:///A:/"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///A|/", "file:///A:/"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///A:/b/", "file:///A:/b/"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///A:/b", "file:///A:/b/"))
+ self.assertEquals("",
+ urlutils.file_relpath("file:///A:/b/", "file:///A:/b"))
+
+ def test_child_posix(self):
+ self._with_posix_paths()
+ self.assertEquals("b",
+ urlutils.file_relpath("file:///a", "file:///a/b"))
+ self.assertEquals("b",
+ urlutils.file_relpath("file:///a/", "file:///a/b"))
+ self.assertEquals("b/c",
+ urlutils.file_relpath("file:///a", "file:///a/b/c"))
+
+ def test_child_win32(self):
+ self._with_win32_paths()
+ self.assertEquals("b",
+ urlutils.file_relpath("file:///A:/", "file:///A:/b"))
+ self.assertEquals("b",
+ urlutils.file_relpath("file:///A|/", "file:///A:/b"))
+ self.assertEquals("c",
+ urlutils.file_relpath("file:///A:/b", "file:///A:/b/c"))
+ self.assertEquals("c",
+ urlutils.file_relpath("file:///A:/b/", "file:///A:/b/c"))
+ self.assertEquals("c/d",
+ urlutils.file_relpath("file:///A:/b", "file:///A:/b/c/d"))
+
+ def test_sibling_posix(self):
+ self._with_posix_paths()
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///a/b", "file:///a/c")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///a/b/", "file:///a/c")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///a/b/", "file:///a/c/")
+
+ def test_sibling_win32(self):
+ self._with_win32_paths()
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///A:/b", "file:///A:/c")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///A:/b/", "file:///A:/c")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///A:/b/", "file:///A:/c/")
+
+ def test_parent_posix(self):
+ self._with_posix_paths()
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///a/b", "file:///a")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///a/b", "file:///a/")
+
+ def test_parent_win32(self):
+ self._with_win32_paths()
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///A:/b", "file:///A:/")
+ self.assertRaises(PathNotChild,
+ urlutils.file_relpath, "file:///A:/b/c", "file:///A:/b")
=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py 2011-10-06 07:43:13 +0000
+++ b/bzrlib/transport/local.py 2011-11-04 21:27:48 +0000
@@ -146,9 +146,7 @@
if abspath is None:
abspath = u'.'
- return urlutils.file_relpath(
- urlutils.strip_trailing_slash(self.base),
- urlutils.strip_trailing_slash(abspath))
+ return urlutils.file_relpath(self.base, abspath)
def has(self, relpath):
return os.access(self._abspath(relpath), os.F_OK)
@@ -540,9 +538,7 @@
"""See Transport.symlink."""
abs_link_dirpath = urlutils.dirname(self.abspath(link_name))
source_rel = urlutils.file_relpath(
- urlutils.strip_trailing_slash(abs_link_dirpath),
- urlutils.strip_trailing_slash(self.abspath(source))
- )
+ abs_link_dirpath, self.abspath(source))
try:
os.symlink(source_rel, self._abspath(link_name))
=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py 2011-11-21 09:59:54 +0000
+++ b/bzrlib/urlutils.py 2011-11-24 13:15:51 +0000
@@ -78,8 +78,8 @@
raise ValueError('Length of base (%r) must equal or'
' exceed the platform minimum url length (which is %d)' %
(base, MIN_ABS_FILEURL_LENGTH))
- base = local_path_from_url(base)
- path = local_path_from_url(path)
+ base = osutils.normpath(local_path_from_url(base))
+ path = osutils.normpath(local_path_from_url(path))
return escape(osutils.relpath(base, path))
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-11-24 12:06:50 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-11-24 13:15:51 +0000
@@ -156,6 +156,9 @@
* ``bzr revno`` now takes a ``--revision`` argument.
(Jelmer Vernooij, #870649)
+* ``bzr rmbranch`` can now remove colocated branches.
+ (Jelmer Vernooij, #831464)
+
* ``bzr serve`` now can serve from URLs rather than just from the
file system. I.e.: ``bzr serve -d lp:bzr`` or
``bzr serve -d file:///data/bzr`` (Jelmer Vernooij)
More information about the bazaar-commits
mailing list