[MERGE][#144421] Fix `bzr st -rbranch:PATH_TO_BRANCH`

Aaron Bentley aaron at aaronbentley.com
Sat Sep 20 22:02:32 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Lukáš,

Lukáš Lalinský wrote:
> * Add RevisionSpec.as_tree which returns a tree representation of the
> revision specifier. This might return a remote revision tree.
> * Make status use this new method and not require
> RevisionSpec.as_revision_id, which for RevisionSpec_branch fetches data
> to the local repository.

I had my own reasons for wanting an as_tree method, but I didn't realise
this case would also be fixed.

> === modified file 'bzrlib/builtins.py'
> --- bzrlib/builtins.py	2008-08-23 18:54:47 +0000
> +++ bzrlib/builtins.py	2008-08-28 13:41:15 +0000
> @@ -67,6 +67,23 @@
>                                       (e.path, file_list[0]))
>  
>  
> +def _get_revision_tree(command_name, revision, branch=None, tree=None):

I think it would be clearer to call this '_get_one_revision_tree'.
Also, 'revision_specs' or even 'revisions' would be clearer than 'revision'.

> @@ -1836,11 +1852,8 @@
>              relpath = u''
>          elif relpath:
>              relpath += '/'
> -        if revision is not None:
> -            tree = branch.repository.revision_tree(
> -                revision[0].as_revision_id(branch))
> -        elif tree is None:
> -            tree = branch.basis_tree()
> +        if revision is not None or tree is None:
> +            tree = _get_revision_tree('ls', revision, branch=branch)

This kind of logic is very common, and it makes me think that there
should be a _get_one_tree (not revision_tree) function.

e.g.
def _get_one_tree(revisions, branch, tree)
    if revisions is None:
        if tree is not None:
            return tree
        return branch.basis_tree()
    else:
        return revision.as_revision_tree(branch)

> === modified file 'bzrlib/revisionspec.py'
> --- bzrlib/revisionspec.py	2008-07-19 15:00:27 +0000
> +++ bzrlib/revisionspec.py	2008-08-28 13:41:15 +0000
> @@ -252,6 +252,25 @@
>          """
>          return self.in_history(context_branch).rev_id
>  
> +    def as_tree(self, context_branch):
> +        """Return the tree object for this revisions spec.
> +
> +        Some revision specs require a context_branch to be able to determine
> +        the revision id and access the repository. Not all specs will make
> +        use of it.
> +        """

It would be nice if, as well as 'context_branch', an optional
'context_tree' could be supplied.

We have a reserved revision-id 'current:' that is meant to mean the
current working tree, so this would allow us to support it in revision
specs.  It would also provide the option of retrieving revision trees
from the working tree, which can improve performance.

> === modified file 'bzrlib/tests/blackbox/test_annotate.py'
> --- bzrlib/tests/blackbox/test_annotate.py	2007-12-29 18:55:20 +0000
> +++ bzrlib/tests/blackbox/test_annotate.py	2008-08-28 13:41:15 +0000
> @@ -144,7 +144,7 @@
>                                  retcode=3)
>          self.assertEqual('', out)
>          self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
> -                         ' exactly 1 argument\n',
> +                         ' exactly one revision identifier\n',
>                           err)
>  
>      def test_annotate_empty_file(self):
> 
> === modified file 'bzrlib/tests/blackbox/test_ls.py'
> --- bzrlib/tests/blackbox/test_ls.py	2008-05-02 00:48:17 +0000
> +++ bzrlib/tests/blackbox/test_ls.py	2008-08-28 13:41:15 +0000
> @@ -181,6 +181,7 @@
>          os.chdir('subdir')
>          self.ls_equals('', '--revision 1')
>  
> +
>      def test_ls_branch(self):
>          """If a branch is specified, files are listed from it"""
>          self.build_tree(['subdir/', 'subdir/b'])

^^^ There should be only one blank line, according to PEP8.

> === modified file 'bzrlib/tests/blackbox/test_status.py'
> --- bzrlib/tests/blackbox/test_status.py	2008-08-16 22:28:01 +0000
> +++ bzrlib/tests/blackbox/test_status.py	2008-08-28 13:41:15 +0000
> @@ -298,6 +298,21 @@
>          self.assertEqual("working tree is out of date, run 'bzr update'\n",
>                           err)
>  
> +    def test_status_write_lock(self):
> +        """That that status works without fetching history and
> +        having a write lock.
> +
> +        See https://bugs.launchpad.net/bzr/+bug/149270
> +        """
> +        mkdir('branch1')
> +        wt = self.make_branch_and_tree('branch1')

^^^ mkdir is redundant with make_branch_and_tree

> +        b = wt.branch
> +        wt.commit('Empty commit 1')
> +        wt2 = b.bzrdir.sprout('branch2').open_workingtree()
> +        wt2.commit('Empty commit 2', allow_pointless=True)

^^^ allow_pointless defaults to True.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI1WTn0F+nu1YWqI0RAvTEAJ932osMLR6J4awQI3/IIBbN0ZAp2ACeIocA
NB+lZjRsaIC/Or9DtFcchns=
=ssnU
-----END PGP SIGNATURE-----



More information about the bazaar mailing list