Merge lp:~nmb/bzr/484516-push-revspec-tree into lp:bzr

Proposed by Neil Martinsen-Burrell
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6545
Proposed branch: lp:~nmb/bzr/484516-push-revspec-tree
Merge into: lp:bzr
Diff against target: 72 lines (+36/-1)
3 files modified
bzrlib/tests/blackbox/test_push.py (+27/-0)
bzrlib/workingtree.py (+6/-1)
doc/en/release-notes/bzr-2.6.txt (+3/-0)
To merge this branch: bzr merge lp:~nmb/bzr/484516-push-revspec-tree
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Marius Kruger Approve
Review via email: mp+101166@code.launchpad.net

Commit message

Create working tree at specified revision when doing a local push

Description of the change

This change fixes bug 484516 by creating a pushed working tree at the specified revision. I have added a script test based on the reproduction recipe, as well as augmenting bzrlib/tests/test_push.py:test_push_with_revisionspec.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This seems reasonable to me.

review: Approve
Revision history for this message
Marius Kruger (amanica) wrote :

Congrats on tracking this nasty down.
I just have 2 comments that I think can be addressed when merging.

1) I suggest adding a comment at the end of your blackbox test_push_with_revspec
  +++ bzrlib/tests/blackbox/test_push.py 2012-06-10 23:32:32 +0000
  @@ -445,20 +445,22 @@ class TestPush(tests.TestCaseWithTranspo
  + $ bzr st ../other # checking that file is not created (bug #484516)
2) You are adding a trailing space here..
  +++ bzrlib/workingtree.py 2012-06-10 23:32:32 +0000
  @@ -527,21 +527,22 @@ class WorkingTree(bzrlib.mutabletree.Mut
  + merge.transform_tree(tree, <--

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Have you looked at the performance impact of this change? This might have to fetch the full contents of the tree another time.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

It might be worthwile to use self.revision_tree() rather than self.branch.repository.revision_tree().

review: Needs Fixing
Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

> It might be worthwile to use self.revision_tree() rather than
> self.branch.repository.revision_tree().

self.revision_tree() doesn't seem to work the same. That is, it breaks lots of other test cases with e.g.

...
NoSuchRevisionInTree: The revision id {added} is not present in the tree <WorkingTree6 of /private/var/folders/d8/wjzb13qx7ns9yjh46bq9ljs00000gn/T/testbzr-jPjTz6.tmp/bzrlib.tests.blackbox.test_push.TestPushStrictWithChanges.test_push_with_revision(out-of-sync-trees)/work/local>

Resubmitting for review with Marius's suggested change.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Mon, Jul 02, 2012 at 05:35:30AM -0000, Neil Martinsen-Burrell wrote:
> > It might be worthwile to use self.revision_tree() rather than
> > self.branch.repository.revision_tree().
>
> self.revision_tree() doesn't seem to work the same. That is, it breaks lots of other test cases with e.g.
>
> ...
> NoSuchRevisionInTree: The revision id {added} is not present in the tree <WorkingTree6 of /private/var/folders/d8/wjzb13qx7ns9yjh46bq9ljs00000gn/T/testbzr-jPjTz6.tmp/bzrlib.tests.blackbox.test_push.TestPushStrictWithChanges.test_push_with_revision(out-of-sync-trees)/work/local>
Perhaps trying WorkingTree.revision_tree() first and if that raises
NoSuchRevision, falling back to Repository.revision_tree() ?

Without using WorkingTree.revision_tree() we're going to be fetching
the entire revision tree from the server in some cases, which is a
major performance regression.

Cheers,

Jelmer

Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

I added a try/except that first tries to look up the revision tree from the working tree and only goes the the branch's repository if the first lookup fails.

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

thanks!

Revision history for this message
Martin Packman (gz) wrote :

sent to pqm by email

Revision history for this message
Martin Packman (gz) wrote :

Failed on PQM due to needing release notes updating, I'll do that and merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/blackbox/test_push.py'
2--- bzrlib/tests/blackbox/test_push.py 2012-04-16 11:08:11 +0000
3+++ bzrlib/tests/blackbox/test_push.py 2012-07-04 18:04:24 +0000
4@@ -452,6 +452,8 @@
5 self.assertTrue(repo_to.has_revision('from-1'))
6 self.assertFalse(repo_to.has_revision('from-2'))
7 self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
8+ self.assertFalse(
9+ tree_to.changes_from(tree_to.basis_tree()).has_changed())
10
11 self.run_bzr_error(
12 ['bzr: ERROR: bzr push --revision '
13@@ -917,3 +919,28 @@
14 2>All changes applied successfully.
15 2>Pushed up to revision 1.
16 """)
17+
18+ def test_push_with_revspec(self):
19+ self.run_script("""
20+ $ bzr init-repo .
21+ Shared repository with trees (format: 2a)
22+ Location:
23+ shared repository: .
24+ $ bzr init trunk
25+ Created a repository tree (format: 2a)
26+ Using shared repository...
27+ $ cd trunk
28+ $ bzr commit -m 'first rev' --unchanged
29+ 2>Committing to:...trunk/
30+ 2>Committed revision 1.
31+ $ echo foo > file
32+ $ bzr add
33+ adding file
34+ $ bzr commit -m 'we need some foo'
35+ 2>Committing to:...trunk/
36+ 2>added file
37+ 2>Committed revision 2.
38+ $ bzr push -r 1 ../other
39+ 2>Created new branch.
40+ $ bzr st ../other # checking that file is not created (#484516)
41+ """)
42
43=== modified file 'bzrlib/workingtree.py'
44--- bzrlib/workingtree.py 2012-06-18 11:43:07 +0000
45+++ bzrlib/workingtree.py 2012-07-04 18:04:24 +0000
46@@ -534,7 +534,12 @@
47 else:
48 # TODO now merge from tree.last_revision to revision (to preserve
49 # user local changes)
50- merge.transform_tree(tree, self)
51+ try:
52+ other_tree = self.revision_tree(revision_id)
53+ except errors.NoSuchRevision:
54+ other_tree = self.branch.repository.revision_tree(revision_id)
55+
56+ merge.transform_tree(tree, other_tree)
57 if revision_id == _mod_revision.NULL_REVISION:
58 new_parents = []
59 else:
60
61=== modified file 'doc/en/release-notes/bzr-2.6.txt'
62--- doc/en/release-notes/bzr-2.6.txt 2012-06-26 15:40:44 +0000
63+++ doc/en/release-notes/bzr-2.6.txt 2012-07-04 18:04:24 +0000
64@@ -44,6 +44,9 @@
65 * Implement ``ResponseFile.readline`` and ``ReponseFile.tell``,
66 fixing some clones over HTTP. (Jelmer Vernooij, #963769)
67
68+* When pushing a specific revision, create the new working tree at
69+ that revision. (#484516, Neil Martinsen-Burrell)
70+
71 Documentation
72 *************
73