Merge lp:~abentley/launchpad/fix-rewrite into lp:launchpad/db-devel

Proposed by Aaron Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/fix-rewrite
Merge into: lp:launchpad/db-devel
Diff against target: 36 lines (+14/-1)
2 files modified
lib/lp/codehosting/rewrite.py (+1/-1)
lib/lp/codehosting/tests/test_rewrite.py (+13/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/fix-rewrite
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Paul Hummer (community) code Approve
Review via email: mp+14498@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

= Summary =
Fix the branch-rewrite script's cache.

== Proposed fix ==
This patch fixes the "trailing path" portion of
_getBranchIdAndTrailingPath so that it has a leading slash, whether it
comes from cached data or not.

== Pre-implementation notes ==
Patch was discussed by flacoste and mwhudson, and has been cowboyed into
production, where it solved the problem.

== Implementation details ==
None

== Tests ==

== Demo and Q/A ==

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/codehosting/tests/test_rewrite.py
  lib/lp/codehosting/rewrite.py

== Pylint notices ==

lib/lp/codehosting/tests/test_rewrite.py
    129: [C0301] Line too long (81/78)
    146: [C0301] Line too long (81/78)

********** *END ENCRYPTED or SIGNED PART* **********

# Bazaar merge directive format 2 (Bazaar 0.90)

Revision history for this message
Aaron Bentley (abentley) wrote :

Forgot to note the test:
./bin/test test_rewrite -t getBranchIdAndTrailingPath

Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/codehosting/rewrite.py'
2--- lib/lp/codehosting/rewrite.py 2009-10-20 21:52:50 +0000
3+++ lib/lp/codehosting/rewrite.py 2009-11-05 20:35:30 +0000
4@@ -52,7 +52,7 @@
5 branch_id, inserted_time = self._cache[first]
6 if (self._now() < inserted_time +
7 config.codehosting.branch_rewrite_cache_lifetime):
8- return branch_id, second, "HIT"
9+ return branch_id, '/' + second, "HIT"
10 branch_id, trailing = getUtility(IBranchLookup).getIdAndTrailingPath(
11 location, from_slave=True)
12 if branch_id is None:
13
14=== modified file 'lib/lp/codehosting/tests/test_rewrite.py'
15--- lib/lp/codehosting/tests/test_rewrite.py 2009-07-23 23:59:29 +0000
16+++ lib/lp/codehosting/tests/test_rewrite.py 2009-11-05 20:35:30 +0000
17@@ -151,6 +151,19 @@
18 logging_output_lines[-1]),
19 "No miss found in %r" % logging_output_lines[-1])
20
21+ def test_getBranchIdAndTrailingPath_cached(self):
22+ """When results come from cache, they should be the same."""
23+ rewriter = self.makeRewriter()
24+ branch = self.factory.makeAnyBranch()
25+ transaction.commit()
26+ id_path = (branch.id, u'/.bzr/README',)
27+ result = rewriter._getBranchIdAndTrailingPath(
28+ '/' + branch.unique_name + '/.bzr/README')
29+ self.assertEqual(id_path + ('MISS',), result)
30+ result = rewriter._getBranchIdAndTrailingPath(
31+ '/' + branch.unique_name + '/.bzr/README')
32+ self.assertEqual(id_path + ('HIT',), result)
33+
34
35 class TestBranchRewriterScript(TestCaseWithFactory):
36 """Acceptance test for the branch-rewrite.py script."""

Subscribers

People subscribed via source and target branches

to status/vote changes: