bzr log -rX shows revision X even if X is not in branch

Bug #893509 reported by GuilhemBichot
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned

Bug Description

We have tens of code branches. If I want to know whether revid X is in branch Y, I do
>cd Y
>bzr log -rX
If this prints the revision, I conclude that X is in this branch. And many other colleagues do the same.

Today we discovered that if our branches are all hosted in a shared repository, this logic doesn't work:
>cd Y
>bzr log -rX
prints the revision even if X is NOT in the branch, as long as it's somewhere in the shared repository. In our case, X was only in another branch Z in the same repo.
This "lookup in the shared repo":
1) is contradicting "bzr help log" which says:
  "Purpose: Show historical log for a branch or subset of a branch."
(says "branch", not "repository")
2) leaves us with no command to determine whether X is in the branch, unless we resort to the full log, like
>bzr log | grep X
which is much slower and error-prone (commit comments may also contain revids, this happens, which could lead to false positives).

How to reproduce the problem: below I create a shared repo and two branches under it.

[T35 10:44 /tmp $]
bzr init-repo repo
Shared repository with trees (format: 2a)
Location:
  shared repository: repo
[T35 10:44 /tmp $]
cd repo/
[T35 10:44 /tmp/repo $]
bzr init v1
Created a repository tree (format: 2a)
Using shared repository: /tmp/repo/
[T35 10:45 /tmp/repo $]
cd v1
[T35 10:45 /tmp/repo/v1 $]
touch foo
[T35 10:45 /tmp/repo/v1 $]
bzr add .
adding foo
[T35 10:45 /tmp/repo/v1 $]
bzr commit -m1
Committing to: /tmp/repo/v1/
added foo
Committed revision 1.
[T35 10:45 /tmp/repo/v1 $]
cd ..
[T35 10:45 /tmp/repo $]
bzr branch v1 v2
Branched 1 revision.
[T35 10:45 /tmp/repo $]
cd v2
[T35 10:45 /tmp/repo/v2 $]
touch bar
[T35 10:45 /tmp/repo/v2 $]
bzr add .
adding bar
[T35 10:45 /tmp/repo/v2 $]
bzr commit -m2
Committing to: /tmp/repo/v2/
added bar
Committed revision 2.

# So what we have so far is: v1 ("version 1 of software") having revision 1, and v2 ("version 2") having revision 1 and 2.

[T35 10:45 /tmp/repo/v2 $]
bzr log
------------------------------------------------------------
revno: 2
revision-id: <email address hidden>
parent: <email address hidden>
committer: Guilhem Bichot <email address hidden>
branch nick: v2
timestamp: Tue 2011-11-22 10:45:26 +0100
message:
  2
------------------------------------------------------------
revno: 1
revision-id: <email address hidden>
committer: Guilhem Bichot <email address hidden>
branch nick: v1
timestamp: Tue 2011-11-22 10:45:09 +0100
message:
  1
[T35 10:45 /tmp/repo/v2 $]
cd ../v1
[T35 10:45 /tmp/repo/v1 $]
bzr log
------------------------------------------------------------
revno: 1
revision-id: <email address hidden>
committer: Guilhem Bichot <email address hidden>
branch nick: v1
timestamp: Tue 2011-11-22 10:45:09 +0100
message:
  1

# Now I want to see whether v1 contains revision 2:

[T35 10:45 /tmp/repo/v1 $]
bzr log -r revid:<email address hidden>
------------------------------------------------------------
revision-id: <email address hidden>
parent: <email address hidden>
committer: Guilhem Bichot <email address hidden>
branch nick: v2
timestamp: Tue 2011-11-22 10:45:26 +0100
message:
  2

Whereas v1 does NOT contain this revision, in fact.

Bazaar (bzr) 2.5.0dev3
  from bzr checkout /home/mysql_src/logiciels/bzr_versions/bzr.dev
    revision: 6237
    revid: <email address hidden>
    branch nick: bzr.dev

Revision history for this message
GuilhemBichot (guilhem-bichot) wrote :

Continuing with the example above, revision 2 shows up even after no branch has it anymore:
[T35 10:55 /tmp/repo/v2 $]
cd ..
[T35 10:55 /tmp/repo $]
cd v1
[T35 10:55 /tmp/repo/v1 $]
cd ..
[T35 10:55 /tmp/repo $]
rm -rf v2
Are you sure to want to rm these: '/tmp/repo/v2' ? [y/n]y
[T35 10:55 /tmp/repo $]
ls
v1

# So at this moment there is no branch containing this revision.

