Merge lp:~gagern/bzr/log_branch_from_revspec into lp:bzr

Proposed by Martin von Gagern
Status: Work in progress
Proposed branch: lp:~gagern/bzr/log_branch_from_revspec
Merge into: lp:bzr
Diff against target: 34 lines (+14/-0)
2 files modified
bzrlib/builtins.py (+1/-0)
bzrlib/tests/blackbox/test_log.py (+13/-0)
To merge this branch: bzr merge lp:~gagern/bzr/log_branch_from_revspec
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+28544@code.launchpad.net

Commit message

Make the log command take its branch from the RevisionInfo.

Description of the change

This makes the bzr log builtin take the branch from the RevisionInfo, thereby allowing things like "bzr log -r -1:some/branch"

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Revision history for this message
John A Meinel (jameinel) wrote :

This is failing in PQM. With this traceback:
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/cleanup.py", line 134, in run_simple
    return _do_with_cleanups(
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/commands.py", line 1126, in ignore_pipe
    result = func(*args, **kwargs)
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/builtins.py", line 2364, in run
    b = rev1.branch
AttributeError: 'NoneType' object has no attribute 'branch'
------------

It would seem that plain 'bzr log' is failing because there is no start revision.

This would hint towards:
 if rev1 is not None:
   b = rev1.branch

Or something like that. You might also want to do:
  if rev1 is not None and rev1.branch is not None:
    b = rev1.branch

I also think we're supposed to do something about a 'has_branch()' check.

review: Needs Fixing

Unmerged revisions

5320. By Martin von Gagern

Merge branch from bug 149270.

That branch has already been approved, and the blackbox tests from both
branches would conflict. Now they can both be merged into bzr.dev.

5319. By Martin von Gagern

Make the log command take its branch from the RevisionInfo.

This allows bzr log to operate with dwim revspecs that provide their own
branch although RevisionSpec_dwim doesn't override get_branch. Therefore
things like the "bzr log -r -1:some/branch" now start to work, as ensured by
the test case.

They will still fail if the current dir doesn't have an associated bzr
branch, though, as it will still attempt to open a branch for the current
directory to be passed to the dwim revspec. In those cases, specifying the
prefix as in "-r revno:-1:some/branch" would be a possible workaround.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2010-06-17 08:53:15 +0000
3+++ bzrlib/builtins.py 2010-06-29 07:18:30 +0000
4@@ -2361,6 +2361,7 @@
5 b = dir.open_branch()
6 self.add_cleanup(b.lock_read().unlock)
7 rev1, rev2 = _get_revision_range(revision, b, self.name())
8+ b = rev1.branch
9
10 # Decide on the type of delta & diff filtering to use
11 # TODO: add an --all-files option to make this configurable & consistent
12
13=== modified file 'bzrlib/tests/blackbox/test_log.py'
14--- bzrlib/tests/blackbox/test_log.py 2010-06-25 08:01:24 +0000
15+++ bzrlib/tests/blackbox/test_log.py 2010-06-29 07:18:30 +0000
16@@ -171,6 +171,19 @@
17 [r.rev.revision_id
18 for r in self.get_captured_revisions()])
19
20+ def test_dwim_branch_revspec(self):
21+ foo = self.make_branch_and_tree('foo')
22+ bar = self.make_branch_and_tree('bar')
23+ self.build_tree(['foo/foo.txt', 'bar/bar.txt'])
24+ foo.add('foo.txt')
25+ bar.add('bar.txt')
26+ foo.commit(message='foo')
27+ bar.commit(message='bar')
28+ self.run_bzr('log -r 1:../bar', working_dir='foo')
29+ self.assertEqual([bar.branch.get_rev_id(1)],
30+ [r.rev.revision_id
31+ for r in self.get_captured_revisions()])
32+
33
34 class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):
35