Merge lp:~abentley/bzrtools/testattach into lp:bzrtools

Proposed by Aaron Bentley on 2013-10-31
Status: Rejected
Rejected by: Aaron Bentley on 2013-10-31
Proposed branch: lp:~abentley/bzrtools/testattach
Merge into: lp:bzrtools
Diff against target: 134 lines (+37/-10)
4 files modified
README (+2/-0)
bzrtools.py (+12/-1)
version.py (+1/-1)
zap.py (+22/-8)
To merge this branch: bzr merge lp:~abentley/bzrtools/testattach
Reviewer Review Type Date Requested Status
Aaron Bentley Pending
Review via email: mp+193415@code.launchpad.net

Commit message

test

Description of the change

This is a test of attaching files to comments.

To post a comment you must log in.
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Test of attachment.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlJyVdsACgkQ0F+nu1YWqI3dFQCfbE8sXX/Ozd05Aeb3vFZUqOCx
/vgAn3aBaQRMhwz69j3NZhARZ3uqrR/Y
=7FGZ
-----END PGP SIGNATURE-----

Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Test.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlJyZAsACgkQ0F+nu1YWqI03HACdGaAWtKktGOyIfzJs91t3LMGf
EPcAnjkj8q2fI0jtibO39D+O7hPUnjXD
=cyF7
-----END PGP SIGNATURE-----

1=== modified file 'README'
2--- README 2009-03-11 02:13:43 +0000
3+++ README 2013-10-31 13:02:36 +0000
4@@ -1,3 +1,5 @@
5+TEST
6+
7 BZR TOOLS
8
9 This is is a set of plugins for Bazaar.
10
11=== modified file 'bzrtools.py'
12--- bzrtools.py 2012-01-20 02:05:50 +0000
13+++ bzrtools.py 2013-08-20 03:02:23 +0000
14@@ -1,4 +1,4 @@
15-# Copyright (C) 2005-2009, 2011-2012 Aaron Bentley <aaron@aaronbentley.com>
16+# Copyright (C) 2005-2009, 2011-2013 Aaron Bentley <aaron@aaronbentley.com>
17 # Copyright (C) 2007 John Arbash Meinel
18 #
19 # This program is free software; you can redistribute it and/or modify
20@@ -14,6 +14,7 @@
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24+from contextlib import contextmanager
25 import re
26
27 from bzrlib import urlutils
28@@ -26,6 +27,16 @@
29 from bzrlib.transport import get_transport
30
31
32+@contextmanager
33+def read_locked(lockable):
34+ """Read-lock a tree, branch or repository in this context."""
35+ lockable.lock_read()
36+ try:
37+ yield lockable
38+ finally:
39+ lockable.unlock()
40+
41+
42 def short_committer(committer):
43 new_committer = re.sub('<.*>', '', committer).strip(' ')
44 if len(new_committer) < 2:
45
46=== modified file 'version.py'
47--- version.py 2012-01-20 02:07:15 +0000
48+++ version.py 2013-08-20 02:19:06 +0000
49@@ -75,5 +75,5 @@
50 return main_version + sub_string
51
52
53-version_info = (2, 5, 0)
54+version_info = (2, 6, 0)
55 __version__ = _format_version_tuple(version_info)
56
57=== modified file 'zap.py'
58--- zap.py 2011-04-12 04:51:37 +0000
59+++ zap.py 2013-08-20 03:00:56 +0000
60@@ -1,4 +1,5 @@
61 # Copyright (C) 2006-2007, 2010-2011 Aaron Bentley <aaron@aaronbentley.com>
62+# Copyright (C) 2013 Aaron Bentley <aaron@aaronbentley.com>
63 # Copyright (C) 2007 Charlie Shepherd <masterdriverz@gentoo.org>
64 # Copyright (C) 2011 Canonical Ltd.
65 #
66@@ -29,6 +30,7 @@
67
68 from errors import (NotCheckout, UncommittedCheckout, ParentMissingRevisions,
69 NoParent)
70+from bzrlib.plugins.bzrtools.bzrtools import read_locked
71
72
73 class AllowChanged(object):
74@@ -83,6 +85,7 @@
75 change_policy_registry.default_key = 'check'
76
77
78+
79 def zap(path, remove_branch=False, policy=HaltOnChange):
80 try:
81 wt = bzrdir.BzrDir.open(path).open_workingtree(path,
82@@ -99,12 +102,13 @@
83 parent_loc = branch.get_parent()
84 if parent_loc is None:
85 raise NoParent()
86- parent = Branch.open(parent_loc)
87- last_revision = _mod_revision.ensure_null(parent.last_revision())
88- p_ancestry = parent.repository.get_ancestry(last_revision)
89- if (last_revision != _mod_revision.NULL_REVISION and
90- branch.last_revision() not in p_ancestry):
91- raise ParentMissingRevisions(branch.get_parent())
92+ with read_locked(Branch.open(parent_loc)) as parent:
93+ last_revision = _mod_revision.ensure_null(parent.last_revision())
94+ if last_revision != _mod_revision.NULL_REVISION:
95+ graph = parent.repository.get_graph()
96+ heads = graph.heads([last_revision, branch.last_revision()])
97+ if branch.last_revision() in heads:
98+ raise ParentMissingRevisions(branch.get_parent())
99 rmtree(path)
100 if remove_branch:
101 t = branch.bzrdir.transport
102@@ -118,7 +122,7 @@
103 import os
104 from unittest import makeSuite
105
106- from bzrlib.tests import TestCaseInTempDir
107+ from bzrlib.tests import TestCaseWithTransport
108
109
110 class PipelinePluginFeature:
111@@ -133,7 +137,7 @@
112 return True
113
114
115- class TestZap(TestCaseInTempDir):
116+ class TestZap(TestCaseWithTransport):
117
118 def make_checkout(self):
119 wt = bzrdir.BzrDir.create_standalone_workingtree('source')
120@@ -209,4 +213,14 @@
121 checkout.branch.set_parent(branch.base)
122 zap('checkout', policy=StoreChanges, remove_branch=True)
123
124+ def test_zap_branch_with_unique_revision(self):
125+ parent = self.make_branch_and_tree('parent')
126+ parent.commit('foo')
127+ new_branch = self.make_branch('new')
128+ new_branch.set_parent(parent.branch.base)
129+ checkout = new_branch.create_checkout('checkout', lightweight=True)
130+ checkout.commit('unique')
131+ self.assertRaises(ParentMissingRevisions, zap, 'checkout',
132+ remove_branch=True)
133+
134 return makeSuite(TestZap)

Unmerged revisions

788. By Aaron Bentley on 2013-10-31

Test commit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2009-03-11 02:13:43 +0000
3+++ README 2013-10-31 13:05:19 +0000
4@@ -1,3 +1,5 @@
5+TEST
6+
7 BZR TOOLS
8
9 This is is a set of plugins for Bazaar.
10
11=== modified file 'bzrtools.py'
12--- bzrtools.py 2012-01-20 02:05:50 +0000
13+++ bzrtools.py 2013-10-31 13:05:19 +0000
14@@ -1,4 +1,4 @@
15-# Copyright (C) 2005-2009, 2011-2012 Aaron Bentley <aaron@aaronbentley.com>
16+# Copyright (C) 2005-2009, 2011-2013 Aaron Bentley <aaron@aaronbentley.com>
17 # Copyright (C) 2007 John Arbash Meinel
18 #
19 # This program is free software; you can redistribute it and/or modify
20@@ -14,6 +14,7 @@
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24+from contextlib import contextmanager
25 import re
26
27 from bzrlib import urlutils
28@@ -26,6 +27,16 @@
29 from bzrlib.transport import get_transport
30
31
32+@contextmanager
33+def read_locked(lockable):
34+ """Read-lock a tree, branch or repository in this context."""
35+ lockable.lock_read()
36+ try:
37+ yield lockable
38+ finally:
39+ lockable.unlock()
40+
41+
42 def short_committer(committer):
43 new_committer = re.sub('<.*>', '', committer).strip(' ')
44 if len(new_committer) < 2:
45
46=== modified file 'version.py'
47--- version.py 2012-01-20 02:07:15 +0000
48+++ version.py 2013-10-31 13:05:19 +0000
49@@ -75,5 +75,5 @@
50 return main_version + sub_string
51
52
53-version_info = (2, 5, 0)
54+version_info = (2, 6, 0)
55 __version__ = _format_version_tuple(version_info)
56
57=== modified file 'zap.py'
58--- zap.py 2011-04-12 04:51:37 +0000
59+++ zap.py 2013-10-31 13:05:19 +0000
60@@ -1,4 +1,5 @@
61 # Copyright (C) 2006-2007, 2010-2011 Aaron Bentley <aaron@aaronbentley.com>
62+# Copyright (C) 2013 Aaron Bentley <aaron@aaronbentley.com>
63 # Copyright (C) 2007 Charlie Shepherd <masterdriverz@gentoo.org>
64 # Copyright (C) 2011 Canonical Ltd.
65 #
66@@ -29,6 +30,7 @@
67
68 from errors import (NotCheckout, UncommittedCheckout, ParentMissingRevisions,
69 NoParent)
70+from bzrlib.plugins.bzrtools.bzrtools import read_locked
71
72
73 class AllowChanged(object):
74@@ -83,6 +85,7 @@
75 change_policy_registry.default_key = 'check'
76
77
78+
79 def zap(path, remove_branch=False, policy=HaltOnChange):
80 try:
81 wt = bzrdir.BzrDir.open(path).open_workingtree(path,
82@@ -99,12 +102,13 @@
83 parent_loc = branch.get_parent()
84 if parent_loc is None:
85 raise NoParent()
86- parent = Branch.open(parent_loc)
87- last_revision = _mod_revision.ensure_null(parent.last_revision())
88- p_ancestry = parent.repository.get_ancestry(last_revision)
89- if (last_revision != _mod_revision.NULL_REVISION and
90- branch.last_revision() not in p_ancestry):
91- raise ParentMissingRevisions(branch.get_parent())
92+ with read_locked(Branch.open(parent_loc)) as parent:
93+ last_revision = _mod_revision.ensure_null(parent.last_revision())
94+ if last_revision != _mod_revision.NULL_REVISION:
95+ graph = parent.repository.get_graph()
96+ heads = graph.heads([last_revision, branch.last_revision()])
97+ if branch.last_revision() in heads:
98+ raise ParentMissingRevisions(branch.get_parent())
99 rmtree(path)
100 if remove_branch:
101 t = branch.bzrdir.transport
102@@ -118,7 +122,7 @@
103 import os
104 from unittest import makeSuite
105
106- from bzrlib.tests import TestCaseInTempDir
107+ from bzrlib.tests import TestCaseWithTransport
108
109
110 class PipelinePluginFeature:
111@@ -133,7 +137,7 @@
112 return True
113
114
115- class TestZap(TestCaseInTempDir):
116+ class TestZap(TestCaseWithTransport):
117
118 def make_checkout(self):
119 wt = bzrdir.BzrDir.create_standalone_workingtree('source')
120@@ -209,4 +213,14 @@
121 checkout.branch.set_parent(branch.base)
122 zap('checkout', policy=StoreChanges, remove_branch=True)
123
124+ def test_zap_branch_with_unique_revision(self):
125+ parent = self.make_branch_and_tree('parent')
126+ parent.commit('foo')
127+ new_branch = self.make_branch('new')
128+ new_branch.set_parent(parent.branch.base)
129+ checkout = new_branch.create_checkout('checkout', lightweight=True)
130+ checkout.commit('unique')
131+ self.assertRaises(ParentMissingRevisions, zap, 'checkout',
132+ remove_branch=True)
133+
134 return makeSuite(TestZap)

Subscribers

People subscribed via source and target branches