hgext3rd/evolve/obshistory.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 15 Nov 2019 09:53:42 -0800
changeset 4952 b135591bec1a
parent 4951 7bfd3fed5d1f
child 4953 5c41bb482867
permissions -rw-r--r--
obslog: make {patch} not be indented and leave that to the template This removes some unwanted indentation from the tests. In the first case, it's because indent() doesn't indent a blank line. In the second case, it's because we used templating with {patch} and had not requested indentation (but we still got it before this patch). Note that tests will only pass with a very recent Mercurial (one with https://phab.mercurial-scm.org/D7432 applied).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 (
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    13
    commands,
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    14
    error,
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
    15
    graphmod,
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
    16
    patch,
3883
ed460e7ee8aa compat: drop compatibility hack for mercurial <4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3838
diff changeset
    17
    obsutil,
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    18
    node as nodemod,
4752
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
    19
    pycompat,
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    20
    scmutil,
3083
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
    21
    util,
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    22
)
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
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
    25
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    26
from . import (
2693
f4b0351fa813 evolve: adapt to function migrate to obsutil
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2678
diff changeset
    27
    compat,
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    28
    exthelper,
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
)
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
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
eh = exthelper.exthelper()
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    32
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    33
# Config
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
    34
efd = {b'default': True} # pass a default value unless the config is registered
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    35
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    36
@eh.extsetup
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    37
def enableeffectflags(ui):
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    38
    item = (getattr(ui, '_knownconfig', {})
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
    39
            .get(b'experimental', {})
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
    40
            .get(b'evolution.effect-flags'))
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    41
    if item is not None:
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    42
        item.default = True
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    43
        efd.clear()
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3071
diff changeset
    44
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    45
@eh.command(
4715
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    46
    b'obslog|olog',
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    47
    [(b'G', b'graph', True, _(b"show the revision DAG")),
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    48
     (b'r', b'rev', [], _(b'show the specified revision or revset'), _(b'REV')),
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    49
     (b'a', b'all', False, _(b'show all related changesets, not only precursors')),
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    50
     (b'p', b'patch', False, _(b'show the patch between two obs versions')),
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    51
     (b'f', b'filternonlocal', False, _(b'filter out non local commits')),
12c8b24757f4 py3: use byte strings for @command registrations
Martin von Zweigbergk <martinvonz@google.com>
parents: 4430
diff changeset
    52
     ] + commands.formatteropts,
4921
a7c01a2a3974 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 4918 4915
diff changeset
    53
    _(b'hg olog [OPTION]... [[-r] REV]...'),
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4827
diff changeset
    54
    **compat.helpcategorykwargs('CATEGORY_CHANGE_NAVIGATION'))
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    55
def cmdobshistory(ui, repo, *revs, **opts):
3454
56277182c029 obslog: drop period from summary line in accordance with convention
Martin von Zweigbergk <martinvonz@google.com>
parents: 3407
diff changeset
    56
    """show the obsolescence history of the specified revisions
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    57
2418
4993d1812311 olog: document the default value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2416
diff changeset
    58
    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
    59
    working copy parent.
4993d1812311 olog: document the default value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2416
diff changeset
    60
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    61
    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
    62
    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
    63
    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
    64
    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
    65
    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
    66
    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
    67
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    68
    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
    69
    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
    70
    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
    71
2678
da2b3e5e4f69 docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2640
diff changeset
    72
    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
    73
    '--no-graph'.
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    74
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    75
    '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
    76
    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
    77
    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
    78
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    79
    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
    80
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    81
    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
    82
    """
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
    83
    ui.pager(b'obslog')
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    84
    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
    85
    if not revs:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
    86
        revs = [b'.']
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    87
    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
    88
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    89
    # Use the default template unless the user provided one, but not if
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    90
    # -f was given, because that doesn't work with templates yet. Note
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    91
    # that --no-graph doesn't support -f (it ignores it), so we also
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    92
    # don't use templating with --no-graph.
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    93
    if not opts['template'] and not (opts['filternonlocal'] and opts['graph']):
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    94
        opts['template'] = DEFAULT_TEMPLATE
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
    95
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    96
    if opts['graph']:
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    97
        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
    98
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2411
diff changeset
    99
    revs.reverse()
2955
b899a94472fd obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents: 2954
diff changeset
   100
    _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
   101
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   102
def _successorsandmarkers(repo, ctx):
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   103
    """compute the raw data needed for computing obsfate
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   104
    Returns a list of dict, one dict per successors set
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   105
    """
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   106
    ssets = obsutil.successorssets(repo, ctx.node(), closest=True)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   107
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   108
    # closestsuccessors returns an empty list for pruned revisions, remap it
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   109
    # into a list containing an empty list for future processing
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   110
    if ssets == []:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   111
        ssets = [[]]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   112
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   113
    # Try to recover pruned markers
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   114
    succsmap = repo.obsstore.successors
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   115
    fullsuccessorsets = [] # successor set + markers
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   116
    for sset in ssets:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   117
        if sset:
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   118
            fullsuccessorsets.append(compat.wrap_succs(sset))
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   119
        else:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   120
            # successorsset return an empty set() when ctx or one of its
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   121
            # successors is pruned.
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   122
            # In this case, walk the obs-markers tree again starting with ctx
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   123
            # and find the relevant pruning obs-makers, the ones without
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   124
            # successors.
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   125
            # Having these markers allow us to compute some information about
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   126
            # its fate, like who pruned this changeset and when.
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   127
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   128
            # XXX we do not catch all prune markers (eg rewritten then pruned)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   129
            # (fix me later)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   130
            foundany = False
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   131
            for mark in succsmap.get(ctx.node(), ()):
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   132
                if not mark[1]:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   133
                    foundany = True
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   134
                    sset = compat._succs()
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   135
                    sset.markers.add(mark)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   136
                    fullsuccessorsets.append(sset)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   137
            if not foundany:
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   138
                fullsuccessorsets.append(compat._succs())
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   139
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   140
    values = []
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   141
    for sset in fullsuccessorsets:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   142
        values.append({b'successors': sset, b'markers': sset.markers})
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   143
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   144
    return values
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   145
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   146
TEMPLATE_MISSING_NODE = b"""{label("evolve.node evolve.missing_change_ctx", node)}"""
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   147
TEMPLATE_PRESENT_NODE = b"""{label("evolve.node", node)} {label("evolve.rev", "({rev})")} {label("evolve.short_description", desc|firstline)}"""
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   148
TEMPLATE_FIRST_LINE = b"""{if(rev, "%(presentnode)s", "%(missingnode)s")}""" % {
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   149
    b"presentnode": TEMPLATE_PRESENT_NODE,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   150
    b"missingnode": TEMPLATE_MISSING_NODE
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   151
}
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   152
TEMPLATE_VERB = b"""{label("evolve.verb", verb)}"""
4951
7bfd3fed5d1f obslog: make {succnodes} be full hex nodes
Martin von Zweigbergk <martinvonz@google.com>
parents: 4950
diff changeset
   153
TEMPLATE_SUCCNODES = b"""{label("evolve.node", join(succnodes % "{succnode|short}", ", "))}"""
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   154
TEMPLATE_REWRITE = b"""{if(succnodes, "%(verb)s{if(effects, "({join(effects, ", ")})")} as %(succnodes)s", "pruned")}""" % {
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   155
    b"verb": TEMPLATE_VERB,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   156
    b"succnodes": TEMPLATE_SUCCNODES
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   157
}
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   158
TEMPLATE_OPERATION = b"""{if(operation, "using {label("evolve.operation", operation)}")}"""
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   159
TEMPLATE_USER = b"""by {label("evolve.user", user)}"""
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   160
TEMPLATE_DATE = b"""{label("evolve.date", "({date(date, "%a %b %d %H:%M:%S %Y %1%2")})")}"""
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   161
TEMPLATE_NOTE = b"""{if(note, "\n    note: {label("evolve.note", note)}")}"""
4952
b135591bec1a obslog: make {patch} not be indented and leave that to the template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4951
diff changeset
   162
TEMPLATE_PATCH = b"""{if(patch, "{patch}")}{if(nopatchreason, "\n(No patch available, {nopatchreason})")}"""
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   163
DEFAULT_TEMPLATE = (b"""%(firstline)s
4952
b135591bec1a obslog: make {patch} not be indented and leave that to the template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4951
diff changeset
   164
{markers %% "  {separate(" ", "%(rewrite)s", "%(operation)s", "%(user)s", "%(date)s")}%(note)s{descdiff}{indent("%(patch)s", "    ")}\n"}
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   165
""") % {
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   166
    b"firstline": TEMPLATE_FIRST_LINE,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   167
    b"rewrite": TEMPLATE_REWRITE,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   168
    b"operation": TEMPLATE_OPERATION,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   169
    b"user": TEMPLATE_USER,
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   170
    b"date": TEMPLATE_DATE,
4952
b135591bec1a obslog: make {patch} not be indented and leave that to the template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4951
diff changeset
   171
    b"note": TEMPLATE_NOTE,
b135591bec1a obslog: make {patch} not be indented and leave that to the template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4951
diff changeset
   172
    b"patch": TEMPLATE_PATCH,
4949
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   173
}
eb9bcef7cc5f obslog: redefine default output as a template, unless -f was given
Martin von Zweigbergk <martinvonz@google.com>
parents: 4948
diff changeset
   174
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3407
diff changeset
   175
