Mercurial > evolve
annotate hgext3rd/evolve/obshistory.py @ 3402:7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Previous patches removed any use of ctx in the function and we now just need the
cset description in the function. Let's pass that only. This will save couple
of calls of repo[node].
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 11 Jan 2018 18:07:09 +0530 |
parents | 43b7773e00ae |
children | b96568036837 |
rev | line source |
---|---|
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
1 # Code dedicated to display and exploration of the obsolescence history |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
2 # |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
3 # This module content aims at being upstreamed enventually. |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
4 # |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
5 # Copyright 2017 Octobus SAS <contact@octobus.net> |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
6 # |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
9 |
2522
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
10 import re |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
11 |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
12 from mercurial import ( |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
13 cmdutil, |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
14 commands, |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
15 error, |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
16 graphmod, |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
17 mdiff, |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
18 patch, |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
19 obsolete, |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
20 node as nodemod, |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
21 scmutil, |
3083
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
22 util, |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
23 ) |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
24 |
3092
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
25 try: |
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
26 from mercurial import obsutil |
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
27 obsutil.marker |
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
28 except ImportError: |
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
29 obsutil = None |
ef38b44c08cf
compat: handle version where obsutil is not available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3086
diff
changeset
|
30 |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
31 from mercurial.i18n import _ |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
32 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
33 from . import ( |
2693
f4b0351fa813
evolve: adapt to function migrate to obsutil
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2678
diff
changeset
|
34 compat, |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
35 exthelper, |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
36 ) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
37 |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
38 eh = exthelper.exthelper() |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
39 |
3080
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
40 # Config |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
41 efd = {'default': True} # pass a default value unless the config is registered |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
42 |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
43 @eh.extsetup |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
44 def enableeffectflags(ui): |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
45 item = (getattr(ui, '_knownconfig', {}) |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
46 .get('experimental', {}) |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
47 .get('evolution.effect-flags')) |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
48 if item is not None: |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
49 item.default = True |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
50 efd.clear() |
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
3071
diff
changeset
|
51 |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
52 @eh.command( |
2441
80b5fc054219
evolve: adding longer aliases for olog
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
2418
diff
changeset
|
53 'obslog|olog', |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
54 [('G', 'graph', True, _("show the revision DAG")), |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
55 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
56 ('a', 'all', False, _('show all related changesets, not only precursors')), |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
57 ('p', 'patch', False, _('show the patch between two obs versions')) |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
58 ] + commands.formatteropts, |
2416
23c0bef0b5d4
obshistory: rename the command to "olog"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2415
diff
changeset
|
59 _('hg olog [OPTION]... [REV]')) |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
60 def cmdobshistory(ui, repo, *revs, **opts): |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
61 """show the obsolescence history of the specified revisions. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
62 |
2418
4993d1812311
olog: document the default value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2416
diff
changeset
|
63 If no revision range is specified, we display the log for the current |
4993d1812311
olog: document the default value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2416
diff
changeset
|
64 working copy parent. |
4993d1812311
olog: document the default value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2416
diff
changeset
|
65 |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
66 By default this command prints the selected revisions and all its |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
67 precursors. For precursors pointing on existing revisions in the repository, |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
68 it will display revisions node id, revision number and the first line of the |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
69 description. For precursors pointing on non existing revisions in the |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
70 repository (that can happen when exchanging obsolescence-markers), display |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
71 only the node id. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
72 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
73 In both case, for each node, its obsolescence marker will be displayed with |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
74 the obsolescence operation (rewritten or pruned) in addition of the user and |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
75 date of the operation. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
76 |
2678
da2b3e5e4f69
docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2640
diff
changeset
|
77 The output is a graph by default but can deactivated with the option |
da2b3e5e4f69
docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2640
diff
changeset
|
78 '--no-graph'. |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
79 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
80 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete, |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
81 and '+' represents a fork where the changeset from the lines below is a |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
82 parent of the 'o' merge on the same line. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
83 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
84 Paths in the DAG are represented with '|', '/' and so forth. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
85 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
86 Returns 0 on success. |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
87 """ |
3067
1769a8c20a82
pager: add support to `hg obslog`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2957
diff
changeset
|
88 compat.startpager(ui, 'obslog') |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
89 revs = list(revs) + opts['rev'] |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
90 if not revs: |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
91 revs = ['.'] |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
92 revs = scmutil.revrange(repo, revs) |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
93 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
94 if opts['graph']: |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
95 return _debugobshistorygraph(ui, repo, revs, opts) |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
96 |
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
97 revs.reverse() |
2955
b899a94472fd
obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents:
2954
diff
changeset
|
98 _debugobshistoryrevs(ui, repo, revs, opts) |
2415
89a5dabbb43d
obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2411
diff
changeset
|
99 |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
100 class obsmarker_printer(cmdutil.changeset_printer): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
101 """show (available) information about a node |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
102 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
103 We display the node, description (if available) and various information |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
104 about obsolescence markers affecting it""" |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
105 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
106 def show(self, ctx, copies=None, matchfn=None, **props): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
107 if self.buffered: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
108 self.ui.pushbuffer(labeled=True) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
109 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
110 changenode = ctx.node() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
111 |
2956
bc9bc1778463
obslog: fix `--template` with `--graph` option
Alain Leufroy
parents:
2955
diff
changeset
|
112 _props = self.diffopts.copy() |
bc9bc1778463
obslog: fix `--template` with `--graph` option
Alain Leufroy
parents:
2955
diff
changeset
|
113 _props.update(props) |
bc9bc1778463
obslog: fix `--template` with `--graph` option
Alain Leufroy
parents:
2955
diff
changeset
|
114 fm = self.ui.formatter('debugobshistory', _props) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
115 _debugobshistorydisplaynode(fm, self.repo, changenode) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
116 |
2636
a788967aa800
obslog: clarify some sorting code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2635
diff
changeset
|
117 # Succs markers |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
118 succs = self.repo.obsstore.successors.get(changenode, ()) |
2636
a788967aa800
obslog: clarify some sorting code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2635
diff
changeset
|
119 succs = sorted(succs) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
120 |
2957 | 121 markerfm = fm.nested("markers") |
2636
a788967aa800
obslog: clarify some sorting code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2635
diff
changeset
|
122 for successor in succs: |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
123 _debugobshistorydisplaymarker(markerfm, successor, |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
124 ctx.node(), self.repo, self.diffopts) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
125 markerfm.end() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
126 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
127 markerfm.plain('\n') |
2955
b899a94472fd
obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents:
2954
diff
changeset
|
128 fm.end() |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
129 self.hunk[ctx.node()] = self.ui.popbuffer() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
130 else: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
131 ### graph output is buffered only |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
132 msg = 'cannot be used outside of the graphlog (yet)' |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
133 raise error.ProgrammingError(msg) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
134 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
135 def flush(self, ctx): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
136 ''' changeset_printer has some logic around buffering data |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
137 in self.headers that we don't use |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
138 ''' |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
139 pass |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
140 |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
141 def patchavailable(node, repo, marker): |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
142 if node not in repo: |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
143 return False, "context is not local" |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
144 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
145 successors = marker[1] |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
146 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
147 if len(successors) == 0: |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
148 return False, "no successors" |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
149 elif len(successors) > 1: |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
150 return False, "too many successors (%d)" % len(successors) |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
151 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
152 succ = successors[0] |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
153 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
154 if succ not in repo: |
3054
bc890c6c9b2f
obslog: spell out successor completely
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2957
diff
changeset
|
155 return False, "successor is unknown locally" |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
156 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
157 # Check that both node and succ have the same parents |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
158 nodep1, nodep2 = repo[node].p1(), repo[node].p2() |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
159 succp1, succp2 = repo[succ].p1(), repo[succ].p2() |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
160 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
161 if nodep1 != succp1 or nodep2 != succp2: |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
162 return False, "changesets rebased" |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
163 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
164 return True, succ |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
165 |
3402
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
166 def getmarkerdescriptionpatch(repo, basedesc, succdesc): |
2640
e278271d2391
obslog: add a comment about the final new line of descriptions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2639
diff
changeset
|
167 # description are stored without final new line, |
e278271d2391
obslog: add a comment about the final new line of descriptions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2639
diff
changeset
|
168 # add one to avoid ugly diff |
3402
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
169 basedesc += '\n' |
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
170 succdesc += '\n' |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
171 |
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
172 # fake file name |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
173 basename = "changeset-description" |
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
174 succname = "changeset-description" |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
175 |
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
176 d = mdiff.unidiff(basedesc, '', succdesc, '', basename, succname) |
2697
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
177 # mercurial 4.1 and before return the patch directly |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
178 if not isinstance(d, tuple): |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
179 patch = d |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
180 else: |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
181 uheaders, hunks = d |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
182 |
2697
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
183 # Copied from patch.diff |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
184 text = ''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
189fd9d6a405
obslog: handle patch generation for mercurial 4.1-
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2693
diff
changeset
|
185 patch = "\n".join(uheaders + [text]) |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
186 |
3399
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
187 return patch |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
188 |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
189 class missingchangectx(object): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
190 ''' a minimal object mimicking changectx for change contexts |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
191 references by obs markers but not available locally ''' |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
192 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
193 def __init__(self, repo, nodeid): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
194 self._repo = repo |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
195 self._node = nodeid |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
196 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
197 def node(self): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
198 return self._node |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
199 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
200 def obsolete(self): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
201 # If we don't have it locally, it's obsolete |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
202 return True |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
203 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
204 def cyclic(graph): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
205 """Return True if the directed graph has a cycle. |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
206 The graph must be represented as a dictionary mapping vertices to |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
207 iterables of neighbouring vertices. For example: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
208 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
209 >>> cyclic({1: (2,), 2: (3,), 3: (1,)}) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
210 True |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
211 >>> cyclic({1: (2,), 2: (3,), 3: (4,)}) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
212 False |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
213 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
214 Taken from: https://codereview.stackexchange.com/a/86067 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
215 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
216 """ |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
217 visited = set() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
218 o = object() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
219 path = [o] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
220 path_set = set(path) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
221 stack = [iter(graph)] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
222 while stack: |
2411
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
223 for v in sorted(stack[-1]): |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
224 if v in path_set: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
225 path_set.remove(o) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
226 return path_set |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
227 elif v not in visited: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
228 visited.add(v) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
229 path.append(v) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
230 path_set.add(v) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
231 stack.append(iter(graph.get(v, ()))) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
232 break |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
233 else: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
234 path_set.remove(path.pop()) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
235 stack.pop() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
236 return False |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
237 |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
238 def _obshistorywalker(repo, revs, walksuccessors=False): |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
239 """ Directly inspired by graphmod.dagwalker, |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
240 walk the obs marker tree and yield |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
241 (id, CHANGESET, ctx, [parentinfo]) tuples |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
242 """ |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
243 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
244 # Get the list of nodes and links between them |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
245 candidates, nodesucc, nodeprec = _obshistorywalker_links(repo, revs, walksuccessors) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
246 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
247 # Shown, set of nodes presents in items |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
248 shown = set() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
249 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
250 def isvalidcandidate(candidate): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
251 """ Function to filter candidates, check the candidate succ are |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
252 in shown set |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
253 """ |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
254 return nodesucc.get(candidate, set()).issubset(shown) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
255 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
256 # While we have some nodes to show |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
257 while candidates: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
258 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
259 # Filter out candidates, returns only nodes with all their successors |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
260 # already shown |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
261 validcandidates = filter(isvalidcandidate, candidates) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
262 |
2411
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
263 # If we likely have a cycle |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
264 if not validcandidates: |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
265 cycle = cyclic(nodesucc) |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
266 assert cycle |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
267 |
2411
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
268 # Then choose a random node from the cycle |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
269 breaknode = sorted(cycle)[0] |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
270 # And display it by force |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
271 repo.ui.debug('obs-cycle detected, forcing display of %s\n' |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
272 % nodemod.short(breaknode)) |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
273 validcandidates = [breaknode] |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
274 |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
275 # Display all valid candidates |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
276 for cand in sorted(validcandidates): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
277 # Remove candidate from candidates set |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
278 candidates.remove(cand) |
2411
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
279 # And remove it from nodesucc in case of future cycle detected |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
280 try: |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
281 del nodesucc[cand] |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
282 except KeyError: |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
283 pass |
bd937b7ce7d2
debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
284 |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
285 shown.add(cand) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
286 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
287 # Add the right changectx class |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
288 if cand in repo: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
289 changectx = repo[cand] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
290 else: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
291 changectx = missingchangectx(repo, cand) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
292 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
293 childrens = [(graphmod.PARENT, x) for x in nodeprec.get(cand, ())] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
294 yield (cand, 'M', changectx, childrens) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
295 |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
296 def _obshistorywalker_links(repo, revs, walksuccessors=False): |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
297 """ Iterate the obs history tree starting from revs, traversing |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
298 each revision precursors recursively. |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
299 If walksuccessors is True, also check that every successor has been |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
300 walked, which ends up walking on all connected obs markers. It helps |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
301 getting a better view with splits and divergences. |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
302 Return a tuple of: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
303 - The list of node crossed |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
304 - The dictionnary of each node successors, values are a set |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
305 - The dictionnary of each node precursors, values are a list |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
306 """ |
2840
dfad30be866c
context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents:
2832
diff
changeset
|
307 precursors = repo.obsstore.predecessors |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
308 successors = repo.obsstore.successors |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
309 nodec = repo.changelog.node |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
310 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
311 # Parents, set of parents nodes seen during walking the graph for node |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
312 nodesucc = dict() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
313 # Childrens |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
314 nodeprec = dict() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
315 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
316 nodes = [nodec(r) for r in revs] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
317 seen = set(nodes) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
318 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
319 # Iterate on each node |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
320 while nodes: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
321 node = nodes.pop() |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
322 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
323 precs = precursors.get(node, ()) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
324 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
325 nodeprec[node] = [] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
326 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
327 for prec in sorted(precs): |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
328 precnode = prec[0] |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
329 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
330 # Mark node as prec successor |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
331 nodesucc.setdefault(precnode, set()).add(node) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
332 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
333 # Mark precnode as node precursor |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
334 nodeprec[node].append(precnode) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
335 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
336 # Add prec for future processing if not node already processed |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
337 if precnode not in seen: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
338 seen.add(precnode) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
339 nodes.append(precnode) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
340 |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
341 # Also walk on successors if the option is enabled |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
342 if walksuccessors: |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
343 for successor in successors.get(node, ()): |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
344 for succnodeid in successor[1]: |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
345 if succnodeid not in seen: |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
346 seen.add(succnodeid) |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
347 nodes.append(succnodeid) |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
348 |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
349 return sorted(seen), nodesucc, nodeprec |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
350 |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
351 def _debugobshistorygraph(ui, repo, revs, opts): |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
352 matchfn = None |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
353 if opts.get('patch'): |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
354 matchfn = scmutil.matchall(repo) |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
355 |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
356 displayer = obsmarker_printer(ui, repo.unfiltered(), matchfn, opts, buffered=True) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
357 edges = graphmod.asciiedges |
2484
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
358 walker = _obshistorywalker(repo.unfiltered(), revs, opts.get('all', False)) |
262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Boris Feld <boris.feld@octobus.net>
parents:
2463
diff
changeset
|
359 cmdutil.displaygraph(ui, repo, walker, displayer, edges) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2406
diff
changeset
|
360 |
2955
b899a94472fd
obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents:
2954
diff
changeset
|
361 def _debugobshistoryrevs(ui, repo, revs, opts): |
2633
59e85fbb31b6
obslog: small renaming of _debugobshistorysingle
Boris Feld <boris.feld@octobus.net>
parents:
2610
diff
changeset
|
362 """ Display the obsolescence history for revset |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
363 """ |
2955
b899a94472fd
obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents:
2954
diff
changeset
|
364 fm = ui.formatter('debugobshistory', opts) |
2840
dfad30be866c
context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents:
2832
diff
changeset
|
365 precursors = repo.obsstore.predecessors |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
366 successors = repo.obsstore.successors |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
367 nodec = repo.changelog.node |
2635
9ab35c37b85a
obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents:
2634
diff
changeset
|
368 unfi = repo.unfiltered() |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
369 nodes = [nodec(r) for r in revs] |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
370 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
371 seen = set(nodes) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
372 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
373 while nodes: |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
374 ctxnode = nodes.pop() |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
375 |
2635
9ab35c37b85a
obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents:
2634
diff
changeset
|
376 _debugobshistorydisplaynode(fm, unfi, ctxnode) |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
377 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
378 succs = successors.get(ctxnode, ()) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
379 |
2957 | 380 markerfm = fm.nested("markers") |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
381 for successor in sorted(succs): |
2954 | 382 _debugobshistorydisplaymarker(markerfm, successor, ctxnode, unfi, opts) |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
383 markerfm.end() |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
384 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
385 precs = precursors.get(ctxnode, ()) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
386 for p in sorted(precs): |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
387 # Only show nodes once |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
388 if p[0] not in seen: |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
389 seen.add(p[0]) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
390 nodes.append(p[0]) |
2955
b899a94472fd
obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents:
2954
diff
changeset
|
391 fm.end() |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
392 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
393 def _debugobshistorydisplaynode(fm, repo, node): |
2635
9ab35c37b85a
obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents:
2634
diff
changeset
|
394 if node in repo: |
9ab35c37b85a
obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents:
2634
diff
changeset
|
395 _debugobshistorydisplayctx(fm, repo[node]) |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
396 else: |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
397 _debugobshistorydisplaymissingctx(fm, node) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
398 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
399 def _debugobshistorydisplayctx(fm, ctx): |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
400 shortdescription = ctx.description().splitlines()[0] |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
401 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
402 fm.startitem() |
2957 | 403 fm.write('node', '%s', str(ctx), |
2404
c07f752137f4
label: rename 'evolve.short_node' to 'evolve.node'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2403
diff
changeset
|
404 label="evolve.node") |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
405 fm.plain(' ') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
406 |
2957 | 407 fm.write('rev', '(%d)', int(ctx), |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
408 label="evolve.rev") |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
409 fm.plain(' ') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
410 |
2957 | 411 fm.write('shortdescription', '%s', shortdescription, |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
412 label="evolve.short_description") |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
413 fm.plain('\n') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
414 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
415 def _debugobshistorydisplaymissingctx(fm, nodewithoutctx): |
2406
31255706b591
obshistory: import 'node' as 'nodemod'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2404
diff
changeset
|
416 hexnode = nodemod.short(nodewithoutctx) |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
417 fm.startitem() |
2957 | 418 fm.write('node', '%s', hexnode, |
2404
c07f752137f4
label: rename 'evolve.short_node' to 'evolve.node'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2403
diff
changeset
|
419 label="evolve.node evolve.missing_change_ctx") |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
420 fm.plain('\n') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
421 |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
422 def _debugobshistorydisplaymarker(fm, marker, node, repo, opts): |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
423 succnodes = marker[1] |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
424 date = marker[4] |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
425 metadata = dict(marker[3]) |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
426 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
427 fm.startitem() |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
428 fm.plain(' ') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
429 |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
430 # Detect pruned revisions |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
431 if len(succnodes) == 0: |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
432 verb = 'pruned' |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
433 else: |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
434 verb = 'rewritten' |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
435 |
2957 | 436 fm.write('verb', '%s', verb, |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
437 label="evolve.verb") |
2453
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
438 |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
439 effectflag = metadata.get('ef1') |
2455
d93a50a9abf5
effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2454
diff
changeset
|
440 if effectflag is not None: |
d93a50a9abf5
effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2454
diff
changeset
|
441 try: |
d93a50a9abf5
effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2454
diff
changeset
|
442 effectflag = int(effectflag) |
d93a50a9abf5
effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2454
diff
changeset
|
443 except ValueError: |
d93a50a9abf5
effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2454
diff
changeset
|
444 effectflag = None |
2453
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
445 if effectflag: |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
446 effect = [] |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
447 |
2456
63be7982d593
effectflag: add a small comment to suggest improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2455
diff
changeset
|
448 # XXX should be a dict |
2453
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
449 if effectflag & DESCCHANGED: |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
450 effect.append('description') |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
451 if effectflag & METACHANGED: |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
452 effect.append('meta') |
2492
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
453 if effectflag & USERCHANGED: |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
454 effect.append('user') |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
455 if effectflag & DATECHANGED: |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
456 effect.append('date') |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
457 if effectflag & BRANCHCHANGED: |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
458 effect.append('branch') |
2453
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
459 if effectflag & PARENTCHANGED: |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
460 effect.append('parent') |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
461 if effectflag & DIFFCHANGED: |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
462 effect.append('content') |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
463 |
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
464 if effect: |
2957 | 465 fmteffect = fm.formatlist(effect, 'effect', sep=', ') |
466 fm.write('effect', '(%s)', fmteffect) | |
2453
ad08aedf25ac
obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents:
2450
diff
changeset
|
467 |
2832
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
468 if len(succnodes) > 0: |
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
469 fm.plain(' as ') |
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
470 |
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
471 shortsnodes = (nodemod.short(succnode) for succnode in sorted(succnodes)) |
2957 | 472 nodes = fm.formatlist(shortsnodes, 'succnodes', sep=', ') |
473 fm.write('succnodes', '%s', nodes, | |
2832
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
474 label="evolve.node") |
07b9fcf8b6d3
output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents:
2697
diff
changeset
|
475 |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
476 fm.plain(' by ') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
477 |
2957 | 478 fm.write('user', '%s', metadata['user'], |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
479 label="evolve.user") |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
480 fm.plain(' ') |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
481 |
2957 | 482 fm.write('date', '(%s)', fm.formatdate(date), |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
483 label="evolve.date") |
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
484 |
3214
9fe2b3fd7fc7
obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3181
diff
changeset
|
485 # initial support for showing note |
9fe2b3fd7fc7
obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3181
diff
changeset
|
486 if metadata.get('note'): |
9fe2b3fd7fc7
obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3181
diff
changeset
|
487 fm.plain('\n note: ') |
3223
73b4e84df0bd
obsnote: don't add '' to note while showing it in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3214
diff
changeset
|
488 fm.write('note', "%s", metadata['note'], label="evolve.note") |
3214
9fe2b3fd7fc7
obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3181
diff
changeset
|
489 |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
490 # Patch display |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
491 if opts.get('patch'): |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
492 _patchavailable = patchavailable(node, repo, marker) |
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
493 |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
494 if _patchavailable[0] is True: |
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
495 succ = _patchavailable[1] |
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
496 |
3402
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
497 basectx = repo[node] |
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
498 succctx = repo[succ] |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
499 # Description patch |
3402
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
500 descriptionpatch = getmarkerdescriptionpatch(repo, |
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
501 basectx.description(), |
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
502 succctx.description()) |
3399
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
503 |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
504 if descriptionpatch: |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
505 # add the diffheader |
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
506 diffheader = "diff -r %s -r %s changeset-description\n" % \ |
3402
7a322f58fee3
obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3401
diff
changeset
|
507 (basectx, succctx) |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
508 descriptionpatch = diffheader + descriptionpatch |
3399
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
509 |
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
510 def tolist(text): |
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
511 return [text] |
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
512 |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
513 fm.plain("\n") |
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
514 |
3399
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
515 for chunk, label in patch.difflabel(tolist, descriptionpatch): |
3400
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
516 chunk = chunk.strip('\t') |
6d345d7ca682
obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3399
diff
changeset
|
517 if chunk and chunk != '\n': |
3399
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
518 fm.plain(' ') |
4adf46158b9b
obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3398
diff
changeset
|
519 fm.write('desc-diff', '%s', chunk, label=label) |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
520 |
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
521 # Content patch |
3398
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
522 diffopts = patch.diffallopts(repo.ui, {}) |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
523 matchfn = scmutil.matchall(repo) |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
524 firstline = True |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
525 for chunk, label in patch.diffui(repo, node, succ, matchfn, |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
526 changes=None, opts=diffopts, |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
527 prefix='', relroot='', |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
528 hunksfilterfn=None): |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
529 if firstline: |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
530 fm.plain('\n') |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
531 firstline = False |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
532 if chunk and chunk != '\n': |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
533 fm.plain(' ') |
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
534 fm.write('patch', '%s', chunk, label=label) |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
535 else: |
3398
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
536 nopatch = " (No patch available, %s)" % _patchavailable[1] |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
537 fm.plain("\n") |
2639
a5d8062f55ba
obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents:
2638
diff
changeset
|
538 # TODO: should be in json too |
3398
d67e6080e11b
obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3223
diff
changeset
|
539 fm.plain(nopatch) |
2637
49f2741c4dd7
obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents:
2636
diff
changeset
|
540 |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
541 fm.plain("\n") |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
542 |
2454
400dbec0849c
effetflag: move the flag back with the test of the creation logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2453
diff
changeset
|
543 # logic around storing and using effect flags |
400dbec0849c
effetflag: move the flag back with the test of the creation logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2453
diff
changeset
|
544 DESCCHANGED = 1 << 0 # action changed the description |
2522
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
545 METACHANGED = 1 << 1 # action change the meta |
2454
400dbec0849c
effetflag: move the flag back with the test of the creation logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2453
diff
changeset
|
546 PARENTCHANGED = 1 << 2 # action change the parent |
400dbec0849c
effetflag: move the flag back with the test of the creation logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2453
diff
changeset
|
547 DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset |
2492
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
548 USERCHANGED = 1 << 4 # the user changed |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
549 DATECHANGED = 1 << 5 # the date changed |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
550 BRANCHCHANGED = 1 << 6 # the branch changed |
2454
400dbec0849c
effetflag: move the flag back with the test of the creation logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2453
diff
changeset
|
551 |
2522
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
552 METABLACKLIST = [ |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
553 re.compile('^__touch-noise__$'), |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
554 re.compile('^branch$'), |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
555 re.compile('^.*-source$'), |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
556 re.compile('^.*_source$'), |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
557 re.compile('^source$'), |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
558 ] |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
559 |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
560 def ismetablacklisted(metaitem): |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
561 """ Check that the key of a meta item (extrakey, extravalue) does not |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
562 match at least one of the blacklist pattern |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
563 """ |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
564 metakey = metaitem[0] |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
565 for pattern in METABLACKLIST: |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
566 if pattern.match(metakey): |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
567 return False |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
568 |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
569 return True |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
570 |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
571 def geteffectflag(relation): |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
572 """compute the effect flag by comparing the source and destination""" |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
573 effects = 0 |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
574 |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
575 source = relation[0] |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
576 |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
577 for changectx in relation[1]: |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
578 # Check if description has changed |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
579 if changectx.description() != source.description(): |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
580 effects |= DESCCHANGED |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
581 |
2448
66f05d5f4769
effectflag: detect meta changes
Boris Feld <boris.feld@octobus.net>
parents:
2446
diff
changeset
|
582 # Check if known meta has changed |
2492
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
583 if changectx.user() != source.user(): |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
584 effects |= USERCHANGED |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
585 |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
586 if changectx.date() != source.date(): |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
587 effects |= DATECHANGED |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
588 |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
589 if changectx.branch() != source.branch(): |
c9f1118b33d6
effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents:
2490
diff
changeset
|
590 effects |= BRANCHCHANGED |
2448
66f05d5f4769
effectflag: detect meta changes
Boris Feld <boris.feld@octobus.net>
parents:
2446
diff
changeset
|
591 |
2522
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
592 # Check if other meta has changed |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
593 changeextra = changectx.extra().items() |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
594 ctxmeta = filter(ismetablacklisted, changeextra) |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
595 |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
596 sourceextra = source.extra().items() |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
597 srcmeta = filter(ismetablacklisted, sourceextra) |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
598 |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
599 if ctxmeta != srcmeta: |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
600 effects |= METACHANGED |
a1cc2a0b9f6f
effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents:
2520
diff
changeset
|
601 |
2449
0b05142117d2
effectflag: detect parent change
Boris Feld <boris.feld@octobus.net>
parents:
2448
diff
changeset
|
602 # Check if at least one of the parent has changes |
0b05142117d2
effectflag: detect parent change
Boris Feld <boris.feld@octobus.net>
parents:
2448
diff
changeset
|
603 if changectx.parents() != source.parents(): |
0b05142117d2
effectflag: detect parent change
Boris Feld <boris.feld@octobus.net>
parents:
2448
diff
changeset
|
604 effects |= PARENTCHANGED |
0b05142117d2
effectflag: detect parent change
Boris Feld <boris.feld@octobus.net>
parents:
2448
diff
changeset
|
605 |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
606 if not _cmpdiff(source, changectx): |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
607 effects |= DIFFCHANGED |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
608 |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
609 return effects |
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
610 |
2520
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
611 def _prepare_hunk(hunk): |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
612 """Drop all information but the username and patch""" |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
613 cleanunk = [] |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
614 for line in hunk.splitlines(): |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
615 if line.startswith(b'# User') or not line.startswith(b'#'): |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
616 if line.startswith(b'@@'): |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
617 line = b'@@\n' |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
618 cleanunk.append(line) |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
619 return cleanunk |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
620 |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
621 def _getdifflines(iterdiff): |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
622 """return a cleaned up lines""" |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
623 try: |
2592
fb33d856d25e
compat: make obshistory._getdifflines compatible with mercurial 4.1
Boris Feld <boris.feld@octobus.net>
parents:
2591
diff
changeset
|
624 # XXX-COMPAT Mercurial 4.1 compat |
fb33d856d25e
compat: make obshistory._getdifflines compatible with mercurial 4.1
Boris Feld <boris.feld@octobus.net>
parents:
2591
diff
changeset
|
625 if isinstance(iterdiff, list) and len(iterdiff) == 0: |
fb33d856d25e
compat: make obshistory._getdifflines compatible with mercurial 4.1
Boris Feld <boris.feld@octobus.net>
parents:
2591
diff
changeset
|
626 return None |
2520
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
627 lines = iterdiff.next() |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
628 except StopIteration: |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
629 return None |
2520
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
630 return _prepare_hunk(lines) |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
631 |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
632 def _cmpdiff(leftctx, rightctx): |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
633 """return True if both ctx introduce the "same diff" |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
634 |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
635 This is a first and basic implementation, with many shortcoming. |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
636 """ |
2548
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
637 |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
638 # Leftctx or right ctx might be filtered, so we need to use the contexts |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
639 # with an unfiltered repository to safely compute the diff |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
640 leftunfi = leftctx._repo.unfiltered()[leftctx.rev()] |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
641 leftdiff = leftunfi.diff(git=1) |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
642 rightunfi = rightctx._repo.unfiltered()[rightctx.rev()] |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
643 rightdiff = rightunfi.diff(git=1) |
3fd4b0dca16c
effectflag: fix content change detection for filtered revs
Boris Feld <boris.feld@octobus.net>
parents:
2522
diff
changeset
|
644 |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
645 left, right = (0, 0) |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
646 while None not in (left, right): |
2520
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
647 left = _getdifflines(leftdiff) |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
648 right = _getdifflines(rightdiff) |
5fb5d096348c
effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents:
2492
diff
changeset
|
649 |
2450
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
650 if left != right: |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
651 return False |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
652 return True |
98613938d098
effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2449
diff
changeset
|
653 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
654 # Wrap pre Mercurial 4.4 createmarkers that didn't included effect-flag |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
655 if not util.safehasattr(obsutil, 'geteffectflag'): |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
656 @eh.wrapfunction(obsolete, 'createmarkers') |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
657 def createmarkerswithbits(orig, repo, relations, flag=0, date=None, |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
658 metadata=None, **kwargs): |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
659 """compute 'effect-flag' and augment the created markers |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
660 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
661 Wrap obsolete.createmarker in order to compute the effect of each |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
662 relationship and store them as flag in the metadata. |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
663 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
664 While we experiment, we store flag in a metadata field. This field is |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
665 "versionned" to easilly allow moving to other meaning for flags. |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
666 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
667 The comparison of description or other infos just before creating the obs |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
668 marker might induce overhead in some cases. However it is a good place to |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
669 start since it automatically makes all markers creation recording more |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
670 meaningful data. In the future, we can introduce way for commands to |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
671 provide precomputed effect to avoid the overhead. |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
672 """ |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
673 if not repo.ui.configbool('experimental', 'evolution.effect-flags', **efd): |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
674 return orig(repo, relations, flag, date, metadata, **kwargs) |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
675 if metadata is None: |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
676 metadata = {} |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
677 tr = repo.transaction('add-obsolescence-marker') |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
678 try: |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
679 for r in relations: |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
680 # Compute the effect flag for each obsmarker |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
681 effect = geteffectflag(r) |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
682 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
683 # Copy the metadata in order to add them, we copy because the |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
684 # effect flag might be different per relation |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
685 m = metadata.copy() |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
686 # we store the effect even if "0". This disctinct markers created |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
687 # without the feature with markers recording a no-op. |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
688 m['ef1'] = "%d" % effect |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
689 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
690 # And call obsolete.createmarkers for creating the obsmarker for real |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
691 orig(repo, [r], flag, date, m, **kwargs) |
2446
4b2f4da124a2
effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
2441
diff
changeset
|
692 |
3086
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
693 tr.close() |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
694 finally: |
611ac10f1fae
effect-flag: remove wrapping of createmarkers for Mercurial 4.4
Boris Feld <boris.feld@octobus.net>
parents:
3083
diff
changeset
|
695 tr.release() |
2488
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
696 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
697 def _getobsfate(successorssets): |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
698 """ Compute a changeset obsolescence fate based on his successorssets. |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
699 Successors can be the tipmost ones or the immediate ones. |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
700 Returns one fate in the following list: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
701 - pruned |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
702 - diverged |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
703 - superseed |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
704 - superseed_split |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
705 """ |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
706 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
707 if len(successorssets) == 0: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
708 # The commit has been pruned |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
709 return 'pruned' |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
710 elif len(successorssets) > 1: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
711 return 'diverged' |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
712 else: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
713 # No divergence, only one set of successors |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
714 successors = successorssets[0] |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
715 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
716 if len(successors) == 1: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
717 return 'superseed' |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
718 else: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
719 return 'superseed_split' |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
720 |
2490
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
721 def _getobsfateandsuccs(repo, revnode, successorssets=None): |
2488
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
722 """ Return a tuple containing: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
723 - the reason a revision is obsolete (diverged, pruned or superseed) |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
724 - the list of successors short node if the revision is neither pruned |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
725 or has diverged |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
726 """ |
2490
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
727 if successorssets is None: |
2693
f4b0351fa813
evolve: adapt to function migrate to obsutil
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2678
diff
changeset
|
728 successorssets = compat.successorssets(repo, revnode) |
2488
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
729 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
730 fate = _getobsfate(successorssets) |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
731 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
732 # Apply node.short if we have no divergence |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
733 if len(successorssets) == 1: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
734 successors = [nodemod.short(node_id) for node_id in successorssets[0]] |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
735 else: |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
736 successors = [] |
2490
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
737 for succset in successorssets: |
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
738 successors.append([nodemod.short(node_id) for node_id in succset]) |
2488
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
739 |
1bdbe8f55339
refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents:
2484
diff
changeset
|
740 return (fate, successors) |
2490
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
741 |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
742 def _successorsetdates(successorset, markers): |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
743 """returns the max date and the min date of the markers list |
2490
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
744 """ |
94f171534918
template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents:
2488
diff
changeset
|
745 |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
746 if not markers: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
747 return {} |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
748 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
749 dates = [m[4] for m in markers] |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
750 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
751 return { |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
752 'min_date': min(dates), |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
753 'max_date': max(dates) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
754 } |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
755 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
756 def _successorsetusers(successorset, markers): |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
757 """ Returns a sorted list of markers users without duplicates |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
758 """ |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
759 if not markers: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
760 return {} |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
761 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
762 # Check that user is present in meta |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
763 markersmeta = [dict(m[3]) for m in markers] |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
764 users = set(meta.get('user') for meta in markersmeta if meta.get('user')) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
765 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
766 return {'users': sorted(users)} |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
767 |
2896
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
768 VERBMAPPING = { |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
769 DESCCHANGED: "reworded", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
770 METACHANGED: "meta-changed", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
771 USERCHANGED: "reauthored", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
772 DATECHANGED: "date-changed", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
773 BRANCHCHANGED: "branch-changed", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
774 PARENTCHANGED: "rebased", |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
775 DIFFCHANGED: "amended" |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
776 } |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
777 |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
778 def _successorsetverb(successorset, markers): |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
779 """ Return the verb summarizing the successorset |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
780 """ |
2896
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
781 verb = None |
2606
02129bed002c
obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2604
diff
changeset
|
782 if not successorset: |
02129bed002c
obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2604
diff
changeset
|
783 verb = 'pruned' |
2607
054d92586e43
obsfate: use 'split' as verb when appropriate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2606
diff
changeset
|
784 elif len(successorset) == 1: |
2896
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
785 # Check for effect flag |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
786 |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
787 metadata = [dict(marker[3]) for marker in markers] |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
788 ef1 = [data.get('ef1') for data in metadata] |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
789 |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
790 if all(ef1): |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
791 combined = 0 |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
792 for ef in ef1: |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
793 combined |= int(ef) |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
794 |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
795 # Combined will be in VERBMAPPING only of one bit is set |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
796 if combined in VERBMAPPING: |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
797 verb = VERBMAPPING[combined] |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
798 |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
799 if verb is None: |
462adae9fea7
obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents:
2840
diff
changeset
|
800 verb = 'rewritten' |
2606
02129bed002c
obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2604
diff
changeset
|
801 else: |
2607
054d92586e43
obsfate: use 'split' as verb when appropriate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2606
diff
changeset
|
802 verb = 'split' |
2606
02129bed002c
obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2604
diff
changeset
|
803 return {'verb': verb} |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
804 |
3181
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
805 # Use a more advanced version of obsfateverb that uses effect-flag |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
806 if util.safehasattr(obsutil, 'obsfateverb'): |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
807 |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
808 @eh.wrapfunction(obsutil, 'obsfateverb') |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
809 def obsfateverb(orig, *args, **kwargs): |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
810 return _successorsetverb(*args, **kwargs)['verb'] |
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
811 |
3083
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
812 # Hijack callers of successorsetverb |
3181
5db76f35efce
effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents:
3115
diff
changeset
|
813 elif util.safehasattr(obsutil, 'obsfateprinter'): |
3083
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
814 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
815 @eh.wrapfunction(obsutil, 'obsfateprinter') |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
816 def obsfateprinter(orig, successors, markers, ui): |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
817 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
818 def closure(successors): |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
819 return _successorsetverb(successors, markers)['verb'] |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
820 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
821 if not util.safehasattr(obsutil, 'successorsetverb'): |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
822 return orig(successors, markers, ui) |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
823 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
824 # Save the old value |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
825 old = obsutil.successorsetverb |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
826 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
827 try: |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
828 # Replace by own |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
829 obsutil.successorsetverb = closure |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
830 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
831 # Call the orig |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
832 result = orig(successors, markers, ui) |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
833 |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
834 # And return result |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
835 return result |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
836 finally: |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
837 # Replace the old one |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
838 obsutil.successorsetverb = old |
e91ca8b5ecf7
obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
839 |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
840 FORMATSSETSFUNCTIONS = [ |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
841 _successorsetdates, |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
842 _successorsetusers, |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
843 _successorsetverb |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
844 ] |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
845 |
2609
81a94da65dca
obsfate: mark successorsetallmarkers public
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2608
diff
changeset
|
846 def successorsetallmarkers(successorset, pathscache): |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
847 """compute all successors of a successorset. |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
848 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
849 pathscache must contains all successors starting from selected nodes |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
850 or revision. This way, iterating on each successor, we can take all |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
851 precursors and have the subgraph of all obsmarkers between roots to |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
852 successors. |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
853 """ |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
854 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
855 markers = set() |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
856 seen = set() |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
857 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
858 for successor in successorset: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
859 stack = [successor] |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
860 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
861 while stack: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
862 element = stack.pop() |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
863 seen.add(element) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
864 for prec, mark in pathscache.get(element, []): |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
865 if prec not in seen: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
866 # Process element precursors |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
867 stack.append(prec) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
868 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
869 if mark not in markers: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
870 markers.add(mark) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
871 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
872 return markers |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
873 |
2610
ee37ab3de5f7
obsfate: split markers fetch from successor set annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2609
diff
changeset
|
874 def preparesuccessorset(successorset, rawmarkers): |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
875 """ For a successor set, get all related markers, compute the set of user, |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
876 the min date and the max date |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
877 """ |
2604
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
878 hex = nodemod.hex |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
879 |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
880 successorset = [hex(n) for n in successorset] |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
881 |
2604
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
882 # hex the binary nodes in the markers |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
883 markers = [] |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
884 for m in rawmarkers: |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
885 hexprec = hex(m[0]) |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
886 hexsucs = tuple(hex(n) for n in m[1]) |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
887 hexparents = None |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
888 if m[5] is not None: |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
889 hexparents = tuple(hex(n) for n in m[5]) |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
890 newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:] |
3bcc9d3bac33
template: use hex node in the obsmarkers used in the obsfate template
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2603
diff
changeset
|
891 markers.append(newmarker) |
2603
23f1c3b9052f
template: use hex successors in obsfate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2592
diff
changeset
|
892 |
2591
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
893 # Format basic data |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
894 data = { |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
895 "successors": sorted(successorset), |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
896 "markers": sorted(markers) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
897 } |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
898 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
899 # Call an extensible list of functions to override or add new data |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
900 for function in FORMATSSETSFUNCTIONS: |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
901 data.update(function(successorset, markers)) |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
902 |
1991935fb603
obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents:
2586
diff
changeset
|
903 return data |