Ticket #14144: trac_14144-branch.patch

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

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1361118472 28800
    # Node ID e4fefeefab9e0f8152380b258a55e2330310dadc
    # Parent  5cae291c1c4401bca5b2a879db68c2c2f5851dfc
    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  
    390390        self.init_inspector()
    391391        self.init_line_transforms()
    392392        self.register_interface_magics()
     393        self.init_print_branch()
    393394
    394395        # right now, the shutdown hook calling quit_sage() doesn't
    395396        # work when we run doctests that involve creating test shells.
     
    494495        if sys.path[0]!='':
    495496            sys.path.insert(0, '')
    496497
     498    def init_print_branch(self):
     499        """
     500        Print the Mercurial branch, unless it's 'main'.
     501        """
     502        branch = sage.misc.misc.branch_current_hg_notice(sage.misc.misc.branch_current_hg())
     503        if branch:
     504            print branch
     505
    497506# from http://stackoverflow.com/questions/4103773/efficient-way-of-having-a-function-only-execute-once-in-a-loop
    498507from functools import wraps
    499508def run_once(f):