[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master

2023-01-30 Thread Otto Co-Pilot
The proposal to merge ~cjwatson/launchpad:stricter-branch-getByPath into 
launchpad:master has been updated.

Status: Approved => Needs review

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/436457
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master

2023-01-30 Thread Colin Watson
The proposal to merge ~cjwatson/launchpad:stricter-branch-getByPath into 
launchpad:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/436457
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master

2023-01-27 Thread Jelmer Vernooij
Review: Approve

Thanks for the quick fix!
-- 
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/436457
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master

2023-01-27 Thread Colin Watson
Colin Watson has proposed merging ~cjwatson/launchpad:stricter-branch-getByPath 
into launchpad:master.

Commit message:
Make BranchSet.getByPath forbid paths with suffixes

Requested reviews:
  Jelmer Vernooij (jelmer)
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2003950 in Launchpad itself: "brz branch  partially ignores 
the location path when using the lp: shorthand"
  https://bugs.launchpad.net/launchpad/+bug/2003950

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/436457

It previously accepted suffixes and discarded them.  This stricter approach is 
consistent with how `GitRepositorySet.getByPath` works, and it makes things 
easier for Breezy (which already walks up the path structure until it finds a 
match, but we were deceiving it by returning inexact matches).  It's also a 
better match to the existing API documentation, which didn't mention anything 
about accepting suffixes.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:stricter-branch-getByPath into launchpad:master.
diff --git a/lib/lp/code/model/branchlookup.py b/lib/lp/code/model/branchlookup.py
index a0f..5c40120 100644
--- a/lib/lp/code/model/branchlookup.py
+++ b/lib/lp/code/model/branchlookup.py
@@ -410,7 +410,7 @@ class BranchLookup:
 def getByPath(self, path):
 """See `IBranchLookup`."""
 try:
-return self.getByLPPath(path)[0]
+branch, suffix = self.getByLPPath(path)
 except (
 CannotHaveLinkedBranch,
 InvalidNamespace,
@@ -424,6 +424,9 @@ class BranchLookup:
 NoLinkedBranch,
 ):
 return None
+if suffix:
+return None
+return branch
 
 def _getLinkedBranchAndPath(self, provided):
 """Get the linked branch for 'provided', and the bzr_path.
diff --git a/lib/lp/code/model/tests/test_branchlookup.py b/lib/lp/code/model/tests/test_branchlookup.py
index 206e540..6cf90c1 100644
--- a/lib/lp/code/model/tests/test_branchlookup.py
+++ b/lib/lp/code/model/tests/test_branchlookup.py
@@ -268,7 +268,10 @@ class TestGetByPath(TestGetByLPPath):
 self.assertIsNone(self.getByPath(path))
 
 def assertPath(self, expected_branch, expected_suffix, path):
-self.assertEqual(expected_branch, self.getByPath(path))
+if expected_suffix:
+self.assertIsNone(self.getByPath(path))
+else:
+self.assertEqual(expected_branch, self.getByPath(path))
 
 
 class TestGetByUrl(TestCaseWithFactory):
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp