Exemplo n.º 1
0
def pager():
    """
    Return a page program, which is either cat or less at present.
    
    Return cat if embedded in the notebook, and less otherwise.
    """
    if embedded():
        return 'cat'
    else:
        return 'less'
Exemplo n.º 2
0
def pager():
    """
    Return a page program, which is either cat or less at present.
    
    Return cat if embedded in the notebook, and less otherwise.
    """
    if embedded():
        return 'cat'
    else:
        return 'less'
Exemplo n.º 3
0
    def commit(self, files='', comment=None, options='', diff=True):
        r"""
        Commit your changes to the repository.
        
        Quit out of the editor without saving to not record your changes.
        
        INPUT:
        
        - ``files`` - space separated string of file names (optional)
          If specified only those files are commited. The path must be
          absolute or relative to self.dir().
        
        - ``comment`` - optional changeset comment. If you don't give
           it you will be dumped into an editor. If you're using the
           Sage notebook, you *must* specify a comment.
        
        - ``options`` - string::

              -A --addremove  mark new/missing files as added/removed before committing
              -m --message    use <text> as commit message
              -l --logfile    read the commit message from <file>
              -d --date       record datecode as commit date
              -u --user       record user as commiter
              -I --include    include names matching the given patterns
              -X --exclude    exclude names matching the given patterns
        
        - ``diff`` - (default: True) if True show diffs between your repository
          and your working repository before recording changes.
        
        .. note::

           If you create new files you should first add them with the
           add method.
        """
        if embedded() and comment is None:
            raise RuntimeError, "You're using the SAGE notebook, so you *must* explicitly specify the comment in the commit command."
        if diff:
            self.diff(files)

        if isinstance(files, (list, tuple)):
            files = ' '.join([str(x) for x in files])
            
        if comment:
            self('commit %s -m "%s" %s '%(options, comment, files))
        else:
            self('commit %s %s'%(options, files))
Exemplo n.º 4
0
    def commit(self, files='', comment=None, options='', diff=True):
        r"""
        Commit your changes to the repository.
        
        Quit out of the editor without saving to not record your changes.
        
        INPUT:
        
        - ``files`` - space separated string of file names (optional)
          If specified only those files are commited. The path must be
          absolute or relative to self.dir().
        
        - ``comment`` - optional changeset comment. If you don't give
           it you will be dumped into an editor. If you're using the
           Sage notebook, you *must* specify a comment.
        
        - ``options`` - string::

              -A --addremove  mark new/missing files as added/removed before committing
              -m --message    use <text> as commit message
              -l --logfile    read the commit message from <file>
              -d --date       record datecode as commit date
              -u --user       record user as commiter
              -I --include    include names matching the given patterns
              -X --exclude    exclude names matching the given patterns
        
        - ``diff`` - (default: True) if True show diffs between your repository
          and your working repository before recording changes.
        
        .. note::

           If you create new files you should first add them with the
           add method.
        """
        if embedded() and comment is None:
            raise RuntimeError, "You're using the SAGE notebook, so you *must* explicitly specify the comment in the commit command."
        if diff:
            self.diff(files)

        if isinstance(files, (list, tuple)):
            files = ' '.join([str(x) for x in files])
            
        if comment:
            self('commit %s -m "%s" %s '%(options, comment, files))
        else:
            self('commit %s %s'%(options, files))
Exemplo n.º 5
0
 def log(self, branches=None, keyword=None, limit=None,
               rev=None, merges=True, only_merges=False,
               patch=None, template=False, include=None,
               exclude=None, verbose=False):
     """
     Display the change log for this repository. This is a list of
     changesets ordered by revision number.
     
     By default this command outputs: changeset id and hash, tags,
     non-trivial parents, user, date and time, and a summary for each
     commit.
     
     INPUT:
     
     
     -  ``branches`` - (string, default: None) show given
        branches
     
     -  ``keyword`` - (string, default: None) search for a
        keyword
     
     -  ``limit`` - (integer, default: None, or 20 in
        notebook mdoe) limit number of changes displayed
     
     -  ``rev`` - (integer) show the specified revision
     
     -  ``merges`` - (bool, default: True) whether or not
        to show merges
     
     -  ``only_merges`` - (bool, default: False) if true,
        show only merges
     
     -  ``patch`` - (string, default: None) show given
        patch
     
     -  ``template`` - (string, default: None) display with
        template
     
     -  ``include`` - (string, default: None) include names
        matching the given patterns
     
     -  ``exclude`` - (string, default: None) exclude names
        matching the given patterns
     
     -  ``verbose`` - (bool, default: False) If true, the
        list of changed files and full commit message is shown.
     """
     if embedded() and limit is None:
         limit = 20
     options = ''
     if branches:
         options += '-b %s '%branches
     if keyword:
         options += '-k "%s" '%keyword
     if limit:
         options += '-l %s '%limit
     if rev:
         options += '-r %s '%rev
     if not merges:
         options += '--no-merges '
     if only_merges:
         options += '-m '
     if patch:
         options += '-p "%s"'%patch
     if template:
         options += '--template'
     if include:
         options += '-I "%s"'%include
     if exclude:
         options += '-X "%s"'%exclude
     if verbose:
         options = '-v ' + options
         
     self('log %s | %s'%(options, pager()))
Exemplo n.º 6
0
 def log(self, branches=None, keyword=None, limit=None,
               rev=None, merges=True, only_merges=False,
               patch=None, template=False, include=None,
               exclude=None, verbose=False):
     """
     Display the change log for this repository. This is a list of
     changesets ordered by revision number.
     
     By default this command outputs: changeset id and hash, tags,
     non-trivial parents, user, date and time, and a summary for each
     commit.
     
     INPUT:
     
     
     -  ``branches`` - (string, default: None) show given
        branches
     
     -  ``keyword`` - (string, default: None) search for a
        keyword
     
     -  ``limit`` - (integer, default: None, or 20 in
        notebook mdoe) limit number of changes displayed
     
     -  ``rev`` - (integer) show the specified revision
     
     -  ``merges`` - (bool, default: True) whether or not
        to show merges
     
     -  ``only_merges`` - (bool, default: False) if true,
        show only merges
     
     -  ``patch`` - (string, default: None) show given
        patch
     
     -  ``template`` - (string, default: None) display with
        template
     
     -  ``include`` - (string, default: None) include names
        matching the given patterns
     
     -  ``exclude`` - (string, default: None) exclude names
        matching the given patterns
     
     -  ``verbose`` - (bool, default: False) If true, the
        list of changed files and full commit message is shown.
     """
     if embedded() and limit is None:
         limit = 20
     options = ''
     if branches:
         options += '-b %s '%branches
     if keyword:
         options += '-k "%s" '%keyword
     if limit:
         options += '-l %s '%limit
     if rev:
         options += '-r %s '%rev
     if not merges:
         options += '--no-merges '
     if only_merges:
         options += '-m '
     if patch:
         options += '-p "%s"'%patch
     if template:
         options += '--template'
     if include:
         options += '-I "%s"'%include
     if exclude:
         options += '-X "%s"'%exclude
     if verbose:
         options = '-v ' + options
         
     self('log %s | %s'%(options, pager()))