class obsmarker_printer(compat.changesetprinter):
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   176
    """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
   177
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   178
    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
   179
    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
   180
3921
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   181
    def __init__(self, ui, repo, *args, **kwargs):
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   182
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   183
        if kwargs.pop('obspatch', False):
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   184
            if compat.changesetdiffer is None:
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   185
                kwargs['matchfn'] = scmutil.matchall(repo)
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   186
            else:
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   187
                kwargs['differ'] = scmutil.matchall(repo)
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   188
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   189
        super(obsmarker_printer, self).__init__(ui, repo, *args, **kwargs)
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3884
diff changeset
   190
        diffopts = kwargs.get('diffopts', {})
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   191
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   192
        # Compat 4.6
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   193
        if not util.safehasattr(self, "_includediff"):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   194
            self._includediff = diffopts and diffopts.get(b'patch')
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   195
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   196
        self.template = diffopts and diffopts.get(b'template')
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   197
        self.filter = diffopts and diffopts.get(b'filternonlocal')
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   198
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   199
    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
   200
        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
   201
            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
   202
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   203
            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
   204
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   205
            _props = {b"template": self.template}
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   206
            fm = self.ui.formatter(b'debugobshistory', _props)
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   207
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   208
            _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
   209
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   210
            markerfm = fm.nested(b"markers")
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   211
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   212
            # Succs markers
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   213
            if self.filter is False:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   214
                succs = self.repo.obsstore.successors.get(changenode, ())
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   215
                succs = sorted(succs)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   216
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   217
                for successor in succs:
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   218
                    _debugobshistorydisplaymarker(self.ui, markerfm, successor,
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   219
                                                  ctx.node(), self.repo,
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   220
                                                  self._includediff)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   221
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   222
            else:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   223
                r = _successorsandmarkers(self.repo, ctx)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   224
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   225
                for succset in sorted(r):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   226
                    markers = succset[b"markers"]
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   227
                    if not markers:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   228
                        continue
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   229
                    successors = succset[b"successors"]
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   230
                    _debugobshistorydisplaysuccsandmarkers(self.ui, markerfm, successors, markers, ctx.node(), self.repo, self._includediff)
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   231
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   232
            markerfm.end()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   233
4940
93c89814a5d8 obslog: avoid using a formatter after calling end() on it
Martin von Zweigbergk <martinvonz@google.com>
parents: 4939
diff changeset
   234
            fm.plain(b'\n')
2955
b899a94472fd obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents: 2954
diff changeset
   235
            fm.end()
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   236
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   237
            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
   238
        else:
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   239
            ### graph output is buffered only
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   240
            msg = b'cannot be used outside of the graphlog (yet)'
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   241
            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
   242
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   243
    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
   244
        ''' 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
   245
        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
   246
        '''
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   247
        pass
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   248
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   249
def patchavailable(node, repo, successors):
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   250
    if node not in repo:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   251
        return False, b"context is not local"
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   252
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   253
    if len(successors) == 0:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   254
        return False, b"no successors"
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   255
    elif len(successors) > 1:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   256
        return False, b"too many successors (%d)" % len(successors)
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   257
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   258
    succ = successors[0]
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   259
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   260
    if succ not in repo:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   261
        return False, b"successor is unknown locally"
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   262
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   263
    # 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
   264
    nodep1, nodep2 = repo[node].p1(), repo[node].p2()
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   265
    succp1, succp2 = repo[succ].p1(), repo[succ].p2()
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   266
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   267
    if nodep1 != succp1 or nodep2 != succp2:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   268
        return False, b"changesets rebased"
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   269
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   270
    return True, succ
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   271
3402
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   272
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
   273
    # 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
   274
    # add one to avoid ugly diff
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   275
    basedesc += b'\n'
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   276
    succdesc += b'\n'
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   277
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   278
    # fake file name
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   279
    basename = b"changeset-description"
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   280
    succname = b"changeset-description"
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   281
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3484
diff changeset
   282
    d = compat.strdiff(basedesc, succdesc, basename, succname)
3604
d24ba168a532 obslog: cleanup patch handling after 4.1 compat drop
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3519
diff changeset
   283
    uheaders, hunks = d
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   284
3604
d24ba168a532 obslog: cleanup patch handling after 4.1 compat drop
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3519
diff changeset
   285
    # Copied from patch.diff
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   286
    text = b''.join(sum((list(hlines) for hrange, hlines in hunks), []))
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   287
    patch = b"\n".join(uheaders + [text])
3400
6d345d7ca682 obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3399
diff changeset
   288
3399
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   289
    return patch
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   290
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   291
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
   292
    ''' 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
   293
    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
   294
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   295
    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
   296
        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
   297
        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
   298
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   299
    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
   300
        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
   301
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   302
    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
   303
        # 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
   304
        return True
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   305
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   306
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
   307
    """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
   308
    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
   309
    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
   310
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   311
    >>> 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
   312
    True
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   313
    >>> 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
   314
    False
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
    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
   317
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
    visited = set()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   320
    o = object()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   321
    path = [o]
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   322
    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
   323
    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
   324
    while stack:
2411
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   325
        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
   326
            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
   327
                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
   328
                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
   329
            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
   330
                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
   331
                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
   332
                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
   333
                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
   334
                break
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   335
        else:
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   336
            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
   337
            stack.pop()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   338
    return False
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   339
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   340
def _obshistorywalker(repo, revs, walksuccessors=False, filternonlocal=False):
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   341
    """ 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
   342
    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
   343
    (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
   344
    """
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   345
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   346
    # 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
   347
    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
   348
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   349
    # 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
   350
    shown = set()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   351
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   352
    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
   353
        """ 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
   354
        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
   355
        """
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   356
        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
   357
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   358
    # 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
   359
    while candidates:
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   360
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   361
        # 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
   362
        # already shown
4741
e8727a27e380 py3: filter() now returns a generator, so wrap when we need a list
Martin von Zweigbergk <martinvonz@google.com>
parents: 4738
diff changeset
   363
        validcandidates = list(filter(isvalidcandidate, candidates))
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   364
2411
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   365
        # If we likely have a cycle
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   366
        if not validcandidates:
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   367
            cycle = cyclic(nodesucc)
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   368
            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
   369
2411
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   370
            # Then choose a random node from the cycle
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   371
            breaknode = sorted(cycle)[0]
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   372
            # And display it by force
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   373
            repo.ui.debug(b'obs-cycle detected, forcing display of %s\n'
2411
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   374
                          % nodemod.short(breaknode))
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   375
            validcandidates = [breaknode]
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   376
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   377
        # 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
   378
        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
   379
            # 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
   380
            candidates.remove(cand)
2411
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   381
            # 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
   382
            try:
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   383
                del nodesucc[cand]
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   384
            except KeyError:
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   385
                pass
bd937b7ce7d2 debugobshistory: handle multiple cycles
Boris Feld <boris.feld@octobus.net>
parents: 2407
diff changeset
   386
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   387
            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
   388
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   389
            # 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
   390
            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
   391
                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
   392
            else:
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   393
                if filternonlocal is False:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   394
                    changectx = missingchangectx(repo, cand)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   395
                else:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   396
                    continue
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   397
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   398
            if filternonlocal is False:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   399
                relations = nodeprec.get(cand, ())
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   400
            else:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   401
                relations = obsutil.closestpredecessors(repo, cand)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   402
            # print("RELATIONS", relations, list(closestpred))
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   403
            childrens = [(graphmod.PARENT, x) for x in relations]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   404
            # print("YIELD", changectx, childrens)
3728
0fc78fdca4b8 obshistory: use a more appropriate type for obslog entries
Anton Shestakov <av6@dwimlabs.net>
parents: 3701
diff changeset
   405
            yield (cand, graphmod.CHANGESET, changectx, childrens)
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   406
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
   407
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
   408
    """ 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
   409
    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
   410
    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
   411
    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
   412
    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
   413
    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
   414
    - 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
   415
    - 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
   416
    - 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
   417
    """
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2832
diff changeset
   418
    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
   419
    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
   420
    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
   421
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   422
    # 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
   423
    nodesucc = dict()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   424
    # Childrens
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   425
    nodeprec = dict()
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   426
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   427
    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
   428
    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
   429
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   430
    # 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
   431
    while nodes:
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   432
        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
   433
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   434
        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
   435
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   436
        nodeprec[node] = []
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   437
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   438
        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
   439
            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
   440
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   441
            # 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
   442
            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
   443
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   444
            # 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
   445
            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
   446
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   447
            # 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
   448
            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
   449
                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
   450
                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
   451
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
   452
        # 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
   453
        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
   454
            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
   455
                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
   456
                    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
   457
                        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
   458
                        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
   459
