Ticket #14144: trac_14144-branch-nodoctest.patch

File trac_14144-branch-nodoctest.patch, 1.6 KB (added by jhpalmieri, 8 years ago)
  • sage/misc/sage_extension.py

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1361134419 28800
    # Node ID 8fe794689094a87515f1e59a732230dd443d9004
    # Parent  5d8c13e7b81a1e152855073f97a4d48ee97255d1
    Print Mercurial branch of Sage library on startup (unless it's 'main')
    
    diff --git a/sage/misc/sage_extension.py b/sage/misc/sage_extension.py
    a b  
    425425        self.init_inspector()
    426426        self.init_line_transforms()
    427427        self.register_interface_magics()
     428        self.init_print_branch()
    428429
    429430        # right now, the shutdown hook calling quit_sage() doesn't
    430431        # work when we run doctests that involve creating test shells.
     
    518519        preparser(True)
    519520
    520521
     522    def init_print_branch(self):
     523        """
     524        Print the Mercurial branch, unless it's 'main'.
     525
     526        That is, unless doctesting or unless the branch is 'main',
     527        print a message of the form 'Loading Sage library. Current
     528        Mercurial branch is: ', followed by the branch name.
     529
     530        Since this message is not printed during doctesting in order
     531        to avoid doctest failures elsewhere in the Sage library, we do
     532        not doctest this.
     533        """
     534        from sage.misc.misc import branch_current_hg_notice, branch_current_hg
     535        from sage.plot.plot import DOCTEST_MODE
     536        branch = branch_current_hg_notice(branch_current_hg())
     537        if (not DOCTEST_MODE) and branch:
     538            print branch
     539
    521540# from http://stackoverflow.com/questions/4103773/efficient-way-of-having-a-function-only-execute-once-in-a-loop
    522541from functools import wraps
    523542def run_once(f):