Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/stack.py @ 37003:40583c7afd63
stack: add a new module for stack-related commands
Bootstrap the module with a function that returns the stack for the current
revision. The definition of the stack is ihnerited from histedit default
revset and used by hg show stack.
Differential Revision: https://phab.mercurial-scm.org/D2395
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 19 Jan 2018 15:25:06 +0100 |
parents | |
children | 68fcc5503ec5 |
comparison
equal
deleted
inserted
replaced
37002:e349ad5cbb71 | 37003: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]) |