[T35 10:55 /tmp/repo $]
cd v1
[T35 10:55 /tmp/repo/v1 $]
bzr log -r revid:<email address hidden>
------------------------------------------------------------
revision-id: <email address hidden>
parent: <email address hidden>
committer: Guilhem Bichot <email address hidden>
branch nick: v2
timestamp: Tue 2011-11-22 10:45:26 +0100
message:
  2

But it still shows up above.

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

Hi Guilhem,

This is intentional behaviour. I don't think it's inconsistent with the help, because what you're basically saying when you specify -rX is "please show me the branch that has tip X".

You should be able to use "bzr missing" to find out if a branch hasn't been merged yet:

bzr missing --mine -d lp:mysql/feature-branch lp:mysql/trunk

That command will output any revisions that are in the feature-branch that haven't been merged into trunk yet.

Changed in bzr:
status: New → Incomplete
Revision history for this message
GuilhemBichot (guilhem-bichot) wrote :

Hello Jelmer.
I wonder whether "log -rX" means "show me the branch which has tip X". If I read "bzr help log", it says
"Purpose: Show historical log for a branch or subset of a branch."
So, "log -rX" should mean "show historical log for a branch or a subset of a branch, limited to revision X", shouldn't it?

Yes, "bzr missing" can be used to compare two branches; but sometimes I just want to know "does branch Y have the fix I made" and I know that this fix is revid X, so I do "cd Y; log -rX". If I have to resort to "bzr missing" for that, I need to first have a branch having my fix, and then do "missing" between it and X, and search the (possibly very long) output for my revid. "log -rX" provides a yes/no answer with no fuss. Except that it doesn't, because it looks into the repo.

If this cannot be changed, then clarifying the help text would be good. And, what is the command which can tell me whether revision X is in branch Y? I know of "revision-info", but I tried:
cd tmp;
bzr revision-info -rX some_remove_branch_over_bzr+ssh
and it failed:
bzr revision-info -r <email address hidden> my:trunk
bzr: ERROR: Not a branch: "/tmp/".

Whereas all I want to know is: does this remote branch have revision X... I thought "log -rX" would do it, but it looks into the repo.
I could download the branch and then do revision-info locally, but that could be a lot of download.

What I'm trying to show is that there could be reasons for "log -rX" to look into the branch and only into the branch. Maybe an option "log --only-in-branch" :-)

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Bazaar because there has been no activity for 60 days.]

Changed in bzr:
status: Incomplete → Expired
Revision history for this message
GuilhemBichot (guilhem-bichot) wrote :

please don't "expire" this bug, I had asked questions in the last post. Thanks.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Why not just use:

    bzr log -rX.. -l1

If X is in the history of the branch it will be displayed, if not an error message should be. Using 'X..' here forces log to search the branch history (since the missing Y in X..Y defaults to the branch tip). Using -l1 ensures you won't get excessive output if the revision is in your branch.

Revision history for this message
GuilhemBichot (guilhem-bichot) wrote :

Merci beaucoup Vincent! This is indeed a good workaround which does the trick.

I continue to think that "bzr help log" is contradicting the behaviour of "searching in the repository", and this help text should be amended.

For example, this in "bzr help log":
    log is bzr's default tool for exploring the history of a branch.
    The branch to use is taken from the first parameter. If no parameters
    are given, the branch containing the working directory is logged.

Reading this suggests that when I do:
  >cd some_branch; bzr log
I'm seeing the log of the branch containing the working directory - some_branch.
-r is described as filtering:
    Revision filtering:
      The -r option can be used to specify what revision or range of revisions
      to filter against.
If -r is filtering, then "bzr log -rX" should be a subset of "bzr log". Which it isn't: actually "bzr log" will show me the branch's log, and "bzr log -rX" will show me X which it isn't in the branch - it's not a subset.

If those are not documentation problems, then what are they...

Revision history for this message
Vincent Ladeuil (vila) wrote :

> I continue to think that "bzr help log" is contradicting the behaviour of "searching in the repository", and this help text should be amended.

Right, let's focus the bug on this then.

The fix could be as simple as what jelmer suggested:

> when you specify -rX is "please show me the branch that has tip X".

I don't think we should restrict log to the current branch and adding a
warning if the revision(s) displayed are not part of the branch history will
hurt performance (which is still not stellar for log).

> If -r is filtering, then "bzr log -rX" should be a subset of "bzr
  log". Which it isn't: actually "bzr log" will show me the branch's log,
  and "bzr log -rX" will show me X which it isn't in the branch - it's not a
  subset.

Should be addressed to.

Thanks for your patience Guilhem ;)

Changed in bzr:
importance: Undecided → Medium
status: Expired → Confirmed
tags: added: doc easy
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.