[PATCH 2 of 2 evolve-ext] evolve: add a --list flag to the evolve command
Laurent Charignon
lcharignon at fb.com
Fri Aug 7 04:28:44 CDT 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1438936589 25200
# Fri Aug 07 01:36:29 2015 -0700
# Node ID 03116d88098c586c685d8c3de01769d1b60ffd9f
# Parent de3c2a7d18f02eacf45dc7948c8fe4898a040d66
evolve: add a --list flag to the evolve command
Before this patch, it was complicated to understand all the troubles affecting
a repository. This patch adds a --list flag to the evolve command displaying
all the troubles in the repository. It can be used with the --bumped,
--divergent and --unstable flag to restrict what is to be displayed.
Example output (truncated to simplify):
18 unstable changesets:
- [24312] record: add option to reverse chunks selection
- [24313] record: ui change for chunk reversal
...
11 divergent changesets:
- [25685] Fast smartlog
- base [25113] Fast smartlog
- others [26324] Fast smartlog
- [26324] Fast smartlog
- base [25113] Fast smartlog
- others [25685] Fast smartlog
- [26779] experimental: add set per phase in C phase computation
(!) Base not found, case not handled
- [26808] Fast smartlog
- base [26414] Fast smartlog
- others [26837] revset: add a C implementation for revsbetween
...
1 bumped changesets:
- [12] add obsol_d'''
- precs [11] add obsol_d''
diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1458,6 +1458,46 @@ def _selectrevs(repo, allopt, revopt, an
revs = set([repo['.'].rev()])
return revs
+def printtroubledetails(ui, repo, rev, category):
+ templates = { 'node': "- %s" % shorttemplate,
+ 'base': " - base %s" % shorttemplate,
+ 'others': " - others %s" % shorttemplate,
+ 'precs': " - precs %s" % shorttemplate}
+ displayers = dict((name, cmdutil.show_changeset(ui, repo, {'template': t}))
+ for (name, t) in templates.items())
+
+ ctx = repo[rev]
+ displayers['node'].show(ctx)
+
+ if category == "divergent":
+ try:
+ base, others = divergentdata(ctx)
+ displayers['base'].show(base)
+ for other in others:
+ displayers['others'].show(other)
+ except error.Abort:
+ ui.status(" (!) Base not found, case not handled\n")
+ elif category == "bumped":
+ precs = repo.set('last(allprecursors(%d) and public())', ctx)
+ for prec in precs:
+ displayers['precs'].show(prec)
+
+def listtroublebycategory(ui, repo, category):
+ revs = repo.revs(category+'()')
+ if revs:
+ ui.status("%d %s changesets:\n" % (len(revs), category))
+ for rev in revs:
+ printtroubledetails(ui, repo, rev, category)
+ else:
+ ui.status("No %s changesets\n" % category)
+
+def listtroubles(ui, repo, troublecategories):
+ if len(troublecategories) == 0:
+ troublestodisplay = ['unstable','divergent','bumped']
+ else:
+ troublestodisplay = troublecategories
+ for category in troublestodisplay:
+ listtroublebycategory(ui, repo, category)
def _orderrevs(repo, revs):
"""Compute an ordering to solve instability for the given revs
@@ -1507,6 +1547,7 @@ def _orderrevs(repo, revs):
('a', 'all', False, 'evolve all troubled changesets related to the current '
'working directory and its descendants'),
('c', 'continue', False, 'continue an interrupted evolution'),
+ ('l', 'list', False, 'list all the troubled changesets in the repository'),
] + mergetoolopts,
_('[OPTIONS]...'))
def evolve(ui, repo, **opts):
@@ -1542,9 +1583,14 @@ def evolve(ui, repo, **opts):
category using --all --any.
The working directory is updated to the newly created revision.
+
+ You can also use the evolve command to list the troubles affecting your
+ repository by using the --list flag. You can choose to display only some
+ categories of troubles with the --unstable, --divergent or --bumped flags.
"""
# Options
+ listopt = opts['list']
contopt = opts['continue']
anyopt = opts['any']
allopt = opts['all']
@@ -1554,6 +1600,9 @@ def evolve(ui, repo, **opts):
revopt = opts['rev']
troublecategories = ['unstable', 'divergent', 'bumped']
specifiedcategories = [t for t in troublecategories if opts[t]]
+ if listopt:
+ listtroubles(ui, repo, specifiedcategories)
+ return
targetcat = 'unstable'
if 1 < len(specifiedcategories):
msg = _('cannot specify more than one trouble category to solve (yet)')
diff --git a/tests/test-evolve-order.t b/tests/test-evolve-order.t
--- a/tests/test-evolve-order.t
+++ b/tests/test-evolve-order.t
@@ -57,6 +57,12 @@ Initial setup
|/
o 0:f92638be10c7 at default(public) add p
+ $ hg evolve --list
+ 2 unstable changesets:
+ - [2] add _b
+ - [3] add _c
+ No divergent changesets
+ No bumped changesets
evolve --rev reorders the rev to solve instability, trivial case 2 revs wrong order
$ hg evolve --rev 'desc(_c) + desc(_b)'
@@ -251,6 +257,14 @@ Test multiple revision with some un-evol
$ hg prune -s 'desc(c3part2)' 'desc(c3_)'
1 changesets pruned
2 new divergent changesets
+ $ hg evolve --list --divergent
+ 2 divergent changesets:
+ - [33] add c3part1
+ - base [31] add c3_
+ - others [34] add c3part2
+ - [34] add c3part2
+ - base [31] add c3_
+ - others [33] add c3part1
$ hg up 'desc(b3prime)'
2 files updated, 0 files merged, 3 files removed, 0 files unresolved
$ hg amend -m 'b3second'
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -560,6 +560,12 @@ check bumped detection
$ cd local
$ hg phase --hidden --public 11
1 new bumped changesets
+ $ hg evolve --list
+ No unstable changesets
+ No divergent changesets
+ 1 bumped changesets:
+ - [12] add obsol_d'''
+ - precs [11] add obsol_d''
$ hg log -G --template='{rev} - ({phase}) {node|short} {desc}\n'
@ 12 - (draft) 6db5e282cb91 add obsol_d'''
|
diff --git a/tests/test-tutorial.t b/tests/test-tutorial.t
--- a/tests/test-tutorial.t
+++ b/tests/test-tutorial.t
@@ -821,8 +821,9 @@ is neither dead or obsolete. My reposit
o 7e82d3f3c2cb (public): Monthy Python Shopping list
- $ hg log -r 'unstable()'
- 99f039c5ec9e (draft): SPAM SPAM SPAM
+ $ hg evolve --list --unstable
+ 1 unstable changesets:
+ - [17] SPAM SPAM SPAM
$ hg evolve
move:[17] SPAM SPAM SPAM
More information about the Mercurial-devel
mailing list