Mercurial > hg
changeset 36954:efc4fb344c05
debug: add debugwhyunstable that explains instabilities
This is a port of evolve's feature of listing all unstable changesets in detail
(`hg evolve --list`).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 26 Feb 2018 20:44:01 +0800 |
parents | b9bbcf9ffac1 |
children | f21798a6bc20 |
files | mercurial/debugcommands.py mercurial/obsutil.py tests/test-completion.t tests/test-help.t tests/test-obsolete-divergent.t tests/test-obsolete.t |
diffstat | 6 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Tue Mar 13 20:34:38 2018 +0800 +++ b/mercurial/debugcommands.py Mon Feb 26 20:44:01 2018 +0800 @@ -2529,6 +2529,17 @@ line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '') ui.write("%s\n" % line.rstrip()) +@command('debugwhyunstable', [], _('REV')) +def debugwhyunstable(ui, repo, rev): + """explain instabilities of a changeset""" + for entry in obsutil.whyunstable(repo, repo[rev]): + dnodes = '' + if entry.get('divergentnodes'): + dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr()) + for ctx in entry['divergentnodes']) + ' ' + ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes, + entry['reason'], entry['node'])) + @command('debugwireargs', [('', 'three', '', 'three'), ('', 'four', '', 'four'),
--- a/mercurial/obsutil.py Tue Mar 13 20:34:38 2018 +0800 +++ b/mercurial/obsutil.py Mon Feb 26 20:44:01 2018 +0800 @@ -923,3 +923,55 @@ args = (changeid, firstsuccessors, remainingnumber) return filteredmsgtable['superseded_split_several'] % args + +def divergentsets(repo, ctx): + """Compute sets of commits divergent with a given one""" + cache = {} + base = {} + for n in allpredecessors(repo.obsstore, [ctx.node()]): + if n == ctx.node(): + # a node can't be a base for divergence with itself + continue + nsuccsets = successorssets(repo, n, cache) + for nsuccset in nsuccsets: + if ctx.node() in nsuccset: + # we are only interested in *other* successor sets + continue + if tuple(nsuccset) in base: + # we already know the latest base for this divergency + continue + base[tuple(nsuccset)] = n + return [{'divergentnodes': divset, 'commonpredecessor': b} + for divset, b in base.iteritems()] + +def whyunstable(repo, ctx): + result = [] + if ctx.orphan(): + for parent in ctx.parents(): + kind = None + if parent.orphan(): + kind = 'orphan' + elif parent.obsolete(): + kind = 'obsolete' + if kind is not None: + result.append({'instability': 'orphan', + 'reason': '%s parent' % kind, + 'node': parent.hex()}) + if ctx.phasedivergent(): + predecessors = allpredecessors(repo.obsstore, [ctx.node()], + ignoreflags=bumpedfix) + immutable = [repo[p] for p in predecessors + if p in repo and not repo[p].mutable()] + for predecessor in immutable: + result.append({'instability': 'phase-divergent', + 'reason': 'immutable predecessor', + 'node': predecessor.hex()}) + if ctx.contentdivergent(): + dsets = divergentsets(repo, ctx) + for dset in dsets: + divnodes = [repo[n] for n in dset['divergentnodes']] + result.append({'instability': 'content-divergent', + 'divergentnodes': divnodes, + 'reason': 'predecessor', + 'node': nodemod.hex(dset['commonpredecessor'])}) + return result
--- a/tests/test-completion.t Tue Mar 13 20:34:38 2018 +0800 +++ b/tests/test-completion.t Mon Feb 26 20:44:01 2018 +0800 @@ -122,6 +122,7 @@ debugupdatecaches debugupgraderepo debugwalk + debugwhyunstable debugwireargs debugwireproto @@ -306,6 +307,7 @@ debugupdatecaches: debugupgraderepo: optimize, run debugwalk: include, exclude + debugwhyunstable: debugwireargs: three, four, five, ssh, remotecmd, insecure debugwireproto: localssh, peer, noreadstderr, ssh, remotecmd, insecure files: rev, print0, include, exclude, template, subrepos
--- a/tests/test-help.t Tue Mar 13 20:34:38 2018 +0800 +++ b/tests/test-help.t Mon Feb 26 20:44:01 2018 +0800 @@ -985,6 +985,8 @@ debugupgraderepo upgrade a repository to use different features debugwalk show how files match on given patterns + debugwhyunstable + explain instabilities of a changeset debugwireargs (no help text available) debugwireproto
--- a/tests/test-obsolete-divergent.t Tue Mar 13 20:34:38 2018 +0800 +++ b/tests/test-obsolete-divergent.t Mon Feb 26 20:44:01 2018 +0800 @@ -717,3 +717,6 @@ a178212c3433c4e77b573f6011e29affb8aefa33 1a2a9b5b0030632400aa78e00388c20f99d3ec44 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'} a178212c3433c4e77b573f6011e29affb8aefa33 ad6478fb94ecec98b86daae98722865d494ac561 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'test', 'user': 'test'} ad6478fb94ecec98b86daae98722865d494ac561 70d5a63ca112acb3764bc1d7320ca90ea688d671 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'test', 'user': 'test'} + + $ hg debugwhyunstable 1a2a9b5b0030 + content-divergent: 70d5a63ca112acb3764bc1d7320ca90ea688d671 (draft) predecessor a178212c3433c4e77b573f6011e29affb8aefa33
--- a/tests/test-obsolete.t Tue Mar 13 20:34:38 2018 +0800 +++ b/tests/test-obsolete.t Mon Feb 26 20:44:01 2018 +0800 @@ -1033,6 +1033,12 @@ orphan: 2 changesets phase-divergent: 1 changesets +test debugwhyunstable output + + $ hg debugwhyunstable 50c51b361e60 + orphan: obsolete parent 3de5eca88c00aa039da7399a220f4a5221faa585 + phase-divergent: immutable predecessor 245bde4270cd1072a27757984f9cda8ba26f08ca + #if serve $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log