Merge lp:~beuno/bzr-upload/ignores into lp:bzr-upload
- ignores
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~beuno/bzr-upload/ignores |
Merge into: | lp:bzr-upload |
Diff against target: |
236 lines (+74/-29) 3 files modified
README (+0/-1) __init__.py (+53/-27) tests/test_upload.py (+21/-1) |
To merge this branch: | bzr merge lp:~beuno/bzr-upload/ignores |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Review via email: mp+15346@code.launchpad.net |
Commit message
Description of the change
Martin Albisetti (beuno) wrote : | # |
- 73. By Martin Albisetti
-
2009 tests!
- 74. By Martin Albisetti
-
Fix all the tests I broke :)
Alexander Belchenko (bialix) wrote : | # |
Martin, on the last bzr sprint in Mooloolaba it was decided to keep different config and settings fro plugins in subdirectory .bzrmeta. You may want to ask Ian Clatworthy for details. So, if you change your code to use .bzrmeta/
(I've got here from your article about TDD ;-)
Vincent Ladeuil (vila) wrote : | # |
It looks like you re-introduce the README file that has been moved in the __init__.py so that the documentation can be automatically generated.
I suspect that's because you started with an old branch.
The test sounds right, you may want to add one (and some code too :) for directories.
The diff is larger than it should, could it be because you introduced spurious spaces ?
195 + ignored_files = self.get_ignored()
196 + if relpath not in ignored_files:
197 + self.get_ignored()
That self.get_ignored() call seems useless.
Martin Albisetti (beuno) wrote : | # |
On Sat, Nov 28, 2009 at 1:58 PM, Vincent Ladeuil <email address hidden> wrote:
> It looks like you re-introduce the README file that has been moved in the __init__.py so that the documentation can be automatically generated.
I did it on purpose :)
People getting the branch/tarball don't really find that information
since it's buried in the python file.
If you feel strongly about not having the duplication, I'll be happy
to drop that change.
> The test sounds right, you may want to add one (and some code too :) for directories.
That sounds sane :)
I will work on that and poke you again.
> The diff is larger than it should, could it be because you introduced spurious spaces ?
The opposite. I removed whitespace.
> 195 + ignored_files = self.get_ignored()
> 196 + if relpath not in ignored_files:
> 197 + self.get_ignored()
>
> That self.get_ignored() call seems useless.
Yes, thanks for catching that. Removed.
--
Martin
- 75. By Martin Albisetti
-
Remove left over line
- 76. By Martin Albisetti
-
Remove duplication from README
Vincent Ladeuil (vila) wrote : | # |
bialix is right, but let's file a bug for that (so we can land this fix).
Martin Albisetti (beuno) wrote : | # |
Ok, updated with ignoring dirs, and a test to prove it.
I think I addressed all comments, Vincent.
- 77. By Martin Albisetti
-
Add test for ignoring a dir
- 78. By Martin Albisetti
-
Actually ignore the dirs. Test pass!
Vincent Ladeuil (vila) wrote : | # |
Well done, please land.
Preview Diff
1 | === modified file 'README' | |||
2 | --- README 2009-09-05 11:35:21 +0000 | |||
3 | +++ README 2009-11-30 21:44:09 +0000 | |||
4 | @@ -13,7 +13,6 @@ | |||
5 | 13 | Please report any bugs to: http://bugs.launchpad.net/bzr-upload/ | 13 | Please report any bugs to: http://bugs.launchpad.net/bzr-upload/ |
6 | 14 | 14 | ||
7 | 15 | Our home page is located at: https://launchpad.net/bzr-upload/ | 15 | Our home page is located at: https://launchpad.net/bzr-upload/ |
8 | 16 | |||
9 | 17 | The original authors are: | 16 | The original authors are: |
10 | 18 | 17 | ||
11 | 19 | Vincent Ladeuil <v.ladeuil+lp@free.fr> | 18 | Vincent Ladeuil <v.ladeuil+lp@free.fr> |
12 | 20 | 19 | ||
13 | === modified file '__init__.py' | |||
14 | --- __init__.py 2009-10-04 17:05:54 +0000 | |||
15 | +++ __init__.py 2009-11-30 21:44:09 +0000 | |||
16 | @@ -115,6 +115,14 @@ | |||
17 | 115 | Note that you will consume more bandwith this way than uploading from a local | 115 | Note that you will consume more bandwith this way than uploading from a local |
18 | 116 | branch. | 116 | branch. |
19 | 117 | 117 | ||
20 | 118 | Ignoring certain files | ||
21 | 119 | ----------------------- | ||
22 | 120 | |||
23 | 121 | If you want to version a file, but not upload it, you can create a file called | ||
24 | 122 | .bzrignore-upload, which works in the same way as the regular .bzrignore file, | ||
25 | 123 | but only applies to bzr-upload. | ||
26 | 124 | |||
27 | 125 | |||
28 | 118 | Collaborating | 126 | Collaborating |
29 | 119 | ------------- | 127 | ------------- |
30 | 120 | 128 | ||
31 | @@ -122,8 +130,7 @@ | |||
32 | 122 | 130 | ||
33 | 123 | bzr branch lp:bzr-upload | 131 | bzr branch lp:bzr-upload |
34 | 124 | 132 | ||
37 | 125 | And change anything you'd like, and get in touch with any of the authors to | 133 | And change anything you'd like, and file a merge proposal on Launchpad. |
36 | 126 | review and add the changes. | ||
38 | 127 | 134 | ||
39 | 128 | 135 | ||
40 | 129 | Known Issues | 136 | Known Issues |
41 | @@ -157,6 +164,7 @@ | |||
42 | 157 | from bzrlib import ( | 164 | from bzrlib import ( |
43 | 158 | bzrdir, | 165 | bzrdir, |
44 | 159 | errors, | 166 | errors, |
45 | 167 | ignores, | ||
46 | 160 | revisionspec, | 168 | revisionspec, |
47 | 161 | transport, | 169 | transport, |
48 | 162 | osutils, | 170 | osutils, |
49 | @@ -271,15 +279,28 @@ | |||
50 | 271 | self._uploaded_revid = revision.NULL_REVISION | 279 | self._uploaded_revid = revision.NULL_REVISION |
51 | 272 | return self._uploaded_revid | 280 | return self._uploaded_revid |
52 | 273 | 281 | ||
53 | 282 | def get_ignored(self): | ||
54 | 283 | """Get upload-specific ignored files from the current branch""" | ||
55 | 284 | try: | ||
56 | 285 | ignore_file = self.tree.get_file_by_path('.bzrignore-upload') | ||
57 | 286 | return ignores.parse_ignore_file(ignore_file) | ||
58 | 287 | except errors.NoSuchId: | ||
59 | 288 | return [] | ||
60 | 289 | |||
61 | 274 | def upload_file(self, relpath, id, mode=None): | 290 | def upload_file(self, relpath, id, mode=None): |
70 | 275 | if mode is None: | 291 | ignored_files = self.get_ignored() |
71 | 276 | if self.tree.is_executable(id): | 292 | if relpath not in ignored_files: |
72 | 277 | mode = 0775 | 293 | if mode is None: |
73 | 278 | else: | 294 | if self.tree.is_executable(id): |
74 | 279 | mode = 0664 | 295 | mode = 0775 |
75 | 280 | if not self.quiet: | 296 | else: |
76 | 281 | self.outf.write('Uploading %s\n' % relpath) | 297 | mode = 0664 |
77 | 282 | self.to_transport.put_bytes(relpath, self.tree.get_file_text(id), mode) | 298 | if not self.quiet: |
78 | 299 | self.outf.write('Uploading %s\n' % relpath) | ||
79 | 300 | self.to_transport.put_bytes(relpath, self.tree.get_file_text(id), mode) | ||
80 | 301 | else: | ||
81 | 302 | if not self.quiet: | ||
82 | 303 | self.outf.write('Ignoring %s\n' % relpath) | ||
83 | 283 | 304 | ||
84 | 284 | def upload_file_robustly(self, relpath, id, mode=None): | 305 | def upload_file_robustly(self, relpath, id, mode=None): |
85 | 285 | """Upload a file, clearing the way on the remote side. | 306 | """Upload a file, clearing the way on the remote side. |
86 | @@ -300,9 +321,14 @@ | |||
87 | 300 | self.upload_file(relpath, id, mode) | 321 | self.upload_file(relpath, id, mode) |
88 | 301 | 322 | ||
89 | 302 | def make_remote_dir(self, relpath, mode=None): | 323 | def make_remote_dir(self, relpath, mode=None): |
93 | 303 | if mode is None: | 324 | ignored_files = self.get_ignored() |
94 | 304 | mode = 0775 | 325 | if relpath not in ignored_files: |
95 | 305 | self.to_transport.mkdir(relpath, mode) | 326 | if mode is None: |
96 | 327 | mode = 0775 | ||
97 | 328 | self.to_transport.mkdir(relpath, mode) | ||
98 | 329 | else: | ||
99 | 330 | if not self.quiet: | ||
100 | 331 | self.outf.write('Ignoring %s\n' % relpath) | ||
101 | 306 | 332 | ||
102 | 307 | def make_remote_dir_robustly(self, relpath, mode=None): | 333 | def make_remote_dir_robustly(self, relpath, mode=None): |
103 | 308 | """Create a remote directory, clearing the way on the remote side. | 334 | """Create a remote directory, clearing the way on the remote side. |
104 | @@ -388,7 +414,7 @@ | |||
105 | 388 | self.tree.lock_read() | 414 | self.tree.lock_read() |
106 | 389 | try: | 415 | try: |
107 | 390 | for relpath, ie in self.tree.inventory.iter_entries(): | 416 | for relpath, ie in self.tree.inventory.iter_entries(): |
109 | 391 | if relpath in ('', '.bzrignore'): | 417 | if relpath in ('', '.bzrignore', '.bzrignore-upload'): |
110 | 392 | # skip root ('') | 418 | # skip root ('') |
111 | 393 | # .bzrignore has no meaning outside of a working tree | 419 | # .bzrignore has no meaning outside of a working tree |
112 | 394 | # so do not upload it | 420 | # so do not upload it |
113 | @@ -407,7 +433,7 @@ | |||
114 | 407 | # If we can't find the revid file on the remote location, upload the | 433 | # If we can't find the revid file on the remote location, upload the |
115 | 408 | # full tree instead | 434 | # full tree instead |
116 | 409 | rev_id = self.get_uploaded_revid() | 435 | rev_id = self.get_uploaded_revid() |
118 | 410 | 436 | ||
119 | 411 | if rev_id == revision.NULL_REVISION: | 437 | if rev_id == revision.NULL_REVISION: |
120 | 412 | if not self.quiet: | 438 | if not self.quiet: |
121 | 413 | self.outf.write('No uploaded revision id found,' | 439 | self.outf.write('No uploaded revision id found,' |
122 | @@ -528,7 +554,7 @@ | |||
123 | 528 | 554 | ||
124 | 529 | (wt, branch, | 555 | (wt, branch, |
125 | 530 | relpath) = bzrdir.BzrDir.open_containing_tree_or_branch(directory) | 556 | relpath) = bzrdir.BzrDir.open_containing_tree_or_branch(directory) |
127 | 531 | 557 | ||
128 | 532 | if wt: | 558 | if wt: |
129 | 533 | wt.lock_read() | 559 | wt.lock_read() |
130 | 534 | else: | 560 | else: |
131 | @@ -536,10 +562,10 @@ | |||
132 | 536 | try: | 562 | try: |
133 | 537 | if wt: | 563 | if wt: |
134 | 538 | changes = wt.changes_from(wt.basis_tree()) | 564 | changes = wt.changes_from(wt.basis_tree()) |
136 | 539 | 565 | ||
137 | 540 | if revision is None and changes.has_changed(): | 566 | if revision is None and changes.has_changed(): |
138 | 541 | raise errors.UncommittedChanges(wt) | 567 | raise errors.UncommittedChanges(wt) |
140 | 542 | 568 | ||
141 | 543 | if location is None: | 569 | if location is None: |
142 | 544 | stored_loc = get_upload_location(branch) | 570 | stored_loc = get_upload_location(branch) |
143 | 545 | if stored_loc is None: | 571 | if stored_loc is None: |
144 | @@ -551,9 +577,9 @@ | |||
145 | 551 | self.outf.encoding) | 577 | self.outf.encoding) |
146 | 552 | self.outf.write("Using saved location: %s\n" % display_url) | 578 | self.outf.write("Using saved location: %s\n" % display_url) |
147 | 553 | location = stored_loc | 579 | location = stored_loc |
149 | 554 | 580 | ||
150 | 555 | to_transport = transport.get_transport(location) | 581 | to_transport = transport.get_transport(location) |
152 | 556 | 582 | ||
153 | 557 | # Check that we are not uploading to a existing working tree. | 583 | # Check that we are not uploading to a existing working tree. |
154 | 558 | try: | 584 | try: |
155 | 559 | to_bzr_dir = bzrdir.BzrDir.open_from_transport(to_transport) | 585 | to_bzr_dir = bzrdir.BzrDir.open_from_transport(to_transport) |
156 | @@ -563,10 +589,10 @@ | |||
157 | 563 | except errors.NotLocalUrl: | 589 | except errors.NotLocalUrl: |
158 | 564 | # The exception raised is a bit weird... but that's life. | 590 | # The exception raised is a bit weird... but that's life. |
159 | 565 | has_wt = True | 591 | has_wt = True |
161 | 566 | 592 | ||
162 | 567 | if has_wt: | 593 | if has_wt: |
163 | 568 | raise CannotUploadToWorkingTreeError(url=location) | 594 | raise CannotUploadToWorkingTreeError(url=location) |
165 | 569 | 595 | ||
166 | 570 | if revision is None: | 596 | if revision is None: |
167 | 571 | rev_id = branch.last_revision() | 597 | rev_id = branch.last_revision() |
168 | 572 | else: | 598 | else: |
169 | @@ -574,18 +600,18 @@ | |||
170 | 574 | raise errors.BzrCommandError( | 600 | raise errors.BzrCommandError( |
171 | 575 | 'bzr upload --revision takes exactly 1 argument') | 601 | 'bzr upload --revision takes exactly 1 argument') |
172 | 576 | rev_id = revision[0].in_history(branch).rev_id | 602 | rev_id = revision[0].in_history(branch).rev_id |
174 | 577 | 603 | ||
175 | 578 | tree = branch.repository.revision_tree(rev_id) | 604 | tree = branch.repository.revision_tree(rev_id) |
177 | 579 | 605 | ||
178 | 580 | uploader = BzrUploader(branch, to_transport, self.outf, tree, | 606 | uploader = BzrUploader(branch, to_transport, self.outf, tree, |
179 | 581 | rev_id, quiet=quiet) | 607 | rev_id, quiet=quiet) |
181 | 582 | 608 | ||
182 | 583 | if not overwrite: | 609 | if not overwrite: |
183 | 584 | prev_uploaded_rev_id = uploader.get_uploaded_revid() | 610 | prev_uploaded_rev_id = uploader.get_uploaded_revid() |
184 | 585 | graph = branch.repository.get_graph() | 611 | graph = branch.repository.get_graph() |
185 | 586 | if not graph.is_ancestor(prev_uploaded_rev_id, rev_id): | 612 | if not graph.is_ancestor(prev_uploaded_rev_id, rev_id): |
186 | 587 | raise DivergedError(rev_id, prev_uploaded_rev_id) | 613 | raise DivergedError(rev_id, prev_uploaded_rev_id) |
188 | 588 | 614 | ||
189 | 589 | if full: | 615 | if full: |
190 | 590 | uploader.upload_full_tree() | 616 | uploader.upload_full_tree() |
191 | 591 | else: | 617 | else: |
192 | @@ -622,7 +648,7 @@ | |||
193 | 622 | 648 | ||
194 | 623 | _fmt = ("The revision upload to this location is from a branch that is " | 649 | _fmt = ("The revision upload to this location is from a branch that is " |
195 | 624 | "diverged from this branch: %(upload_revid)s") | 650 | "diverged from this branch: %(upload_revid)s") |
197 | 625 | 651 | ||
198 | 626 | # We should probably tell the user to use merge on the diverged branch, | 652 | # We should probably tell the user to use merge on the diverged branch, |
199 | 627 | # but how do we explan which branch they need to merge from! | 653 | # but how do we explan which branch they need to merge from! |
200 | 628 | 654 | ||
201 | 629 | 655 | ||
202 | === modified file 'tests/test_upload.py' | |||
203 | --- tests/test_upload.py 2009-10-05 09:31:11 +0000 | |||
204 | +++ tests/test_upload.py 2009-11-30 21:44:09 +0000 | |||
205 | @@ -1,4 +1,4 @@ | |||
207 | 1 | # Copyright (C) 2008 Canonical Ltd | 1 | # Copyright (C) 2008, 2009 Canonical Ltd |
208 | 2 | # | 2 | # |
209 | 3 | # This program is free software; you can redistribute it and/or modify | 3 | # This program is free software; you can redistribute it and/or modify |
210 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
211 | @@ -449,6 +449,26 @@ | |||
212 | 449 | self.assertUpFileEqual('baz', 'dir/goodbye') | 449 | self.assertUpFileEqual('baz', 'dir/goodbye') |
213 | 450 | self.assertUpFileEqual('foo', 'dir/hello') | 450 | self.assertUpFileEqual('foo', 'dir/hello') |
214 | 451 | 451 | ||
215 | 452 | def test_ignore_file(self): | ||
216 | 453 | self.make_branch_and_working_tree() | ||
217 | 454 | self.do_full_upload() | ||
218 | 455 | self.add_file('.bzrignore-upload','foo') | ||
219 | 456 | self.add_file('foo', 'bar') | ||
220 | 457 | |||
221 | 458 | self.do_upload() | ||
222 | 459 | |||
223 | 460 | self.failIfUpFileExists('foo') | ||
224 | 461 | |||
225 | 462 | def test_ignore_directory(self): | ||
226 | 463 | self.make_branch_and_working_tree() | ||
227 | 464 | self.do_full_upload() | ||
228 | 465 | self.add_file('.bzrignore-upload','dir') | ||
229 | 466 | self.add_dir('dir') | ||
230 | 467 | |||
231 | 468 | self.do_upload() | ||
232 | 469 | |||
233 | 470 | self.failIfUpFileExists('dir') | ||
234 | 471 | |||
235 | 452 | 472 | ||
236 | 453 | class TestFullUpload(tests.TestCaseWithTransport, TestUploadMixin): | 473 | class TestFullUpload(tests.TestCaseWithTransport, TestUploadMixin): |
237 | 454 | 474 |
This branch provides support for ignoring files specifically on upload, but not on versioning.
The file is .bzrignore-upload, and there is a test attached, I'm not sure how much to test as I'm re-using bzr's API (directories as well as files?).