[RFC] implementation of revno:N:branch revisionspec (and general remark about diff implementation)
Matthieu Moy
Matthieu.Moy at imag.fr
Sun May 28 19:14:43 BST 2006
Hi,
I finally found time to give my old feature request for a
revno:N:branch revision specifier a try. Following is a patch
implementing it. It doesn't have a testcase yet, but seems to work for
me, and still passes "bzr selftest".
Any comments are welcome.
To use it, for example,
$ bzr diff -r \
revno:1:http://bazaar-vcs.org/bzr/bzr.dev/..revno:2:http://bazaar-vcs.org/bzr/bzr.dev/
will give you the diff between revision 1 and revision 2 of bzr's
upstream, downloading only the necessary files, and without requiring
any working tree or local branch.
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -1052,6 +1052,8 @@
# FIXME diff those two files. rbc 20051123
raise BzrCommandError("Files are in different
branches")
file_list = None
+ except NotBranchError:
+ tree1, tree2 = None, None
if revision is not None:
if tree2 is not None:
raise BzrCommandError("Can't specify -r with two
branches")
=== modified file 'bzrlib/diff.py'
--- bzrlib/diff.py
+++ bzrlib/diff.py
@@ -219,8 +219,13 @@
import sys
output = sys.stdout
def spec_tree(spec):
- revision_id = spec.in_store(tree.branch).rev_id
- return tree.branch.repository.revision_tree(revision_id)
+ if tree:
+ revision = spec.in_store(tree.branch)
+ else:
+ revision = spec.in_store(None)
+ revision_id = revision.rev_id
+ branch = revision.branch
+ return branch.repository.revision_tree(revision_id)
if old_revision_spec is None:
old_tree = tree.basis_tree()
else:
=== modified file 'bzrlib/revisionspec.py'
--- bzrlib/revisionspec.py
+++ bzrlib/revisionspec.py
@@ -149,7 +149,10 @@
raise NoSuchRevision(branch, str(self.spec))
def in_history(self, branch):
- revs = branch.revision_history()
+ if branch:
+ revs = branch.revision_history()
+ else:
+ revs = None
return self._match_on_and_check(branch, revs)
# FIXME: in_history is somewhat broken,
@@ -190,10 +193,21 @@
def _match_on(self, branch, revs):
"""Lookup a revision by revision number"""
- try:
- return RevisionInfo(branch, int(self.spec))
- except ValueError:
- return RevisionInfo(branch, None)
+ if self.spec.find(':') == -1:
+ try:
+ return RevisionInfo(branch, int(self.spec))
+ except ValueError:
+ return RevisionInfo(branch, None)
+ else:
+ from branch import Branch
+ revname = self.spec[self.spec.find(':')+1:]
+ other_branch = Branch.open_containing(revname)[0]
+ try:
+ revno = int(self.spec[:self.spec.find(':')])
+ except ValueError:
+ return RevisionInfo(other_branch, None)
+ revid = other_branch.get_rev_id(revno)
+ return RevisionInfo(other_branch, revno)
SPEC_TYPES.append(RevisionSpec_revno)
--
Matthieu
More information about the bazaar
mailing list