2407
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   460
    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
   461
783a74c60a5e obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2406
diff changeset
   462
def _debugobshistorygraph(ui, repo, revs, opts):
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   463
4752
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
   464
    displayer = obsmarker_printer(ui, repo.unfiltered(), obspatch=True,
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
   465
                                  diffopts=pycompat.byteskwargs(opts),
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
   466
                                  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
   467
    edges = graphmod.asciiedges
4752
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
   468
    walker = _obshistorywalker(repo.unfiltered(), revs, opts.get('all', False),
8a73a8df63b6 py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents: 4747
diff changeset
   469
                               opts.get('filternonlocal', False))
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3407
diff changeset
   470
    compat.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
   471
2955
b899a94472fd obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents: 2954
diff changeset
   472
def _debugobshistoryrevs(ui, repo, revs, opts):
2633
59e85fbb31b6 obslog: small renaming of _debugobshistorysingle
Boris Feld <boris.feld@octobus.net>
parents: 2610
diff changeset
   473
    """ Display the obsolescence history for revset
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   474
    """
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   475
    fm = ui.formatter(b'debugobshistory', pycompat.byteskwargs(opts))
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2832
diff changeset
   476
    precursors = repo.obsstore.predecessors
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   477
    successors = repo.obsstore.successors
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   478
    nodec = repo.changelog.node
2635
9ab35c37b85a obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents: 2634
diff changeset
   479
    unfi = repo.unfiltered()
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   480
    nodes = [nodec(r) for r in revs]
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   481
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   482
    seen = set(nodes)
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   483
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   484
    while nodes:
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   485
        ctxnode = nodes.pop()
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   486
2635
9ab35c37b85a obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents: 2634
diff changeset
   487
        _debugobshistorydisplaynode(fm, unfi, ctxnode)
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   488
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   489
        succs = successors.get(ctxnode, ())
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   490
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   491
        markerfm = fm.nested(b"markers")
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   492
        for successor in sorted(succs):
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   493
            includediff = opts and opts.get("patch")
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   494
            _debugobshistorydisplaymarker(ui, markerfm, successor, ctxnode, unfi, includediff)
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   495
        markerfm.end()
4948
069cfc5301fb obslog: add newline after all markers in non-graphlog to match graphlog
Martin von Zweigbergk <martinvonz@google.com>
parents: 4947
diff changeset
   496
        fm.plain(b'\n')
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   497
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   498
        precs = precursors.get(ctxnode, ())
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   499
        for p in sorted(precs):
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   500
            # Only show nodes once
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   501
            if p[0] not in seen:
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   502
                seen.add(p[0])
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   503
                nodes.append(p[0])
2955
b899a94472fd obslog: uniformize `_debugobshistoryrevs` and `_debugobshistorygraph` arguments
Alain Leufroy
parents: 2954
diff changeset
   504
    fm.end()
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   505
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   506
def _debugobshistorydisplaynode(fm, repo, node):
2635
9ab35c37b85a obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents: 2634
diff changeset
   507
    if node in repo:
9ab35c37b85a obslog: pass directly unfiltered_repo
Boris Feld <boris.feld@octobus.net>
parents: 2634
diff changeset
   508
        _debugobshistorydisplayctx(fm, repo[node])
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   509
    else:
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   510
        _debugobshistorydisplaymissingctx(fm, node)
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   511
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   512
def _debugobshistorydisplayctx(fm, ctx):
3729
1b1badb3d2fc obshistory: make obslog work when a commit doesn't have any description
Anton Shestakov <av6@dwimlabs.net>
parents: 3728
diff changeset
   513
    shortdescription = ctx.description().strip()
1b1badb3d2fc obshistory: make obslog work when a commit doesn't have any description
Anton Shestakov <av6@dwimlabs.net>
parents: 3728
diff changeset
   514
    if shortdescription:
1b1badb3d2fc obshistory: make obslog work when a commit doesn't have any description
Anton Shestakov <av6@dwimlabs.net>
parents: 3728
diff changeset
   515
        shortdescription = shortdescription.splitlines()[0]
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   516
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   517
    fm.startitem()
4917
d1d8e97d32af obslog: make changeset available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4894
diff changeset
   518
    fm.context(ctx=ctx)
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   519
    fm.write(b'node', b'%s', bytes(ctx),
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   520
             label=b"evolve.node")
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   521
    fm.plain(b' ')
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   522
4918
f16274729530 obslog: don't overwrite {rev} keyword from changeset context
Martin von Zweigbergk <martinvonz@google.com>
parents: 4917
diff changeset
   523
    fm.plain(b'(%d)' % ctx.rev(), label=b"evolve.rev")
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   524
    fm.plain(b' ')
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   525
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   526
    fm.write(b'shortdescription', b'%s', shortdescription,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   527
             label=b"evolve.short_description")
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   528
    fm.plain(b'\n')
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   529
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   530
def _debugobshistorydisplaymissingctx(fm, nodewithoutctx):
2406
31255706b591 obshistory: import 'node' as 'nodemod'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2404
diff changeset
   531
    hexnode = nodemod.short(nodewithoutctx)
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   532
    fm.startitem()
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   533
    fm.write(b'node', b'%s', hexnode,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   534
             label=b"evolve.node evolve.missing_change_ctx")
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   535
    fm.plain(b'\n')
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   536
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   537
def _debugobshistorydisplaymarker(ui, fm, marker, node, repo, includediff=False):
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   538
    succnodes = marker[1]
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   539
    date = marker[4]
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   540
    metadata = dict(marker[3])
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   541
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   542
    fm.startitem()
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   543
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   544
    # Detect pruned revisions
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   545
    if len(succnodes) == 0:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   546
        verb = b'pruned'
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   547
    else:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   548
        verb = b'rewritten'
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   549
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   550
    fm.data(verb=verb)
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   551
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   552
    effectflag = metadata.get(b'ef1')
2455
d93a50a9abf5 effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2454
diff changeset
   553
    if effectflag is not None:
d93a50a9abf5 effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2454
diff changeset
   554
        try:
d93a50a9abf5 effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2454
diff changeset
   555
            effectflag = int(effectflag)
d93a50a9abf5 effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2454
diff changeset
   556
        except ValueError:
d93a50a9abf5 effectflag: handle invalid data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2454
diff changeset
   557
            effectflag = None
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   558
    if effectflag:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   559
        effects = []
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   560
2456
63be7982d593 effectflag: add a small comment to suggest improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2455
diff changeset
   561
        # 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
   562
        if effectflag & DESCCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   563
            effects.append(b'description')
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   564
        if effectflag & METACHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   565
            effects.append(b'meta')
2492
c9f1118b33d6 effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents: 2490
diff changeset
   566
        if effectflag & USERCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   567
            effects.append(b'user')
2492
c9f1118b33d6 effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents: 2490
diff changeset
   568
        if effectflag & DATECHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   569
            effects.append(b'date')
2492
c9f1118b33d6 effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents: 2490
diff changeset
   570
        if effectflag & BRANCHCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   571
            effects.append(b'branch')
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   572
        if effectflag & PARENTCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   573
            effects.append(b'parent')
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   574
        if effectflag & DIFFCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   575
            effects.append(b'content')
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   576
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   577
        if effects:
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   578
            fmteffect = fm.formatlist(effects, b'effect')
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   579
            fm.write(b'effects', b'(%s)', fmteffect)
2453
ad08aedf25ac obshistory: display informations from the obs marker effect flag
Boris Feld <boris.feld@octobus.net>
parents: 2450
diff changeset
   580
2832
07b9fcf8b6d3 output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents: 2697
diff changeset
   581
    if len(succnodes) > 0:
4951
7bfd3fed5d1f obslog: make {succnodes} be full hex nodes
Martin von Zweigbergk <martinvonz@google.com>
parents: 4950
diff changeset
   582
        hexnodes = (nodemod.hex(succnode) for succnode in sorted(succnodes))
7bfd3fed5d1f obslog: make {succnodes} be full hex nodes
Martin von Zweigbergk <martinvonz@google.com>
parents: 4950
diff changeset
   583
        nodes = fm.formatlist(hexnodes, b'succnode')
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   584
        fm.write(b'succnodes', b'%s', nodes)
2832
07b9fcf8b6d3 output: update obsfate / obslog output order
Boris Feld <boris.feld@octobus.net>
parents: 2697
diff changeset
   585
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   586
    operation = metadata.get(b'operation')
3519
2823c82ad8a4 obslog: add the operation to the Obslog output
Boris Feld <boris.feld@octobus.net>
parents: 3506
diff changeset
   587
    if operation:
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   588
        fm.data(operation=operation)
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   589
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   590
    fm.data(user=metadata[b'user'])
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   591
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   592
    fm.data(date=date)
2403
1b348702d79e obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   593
3214
9fe2b3fd7fc7 obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3181
diff changeset
   594
    # initial support for showing note
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   595
    if metadata.get(b'note'):
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   596
        fm.data(note=metadata[b'note'])
3214
9fe2b3fd7fc7 obslog: add initial support for showing note in obslog
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3181
diff changeset
   597
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   598
    # Patch display
3746
4dcf87849f9d compat: fix obslog with Mercurial 4.6+
Boris Feld <boris.feld@octobus.net>
parents: 3729
diff changeset
   599
    if includediff is True:
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   600
        _patchavailable = patchavailable(node, repo, marker[1])
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   601
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   602
        if _patchavailable[0] is True:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   603
            succ = _patchavailable[1]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   604
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   605
            basectx = repo[node]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   606
            succctx = repo[succ]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   607
            # Description patch
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   608
            descriptionpatch = getmarkerdescriptionpatch(repo,
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   609
                                                         basectx.description(),
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   610
                                                         succctx.description())
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   611
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   612
            if descriptionpatch:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   613
                # add the diffheader
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   614
                diffheader = b"diff -r %s -r %s changeset-description\n" %\
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   615
                             (basectx, succctx)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   616
                descriptionpatch = diffheader + descriptionpatch
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   617
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   618
                def tolist(text):
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   619
                    return [text]
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   620
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   621
                ui.pushbuffer(labeled=True)
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   622
                ui.write(b"\n")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   623
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   624
                for chunk, label in patch.difflabel(tolist, descriptionpatch):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   625
                    chunk = chunk.strip(b'\t')
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   626
                    if chunk and chunk != b'\n':
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   627
                        ui.write(b'    ')
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   628
                    ui.write(chunk, label=label)
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   629
                fm.write(b'descdiff', b'%s', ui.popbuffer())
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   630
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   631
            # Content patch
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   632
            ui.pushbuffer(labeled=True)
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   633
            diffopts = patch.diffallopts(repo.ui, {})
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   634
            matchfn = scmutil.matchall(repo)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   635
            firstline = True
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   636
            linestart = True
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   637
            for chunk, label in patch.diffui(repo, node, succ, matchfn,
4399
3722557b008c obshistory: omit keyword arguments with default values in patch.diffui() calls
Anton Shestakov <av6@dwimlabs.net>
parents: 4260
diff changeset
   638
                                             opts=diffopts):
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   639
                if firstline:
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   640
                    ui.write(b'\n')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   641
                    firstline = False
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   642
                if linestart:
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   643
                    linestart = False
4827
4c6dd20e8cc2 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 4814 4823
diff changeset
   644
                if chunk == b'\n':
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   645
                    linestart = True
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   646
                ui.write(chunk, label=label)
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   647
            fm.data(patch=ui.popbuffer())
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   648
        else:
4950
60d2065b720b obslog: remove now-unused code for plain styling
Martin von Zweigbergk <martinvonz@google.com>
parents: 4949
diff changeset
   649
            fm.data(nopatchreason=_patchavailable[1])
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   650
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   651
def _debugobshistorydisplaysuccsandmarkers(ui, fm, succnodes, markers, node, repo, includediff=False):
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   652
    """
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   653
    This function is a duplication of _debugobshistorydisplaymarker modified
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   654
    to accept multiple markers as input.
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   655
    """
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   656
    fm.startitem()
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   657
    fm.plain(b'  ')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   658
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   659
    # Detect pruned revisions
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   660
    verb = _successorsetverb(succnodes, markers)[b"verb"]
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   661
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   662
    fm.write(b'verb', b'%s', verb,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   663
             label=b"evolve.verb")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   664
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   665
    # Effect flag
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   666
    metadata = [dict(marker[3]) for marker in markers]
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   667
    ef1 = [data.get(b'ef1') for data in metadata]
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   668
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   669
    effectflag = 0
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   670
    for ef in ef1:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   671
        if ef:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   672
            effectflag |= int(ef)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   673
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   674
    if effectflag:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   675
        effects = []
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   676
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   677
        # XXX should be a dict
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   678
        if effectflag & DESCCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   679
            effects.append(b'description')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   680
        if effectflag & METACHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   681
            effects.append(b'meta')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   682
        if effectflag & USERCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   683
            effects.append(b'user')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   684
        if effectflag & DATECHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   685
            effects.append(b'date')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   686
        if effectflag & BRANCHCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   687
            effects.append(b'branch')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   688
        if effectflag & PARENTCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   689
            effects.append(b'parent')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   690
        if effectflag & DIFFCHANGED:
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   691
            effects.append(b'content')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   692
4939
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   693
        if effects:
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   694
            fmteffect = fm.formatlist(effects, b'effect', sep=b', ')
7aba58dc4b73 obslog: use plural name "effects" for list of all effects
Martin von Zweigbergk <martinvonz@google.com>
parents: 4938
diff changeset
   695
            fm.write(b'effects', b'(%s)', fmteffect)
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   696
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   697
    if len(succnodes) > 0:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   698
        fm.plain(b' as ')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   699
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   700
        shortsnodes = (nodemod.short(succnode) for succnode in sorted(succnodes))
4938
d8033f75a52e obslog: use singular name "succnode" for each element of {succnodes}
Martin von Zweigbergk <martinvonz@google.com>
parents: 4921
diff changeset
   701
        nodes = fm.formatlist(shortsnodes, b'succnode', sep=b', ')
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   702
        fm.write(b'succnodes', b'%s', nodes,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   703
                 label=b"evolve.node")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   704
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   705
    # Operations
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   706
    operations = compat.markersoperations(markers)
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   707
    if operations:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   708
        fm.plain(b' using ')
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   709
        fm.write(b'operation', b'%s', b", ".join(operations), label=b"evolve.operation")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   710
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   711
    fm.plain(b' by ')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   712
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   713
    # Users
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   714
    users = compat.markersusers(markers)
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   715
    fm.write(b'user', b'%s', b", ".join(users),
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   716
             label=b"evolve.user")
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   717
    fm.plain(b' ')
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   718
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   719
    # Dates
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3921
diff changeset
   720
    dates = compat.markersdates(markers)
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   721
    if dates:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   722
        min_date = min(dates)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   723
        max_date = max(dates)
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   724
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   725
        if min_date == max_date:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   726
            fm.write(b"date", b"(at %s)", fm.formatdate(min_date), label=b"evolve.date")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   727
        else:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   728
            fm.write(b"date", b"(between %s and %s)", fm.formatdate(min_date),
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   729
                     fm.formatdate(max_date), label=b"evolve.date")
3884
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   730
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   731
    # initial support for showing note
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   732
    # if metadata.get('note'):
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   733
    #     fm.plain('\n    note: ')
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   734
    #     fm.write('note', "%s", metadata['note'], label="evolve.note")
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   735
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   736
    # Patch display
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   737
    if includediff is True:
16bec7609a08 obslog: add a new flag to filter out non-local nodes
Boris Feld <boris.feld@octobus.net>
parents: 3883
diff changeset
   738
        _patchavailable = patchavailable(node, repo, succnodes)
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   739
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   740
        if _patchavailable[0] is True:
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   741
            succ = _patchavailable[1]
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   742
3402
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   743
            basectx = repo[node]
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   744
            succctx = repo[succ]
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   745
            # Description patch
3402
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   746
            descriptionpatch = getmarkerdescriptionpatch(repo,
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   747
                                                         basectx.description(),
7a322f58fee3 obshistory: pass the csets description in getmarkerdescriptionpatch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3401
diff changeset
   748
                                                         succctx.description())
3399
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   749
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   750
            if descriptionpatch:
3400
6d345d7ca682 obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3399
diff changeset
   751
                # add the diffheader
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   752
                diffheader = b"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
   753
                             (basectx, succctx)
3400
6d345d7ca682 obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3399
diff changeset
   754
                descriptionpatch = diffheader + descriptionpatch
3399
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   755
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   756
                def tolist(text):
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   757
                    return [text]
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   758
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   759
                ui.pushbuffer(labeled=True)
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   760
                ui.write(b"\n")
3400
6d345d7ca682 obslog: add header to the changeset description diff
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3399
diff changeset
   761
3399
4adf46158b9b obslog: colorize the description diff shown in obslog -p
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3398
diff changeset
   762
                for chunk, label in patch.difflabel(tolist, descriptionpatch):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   763
                    chunk = chunk.strip(b'\t')
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   764
                    if chunk and chunk != b'\n':
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   765
                        ui.write(b'    ')
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   766
                    ui.write(chunk, label=label)
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   767
                fm.write(b'descdiff', b'%s', ui.popbuffer())
2639
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   768
a5d8062f55ba obslog: also display description patch with --patch
Boris Feld <boris.feld@octobus.net>
parents: 2638
diff changeset
   769
            # Content patch
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   770
            ui.pushbuffer(labeled=True)
3398
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   771
            diffopts = patch.diffallopts(repo.ui, {})
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   772
            matchfn = scmutil.matchall(repo)
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   773
            firstline = True
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   774
            linestart = True
3398
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   775
            for chunk, label in patch.diffui(repo, node, succ, matchfn,
4399
3722557b008c obshistory: omit keyword arguments with default values in patch.diffui() calls
Anton Shestakov <av6@dwimlabs.net>
parents: 4260
diff changeset
   776
                                             opts=diffopts):
3398
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   777
                if firstline:
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   778
                    ui.write(b'\n')
3398
d67e6080e11b obslog: colorize the patch shown using `hg obslog -p`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3223
diff changeset
   779
                    firstline = False
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   780
                if linestart:
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   781
                    ui.write(b'    ')
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   782
                    linestart = False
4827
4c6dd20e8cc2 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 4814 4823
diff changeset
   783
                if chunk == b'\n':
4823
c16fed4908d8 obslog: only indent the first chunk and chunks just after newlines (issue6175)
Anton Shestakov <av6@dwimlabs.net>
parents: 4752
diff changeset
   784
                    linestart = True
4946
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   785
                ui.write(chunk, label=label)
bd992b1d4426 obslog: make content and description patches available to templater
Martin von Zweigbergk <martinvonz@google.com>
parents: 4945
diff changeset
   786
            fm.write(b'patch', b'%s', ui.popbuffer())
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   787
        else:
4947
0ad2000854c4 obslog: make reason for unavailable patch part of template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4946
diff changeset
   788
            fm.write(b'nopatchreason', b"\n    (No patch available, %s)",
0ad2000854c4 obslog: make reason for unavailable patch part of template
Martin von Zweigbergk <martinvonz@google.com>
parents: 4946
diff changeset
   789
                     _patchavailable[1])
2637
49f2741c4dd7 obslog: add a patch option
Boris Feld <boris.feld@octobus.net>
parents: 2636
diff changeset
   790
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   791
    fm.plain(b"\n")
2446
4b2f4da124a2 effectflag: allow to save effect of change in obsmarkers
Boris Feld <boris.feld@octobus.net>
parents: 2441
diff changeset
   792
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
   793
# 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
   794
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
   795
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
   796
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
   797
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
   798
USERCHANGED = 1 << 4 # the user changed
c9f1118b33d6 effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents: 2490
diff changeset
   799
DATECHANGED = 1 << 5 # the date changed
c9f1118b33d6 effectflag: split effect flag meta
Boris Feld <boris.feld@octobus.net>
parents: 2490
diff changeset
   800
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
   801
2522
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   802
METABLACKLIST = [
4801
16c1398b0063 python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents: 4752
diff changeset
   803
    re.compile(br'^__touch-noise__$'),
16c1398b0063 python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents: 4752
diff changeset
   804
    re.compile(br'^branch$'),
16c1398b0063 python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents: 4752
diff changeset
   805
    re.compile(br'^.*-source$'),
16c1398b0063 python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents: 4752
diff changeset
   806
    re.compile(br'^.*_source$'),
16c1398b0063 python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents: 4752
diff changeset
   807
    re.compile(br'^source$'),
2522
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   808
]
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   809
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   810
def ismetablacklisted(metaitem):
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   811
    """ 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
   812
    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
   813
    """
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   814
    metakey = metaitem[0]
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   815
    for pattern in METABLACKLIST:
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   816
        if pattern.match(metakey):
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   817
            return False
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   818
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   819
    return True
a1cc2a0b9f6f effetflag: detect other meta (extra) changes
Boris Feld <boris.feld@octobus.net>
parents: 2520
diff changeset
   820
2520
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   821
def _prepare_hunk(hunk):
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   822
    """Drop all information but the username and patch"""
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   823
    cleanunk = []
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   824
    for line in hunk.splitlines():
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   825
        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
   826
            if line.startswith(b'@@'):
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   827
                line = b'@@\n'
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   828
            cleanunk.append(line)
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   829
    return cleanunk
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   830
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   831
def _getdifflines(iterdiff):
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   832
    """return a cleaned up lines"""
2450
98613938d098 effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2449
diff changeset
   833
    try:
4738
45508676ed00 py3: replace iter.next() by next(iter)
Martin von Zweigbergk <martinvonz@google.com>
parents: 4715
diff changeset
   834
        lines = next(iterdiff)
2450
98613938d098 effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2449
diff changeset
   835
    except StopIteration:
98613938d098 effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2449
diff changeset
   836
        return None
2520
5fb5d096348c effectflag: better diff detection
Boris Feld <boris.feld@octobus.net>
parents: 2492
diff changeset
   837
    return _prepare_hunk(lines)
2450
98613938d098 effectflag: basic diff change detection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2449
diff changeset
   838
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   839
def _getobsfate(successorssets):
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   840
    """ 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
   841
    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
   842
    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
   843
    - pruned
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   844
    - diverged
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   845
    - superseed
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   846
    - superseed_split
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   847
    """
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   848
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   849
    if len(successorssets) == 0:
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   850
        # The commit has been pruned
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   851
        return b'pruned'
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   852
    elif len(successorssets) > 1:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   853
        return b'diverged'
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   854
    else:
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   855
        # 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
   856
        successors = successorssets[0]
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   857
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   858
        if len(successors) == 1:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   859
            return b'superseed'
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   860
        else:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   861
            return b'superseed_split'
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   862
2490
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   863
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
   864
    """ Return a tuple containing:
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   865
    - 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
   866
    - 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
   867
    or has diverged
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   868
    """
2490
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   869
    if successorssets is None:
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3607
diff changeset
   870
        successorssets = obsutil.successorssets(repo, revnode)
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   871
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   872
    fate = _getobsfate(successorssets)
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   873
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   874
    # 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
   875
    if len(successorssets) == 1:
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   876
        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
   877
    else:
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   878
        successors = []
2490
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   879
        for succset in successorssets:
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   880
            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
   881
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2484
diff changeset
   882
    return (fate, successors)
2490
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   883
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   884
def _successorsetdates(successorset, markers):
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   885
    """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
   886
    """
94f171534918 template: update obsfate to be more human friendly
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
   887
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   888
    if not markers:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   889
        return {}
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   890
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   891
    dates = [m[4] for m in markers]
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   892
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   893
    return {
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   894
        b'min_date': min(dates),
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   895
        b'max_date': max(dates)
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   896
    }
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
def _successorsetusers(successorset, markers):
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   899
    """ 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
   900
    """
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   901
    if not markers:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   902
        return {}
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   903
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   904
    # Check that user is present in meta
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   905
    markersmeta = [dict(m[3]) for m in markers]
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   906
    users = set(meta.get(b'user') for meta in markersmeta if meta.get(b'user'))
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   907
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   908
    return {b'users': sorted(users)}
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   909
2896
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   910
VERBMAPPING = {
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   911
    DESCCHANGED: b"reworded",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   912
    METACHANGED: b"meta-changed",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   913
    USERCHANGED: b"reauthored",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   914
    DATECHANGED: b"date-changed",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   915
    BRANCHCHANGED: b"branch-changed",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   916
    PARENTCHANGED: b"rebased",
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   917
    DIFFCHANGED: b"amended"
2896
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   918
}
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   919
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   920
def _successorsetverb(successorset, markers):
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   921
    """ Return the verb summarizing the successorset
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   922
    """
2896
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   923
    verb = None
2606
02129bed002c obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2604
diff changeset
   924
    if not successorset:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   925
        verb = b'pruned'
2607
054d92586e43 obsfate: use 'split' as verb when appropriate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2606
diff changeset
   926
    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
   927
        # 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
   928
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   929
        metadata = [dict(marker[3]) for marker in markers]
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   930
        ef1 = [data.get(b'ef1') for data in metadata]
2896
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   931
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   932
        if all(ef1):
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   933
            combined = 0
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   934
            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
   935
                combined |= int(ef)
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   936
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   937
            # 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
   938
            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
   939
                verb = VERBMAPPING[combined]
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   940
462adae9fea7 obsfate: use effect flag information for computing a better verb
Boris Feld <boris.feld@octobus.net>
parents: 2840
diff changeset
   941
        if verb is None:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   942
            verb = b'rewritten'
2606
02129bed002c obsfate: improve prune support in _successorsetverb
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2604
diff changeset
   943
    else:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   944
        verb = b'split'
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   945
    return {b'verb': verb}
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   946
3181
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   947
# 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
   948
if util.safehasattr(obsutil, 'obsfateverb'):
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   949
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   950
    @eh.wrapfunction(obsutil, 'obsfateverb')
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   951
    def obsfateverb(orig, *args, **kwargs):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   952
        return _successorsetverb(*args, **kwargs)[b'verb']
3181
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   953
3083
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   954
# Hijack callers of successorsetverb
3181
5db76f35efce effect-flag: fix obsfate verb hooking
Boris Feld <boris.feld@octobus.net>
parents: 3115
diff changeset
   955
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
   956
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   957
    @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
   958
    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
   959
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   960
        def closure(successors):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
   961
            return _successorsetverb(successors, markers)[b'verb']
3083
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   962
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   963
        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
   964
            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
   965
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   966
        # 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
   967
        old = obsutil.successorsetverb
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   968
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   969
        try:
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   970
            # Replace by own
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   971
            obsutil.successorsetverb = closure
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   972
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   973
            # Call the orig
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   974
            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
   975
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   976
            # And return result
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   977
            return result
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   978
        finally:
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   979
            # 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
   980
            obsutil.successorsetverb = old
e91ca8b5ecf7 obsfate: use core version of obsfate if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
   981
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   982
FORMATSSETSFUNCTIONS = [
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   983
    _successorsetdates,
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   984
    _successorsetusers,
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   985
    _successorsetverb
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   986
]
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   987
2609
81a94da65dca obsfate: mark successorsetallmarkers public
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2608
diff changeset
   988
def successorsetallmarkers(successorset, pathscache):
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   989
    """compute all successors of a successorset.
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   990
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   991
    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
   992
    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
   993
    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
   994
    successors.
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   995
    """
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   996
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   997
    markers = set()
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   998
    seen = set()
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
   999
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1000
    for successor in successorset:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1001
        stack = [successor]
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1002
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1003
        while stack:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1004
            element = stack.pop()
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1005
            seen.add(element)
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1006
            for prec, mark in pathscache.get(element, []):
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1007
                if prec not in seen:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1008
                    # Process element precursors
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1009
                    stack.append(prec)
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1010
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1011
                if mark not in markers:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1012
                    markers.add(mark)
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1013
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1014
    return markers
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1015
2610
ee37ab3de5f7 obsfate: split markers fetch from successor set annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2609
diff changeset
  1016
def preparesuccessorset(successorset, rawmarkers):
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1017
    """ 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
  1018
    the min date and the max date
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1019
    """
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
  1020
    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
  1021
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
  1022
    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
  1023
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
  1024
    # 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
  1025
    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
  1026
    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
  1027
        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
  1028
        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
  1029
        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
  1030
        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
  1031
            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
  1032
        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
  1033
        markers.append(newmarker)
2603
23f1c3b9052f template: use hex successors in obsfate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2592
diff changeset
  1034
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1035
    # Format basic data
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1036
    data = {
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
  1037
        b"successors": sorted(successorset),
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4801
diff changeset
  1038
        b"markers": sorted(markers)
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1039
    }
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1040
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1041
    # 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
  1042
    for function in FORMATSSETSFUNCTIONS:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1043
        data.update(function(successorset, markers))
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1044
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
  1045
    return data