mercurial/stack.py
changeset 37000 40583c7afd63
child 37004 68fcc5503ec5
equal deleted inserted replaced
36999:e349ad5cbb71 37000:40583c7afd63
       
     1 # stack.py - Mercurial functions for stack definition
       
     2 #
       
     3 #  Copyright Matt Mackall <mpm@selenic.com> and other
       
     4 #
       
     5 # This software may be used and distributed according to the terms of the
       
     6 # GNU General Public License version 2 or any later version.
       
     7 
       
     8 from __future__ import absolute_import
       
     9 
       
    10 from . import (
       
    11     revsetlang,
       
    12     scmutil,
       
    13 )
       
    14 
       
    15 def getstack(repo, rev=None):
       
    16     """return a smartrev of the stack containing either rev if it is not None
       
    17     or the current working directory parent.
       
    18 
       
    19     The stack will always contain all drafts changesets which are ancestors to
       
    20     the revision and are not merges.
       
    21     """
       
    22     if rev is None:
       
    23         rev = '.'
       
    24 
       
    25     revspec = 'reverse(only(%s) and not public() and not ::merge())'
       
    26     revset = revsetlang.formatspec(revspec, rev)
       
    27     return scmutil.revrange(repo, [revset])