[MERGE] test-progress-bars

John A Meinel john at arbash-meinel.com
Tue May 9 16:04:26 BST 2006


Robert Collins wrote:
> http://people.ubuntu.com/~robertc/baz2.0/test-pb has an updated, and now
> working correctly, selftest using progress bars.
> 
> Diff attached against .dev.
> 
> The output looks like:
> --------------------
>  ./bzr selftest
> running tests...
>        bzr: /home/robertc/source/baz/test-pb/bzr
>     bzrlib: /home/robertc/source/baz/test-pb/bzrlib
> 
> /home/robertc/source/baz/test-pb/bzrlib/transport/ftp.py:411: UserWarning: There are no FTP transport provider tests yet.
>   warn("There are no FTP transport provider tests yet.")
> [========================                             ] ..._detection 1039/2321TODO for merging: create a corrupted knit.
> [===================================================  ] ....test_body 2241/2321/home/robertc/.bazaar/plugins/email/tests/testemail.py:88: DeprecationWarning: bzrlib.branch.initialize was deprecated in version 0.8.
>   self.branch = Branch.initialize('.')
> /home/robertc/.bazaar/plugins/email/tests/testemail.py:89: DeprecationWarning: bzrlib.branch.BzrBranch5.working_tree was deprecated in version 0.8.
>   self.branch.working_tree().commit('foo bar baz\nfuzzy\rwuzzy', rev_id='A',
> [=====================================================] ..._two_hunks 2305/23211 out of 1 hunk FAILED -- saving rejects to file test_file.rej
> [=====================================================] OK            2321/2321
> ----------------------------------------------------------------------
> Ran 2321 tests in 308.639s
> 
> OK
> ------------------
> 
> The multiple lines are due to 'test stipple' - output being generated by
> comments output to stdout during the test suite. We shouldn't have any
> of this, so its a good prompt to fix them.
> 
> selftest -v operates unaltered with this patch, so when you care for
> checking specific tests you can still do that.
> 
> What do you all think? I find this much nicer than no output or dots,
> because it marks how far the progress has to go.
> 
>  branch.py                       |   20 ----
>  progress.py                     |    7 +
>  revision.py                     |   45 ----------
>  tests/__init__.py               |  166 ++++++++++++++++++++++++++++++--------
>  tests/blackbox/__init__.py      |   22 ++++-
>  tests/blackbox/test_selftest.py |   19 ++++
>  tests/test_revision.py          |   44 ----------
>  tests/test_selftest.py          |  171 ++++++++++++++++++++++++++++++++++++----
>  tests/test_transactions.py      |   14 ---
>  trace.py                        |   15 ++-
>  ui/text.py                      |   14 ++-
>  11 files changed, 352 insertions(+), 185 deletions(-)
> 
> 
> Rob.
> 
> 
> ------------------------------------------------------------------------
> 
> === modified file 'bzrlib/branch.py'
> --- bzrlib/branch.py	
> +++ bzrlib/branch.py	
> @@ -52,7 +52,6 @@
>  from bzrlib.tree import EmptyTree, RevisionTree
>  from bzrlib.repository import Repository
>  from bzrlib.revision import (
> -                             get_intervening_revisions,
>                               is_ancestor,
>                               NULL_REVISION,
>                               Revision,
> @@ -1098,25 +1097,6 @@
>          finally:
>              other.unlock()
>  
> -    @deprecated_method(zero_eight)
> -    def pullable_revisions(self, other, stop_revision):
> -        """Please use bzrlib.missing instead."""
> -        other_revno = other.revision_id_to_revno(stop_revision)
> -        try:
> -            return self.missing_revisions(other, other_revno)
> -        except DivergedBranches, e:
> -            try:
> -                pullable_revs = get_intervening_revisions(self.last_revision(),
> -                                                          stop_revision, 
> -                                                          self.repository)
> -                assert self.last_revision() not in pullable_revs
> -                return pullable_revs
> -            except bzrlib.errors.NotAncestor:
> -                if is_ancestor(self.last_revision(), stop_revision, self):
> -                    return []
> -                else:
> -                    raise e
> -        
>      def basis_tree(self):
>          """See Branch.basis_tree."""
>          return self.repository.revision_tree(self.last_revision())
> 

This doesn't seem associated with your other changes. I'm not opposed to
removing deprecated functions now that 0.8 is out. But it shouldn't
really be part of a "Use progress bars" function.


> === modified file 'bzrlib/progress.py'
> --- bzrlib/progress.py	
> +++ bzrlib/progress.py	
> @@ -285,7 +285,6 @@
>          self.last_update = now
>          return False
>          
> -
>      def tick(self):
>          self.update(self.last_msg, self.last_cnt, self.last_total, 
>                      self.child_fraction)
> @@ -303,10 +302,14 @@
>              self.last_msg = ''
>          self.tick()
>  
> -
>      def update(self, msg, current_cnt=None, total_cnt=None, 
>                 child_fraction=0):
>          """Update and redraw progress bar."""
> +        if msg is None:
> +            msg = self.last_msg
> +
> +        if total_cnt is None:
> +            total_cnt = self.last_total
>  
>          if current_cnt < 0:
>              current_cnt = 0
> 
> === modified file 'bzrlib/revision.py'
> --- bzrlib/revision.py	
> +++ bzrlib/revision.py	
> @@ -399,48 +399,3 @@
>      def unlock(self):
>          for source in self._revision_sources:
>              source.unlock()
> -
> -
> - at deprecated_method(zero_eight)
> -def get_intervening_revisions(ancestor_id, rev_id, rev_source, 
> -                              revision_history=None):
> -    """Find the longest line of descent from maybe_ancestor to revision.
> -    Revision history is followed where possible.
> -
> -    If ancestor_id == rev_id, list will be empty.
> -    Otherwise, rev_id will be the last entry.  ancestor_id will never appear.
> -    If ancestor_id is not an ancestor, NotAncestor will be thrown
> -    """
> -    root, ancestors, descendants = revision_graph(rev_id, rev_source)
> -    if len(descendants) == 0:
> -        raise NoSuchRevision(rev_source, rev_id)
> -    if ancestor_id not in descendants:
> -        rev_source.get_revision(ancestor_id)
> -        raise bzrlib.errors.NotAncestor(rev_id, ancestor_id)
> -    root_descendants = all_descendants(descendants, ancestor_id)
> -    root_descendants.add(ancestor_id)
> -    if rev_id not in root_descendants:
> -        raise bzrlib.errors.NotAncestor(rev_id, ancestor_id)
> -    distances = node_distances(descendants, ancestors, ancestor_id,
> -                               root_descendants=root_descendants)
> -
> -    def best_ancestor(rev_id):
> -        best = None
> -        for anc_id in ancestors[rev_id]:
> -            try:
> -                distance = distances[anc_id]
> -            except KeyError:
> -                continue
> -            if revision_history is not None and anc_id in revision_history:
> -                return anc_id
> -            elif best is None or distance > best[1]:
> -                best = (anc_id, distance)
> -        return best[0]
> -
> -    next = rev_id
> -    path = []
> -    while next != ancestor_id:
> -        path.append(next)
> -        next = best_ancestor(next)
> -    path.reverse()
> -    return path
> 

Same thing with this change.


> === modified file 'bzrlib/tests/__init__.py'
> --- bzrlib/tests/__init__.py	
> +++ bzrlib/tests/__init__.py	
> @@ -52,6 +52,7 @@
>  import bzrlib.osutils
>  import bzrlib.osutils as osutils
>  import bzrlib.plugin
> +import bzrlib.progress as progress
>  from bzrlib.revision import common_ancestor
>  import bzrlib.store
>  import bzrlib.trace
> @@ -113,9 +114,32 @@
>      Shows output in a different format, including displaying runtime for tests.
>      """
>      stop_early = False
> +    
> +    def __init__(self, stream, descriptions, verbosity, pb=None):
> +        unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
> +        self.pb = pb
>  
>      def _elapsedTime(self):
>          return "%5dms" % (1000 * (time.time() - self._start_time))
> +
> +    def _ellipsise_unimportant_words(self, a_string, final_width,
> +                                   keep_start=False):
> +        """Add ellipsese (sp?) for overly long strings.
> +        

I believe it is an 'ellipsis'

> +        :param keep_start: If true preserve the start of a_string rather
> +                           than the end of it.
> +        """

...

I'm +1 on the patch and using progress bars. -0 on mixing patch concepts.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060509/fe6e5073/attachment.pgp 


More information about the bazaar mailing list