hgext3rd/evolve/compat.py
author Raphaël Gomès <rgomes@octobus.net>
Tue, 06 Aug 2019 11:26:29 +0200
changeset 4804 079dbf36e884
parent 4746 724c67878d98
child 4805 60e8cdce0e9c
permissions -rw-r--r--
python3: add raw prefix in cases harder to analyze at the token level The `byteify-strings.py` script would be a lot more complicated if it had to do backtracking and other more advanced static analysis to figure our those cases, so we have to add the raw prefix to those cases manually.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
# Copyright 2017 Octobus <contact@octobus.net>
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
#
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
# This software may be used and distributed according to the terms of the
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
# GNU General Public License version 2 or any later version.
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
"""
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
Compatibility module
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
"""
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
     9
import inspect
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    10
import array
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    11
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
from mercurial import (
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    13
    context,
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
    14
    copies,
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
    15
    encoding,
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    16
    mdiff,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
    17
    obsolete,
3693
105d2d2c6a2e compat: drop obsutile layer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3692
diff changeset
    18
    obsutil,
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    19
    pycompat,
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    20
    repair,
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    21
    scmutil,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
    22
    util,
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    23
    ui as uimod,
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
)
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
    25
from mercurial.hgweb import hgweb_mod
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    27
if pycompat.ispy3:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    28
    arraytobytes = array.array.tobytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    29
    arrayfrombytes = array.array.frombytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    30
else:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    31
    arraytobytes = array.array.tostring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    32
    arrayfrombytes = array.array.fromstring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    33
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    34
# hg < 4.6 compat (c8e2d6ed1f9e)
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    35
try:
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    36
    from mercurial import logcmdutil
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    37
    changesetdisplayer = logcmdutil.changesetdisplayer
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    38
    changesetprinter = logcmdutil.changesetprinter
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    39
    displaygraph = logcmdutil.displaygraph
3921
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3908
diff changeset
    40
    changesetdiffer = logcmdutil.changesetdiffer
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    41
except (AttributeError, ImportError):
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    42
    from mercurial import cmdutil
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    43
    changesetdisplayer = cmdutil.show_changeset
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    44
    changesetprinter = cmdutil.changeset_printer
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    45
    displaygraph = cmdutil.displaygraph
3921
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3908
diff changeset
    46
    changesetdiffer = None
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    47
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
from . import (
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    49
    exthelper,
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
)
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    51
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    52
eh = exthelper.exthelper()
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    53
3283
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    54
def isobsnotesupported():
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    55
    # hack to know obsnote is supported. The patches for obsnote support was
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    56
    # pushed before the obsfateprinter patches, so this will serve as a good
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    57
    # check
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    58
    if not obsutil:
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    59
        return False
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    60
    return util.safehasattr(obsutil, 'obsfateprinter')
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    61
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    62
# Evolution renaming compat
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    63
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    64
TROUBLES = {
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    65
    'ORPHAN': 'orphan',
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    66
    'CONTENTDIVERGENT': 'content-divergent',
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    67
    'PHASEDIVERGENT': 'phase-divergent',
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    68
}
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    69
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    70
if util.safehasattr(uimod.ui, 'makeprogress'):
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    71
    def progress(ui, topic, pos, item="", unit="", total=None):
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    72
        progress = ui.makeprogress(topic, unit, total)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    73
        if pos is not None:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    74
            progress.update(pos, item=item)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    75
        else:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    76
            progress.complete()
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    77
else:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    78
    def progress(ui, topic, pos, item="", unit="", total=None):
4565
393a58d71b30 evolve: fix progress display with hg<4.7
Martin von Zweigbergk <martinvonz@google.com>
parents: 4546
diff changeset
    79
        ui.progress(topic, pos, item, unit, total)
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    80
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    81
# XXX: Better detection of property cache
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
    82
if r'predecessors' not in dir(obsolete.obsstore):
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    83
    @property
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    84
    def predecessors(self):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    85
        return self.precursors
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    86
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    87
    obsolete.obsstore.predecessors = predecessors
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
    88
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    89
def memfilectx(repo, ctx, fctx, flags, copied, path):
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    90
    # XXX Would it be better at the module level?
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    91
    varnames = context.memfilectx.__init__.__code__.co_varnames
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    92
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
    93
    if r"copysource" in varnames:
4460
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    94
        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    95
                                  islink='l' in flags,
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    96
                                  isexec='x' in flags,
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    97
                                  copysource=copied.get(path))
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    98
    # compat with hg <- 4.9
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
    99
    elif varnames[2] == r"changectx":
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   100
        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   101
                                  islink='l' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   102
                                  isexec='x' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   103
                                  copied=copied.get(path))
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   104
    else:
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   105
        mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   106
                                  islink='l' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   107
                                  isexec='x' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   108
                                  copied=copied.get(path))
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   109
    return mctx
3408
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   110
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   111
def strdiff(a, b, fn1, fn2):
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   112
    """ A version of mdiff.unidiff for comparing two strings
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   113
    """
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   114
    args = [a, '', b, '', fn1, fn2]
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   115
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   116
    # hg < 4.6 compat 8b6dd3922f70
4746
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   117
    if util.safehasattr(inspect, 'signature'):
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   118
        signature = inspect.signature(mdiff.unidiff)
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
   119
        needsbinary = r'binary' in signature.parameters
4746
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   120
    else:
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   121
        argspec = inspect.getargspec(mdiff.unidiff)
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
   122
        needsbinary = r'binary' in argspec.args
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   123
4746
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   124
    if needsbinary:
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   125
        args.append(False)
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   126
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   127
    return mdiff.unidiff(*args)
3514
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   128
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   129
# date related
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   130
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   131
try:
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   132
    import mercurial.utils.dateutil
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   133
    makedate = mercurial.utils.dateutil.makedate
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   134
    parsedate = mercurial.utils.dateutil.parsedate
4304
604732387e33 linter: silence rightful complains about unused variable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 4223
diff changeset
   135
except ImportError:
3514
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   136
    import mercurial.util
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   137
    makedate = mercurial.util.makedate
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   138
    parsedate = mercurial.util.parsedate
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   139
4716
d587611d0c78 py3: use bytes for wireprotocol command registration
Martin von Zweigbergk <martinvonz@google.com>
parents: 4714
diff changeset
   140
def wireprotocommand(exthelper, name, args=b'', permission=b'pull'):
3680
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   141
    try:
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   142
        # Since b4d85bc1
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   143
        from mercurial.wireprotov1server import wireprotocommand
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   144
        return wireprotocommand(name, args, permission=permission)
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   145
    except (ImportError, AttributeError):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   146
        from mercurial import wireproto
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   147
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   148
    if 3 <= len(wireproto.wireprotocommand.func_defaults):
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   149
        return wireproto.wireprotocommand(name, args, permission=permission)
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   150
3680
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   151
    # <= hg-4.5 permission must be registered in dictionnary
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   152
    def decorator(func):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   153
        @eh.extsetup
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   154
        def install(ui):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   155
            hgweb_mod.perms[name] = permission
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   156
            wireproto.commands[name] = (func, args)
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   157
    return decorator
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   158
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   159
# mercurial <= 4.5 do not have the updateresult object
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   160
try:
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   161
    from mercurial.merge import updateresult
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   162
except (ImportError, AttributeError):
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   163
    updateresult = None
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   164
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   165
# 46c2b19a1263f18a5829a21b7a5053019b0c5a31 in hg moved repair.stripbmrevset to
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   166
# scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   167
# This change is a part of 4.7 cycle, so drop this when we drop support for 4.6
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   168
try:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   169
    bmrevset = repair.stripbmrevset
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   170
except AttributeError:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   171
    bmrevset = scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   172
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   173
def hasconflict(upres):
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   174
    if updateresult is None:
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   175
        return bool(upres[-1])
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   176
    return bool(upres.unresolvedcount)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   177
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   178
hg48 = util.safehasattr(copies, 'stringutil')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   179
# code imported from Mercurial core at ae17555ef93f + patch
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   180
def fixedcopytracing(repo, c1, c2, base):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   181
    """A complete copy-patse of copies._fullcopytrace with a one line fix to
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   182
    handle when the base is not parent of both c1 and c2. This should be
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   183
    converted in a compat function once https://phab.mercurial-scm.org/D3896
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   184
    gets in and once we drop support for 4.7, this should be removed."""
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   185
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   186
    from mercurial import pathutil
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   187
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   188
    # In certain scenarios (e.g. graft, update or rebase), base can be
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   189
    # overridden We still need to know a real common ancestor in this case We
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   190
    # can't just compute _c1.ancestor(_c2) and compare it to ca, because there
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   191
    # can be multiple common ancestors, e.g. in case of bidmerge.  Because our
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   192
    # caller may not know if the revision passed in lieu of the CA is a genuine
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   193
    # common ancestor or not without explicitly checking it, it's better to
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   194
    # determine that here.
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   195
    #
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   196
    # base.isancestorof(wc) is False, work around that
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   197
    _c1 = c1.p1() if c1.rev() is None else c1
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   198
    _c2 = c2.p1() if c2.rev() is None else c2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   199
    # an endpoint is "dirty" if it isn't a descendant of the merge base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   200
    # if we have a dirty endpoint, we need to trigger graft logic, and also
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   201
    # keep track of which endpoint is dirty
3908
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   202
    if util.safehasattr(base, 'isancestorof'):
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   203
        dirtyc1 = not base.isancestorof(_c1)
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   204
        dirtyc2 = not base.isancestorof(_c2)
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   205
    else: # hg <= 4.6
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   206
        dirtyc1 = not base.descendant(_c1)
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   207
        dirtyc2 = not base.descendant(_c2)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   208
    graft = dirtyc1 or dirtyc2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   209
    tca = base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   210
    if graft:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   211
        tca = _c1.ancestor(_c2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   212
4388
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   213
    # hg < 4.8 compat (dc50121126ae)
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   214
    try:
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   215
        limit = copies._findlimit(repo, c1, c2)
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   216
    except (AttributeError, TypeError):
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   217
        limit = copies._findlimit(repo, c1.rev(), c2.rev())
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   218
    if limit is None:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   219
        # no common ancestor, no copies
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   220
        return {}, {}, {}, {}, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   221
    repo.ui.debug("  searching for copies back to rev %d\n" % limit)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   222
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   223
    m1 = c1.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   224
    m2 = c2.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   225
    mb = base.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   226
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   227
    # gather data from _checkcopies:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   228
    # - diverge = record all diverges in this dict
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   229
    # - copy = record all non-divergent copies in this dict
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   230
    # - fullcopy = record all copies in this dict
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   231
    # - incomplete = record non-divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   232
    # - incompletediverge = record divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   233
    diverge = {} # divergence data is shared
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   234
    incompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   235
    data1 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   236
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   237
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   238
             'diverge': diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   239
             'incompletediverge': incompletediverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   240
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   241
    data2 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   242
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   243
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   244
             'diverge': diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   245
             'incompletediverge': incompletediverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   246
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   247
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   248
    # find interesting file sets from manifests
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   249
    if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   250
        addedinm1 = m1.filesnotin(mb, repo.narrowmatch())
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   251
        addedinm2 = m2.filesnotin(mb, repo.narrowmatch())
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   252
    else:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   253
        addedinm1 = m1.filesnotin(mb)
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   254
        addedinm2 = m2.filesnotin(mb)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   255
    bothnew = sorted(addedinm1 & addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   256
    if tca == base:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   257
        # unmatched file from base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   258
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   259
        u1u, u2u = u1r, u2r
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   260
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   261
        # unmatched file from base (DAG rotation in the graft case)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   262
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   263
                                             baselabel='base')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   264
        # unmatched file from topological common ancestors (no DAG rotation)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   265
        # need to recompute this for directory move handling when grafting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   266
        mta = tca.manifest()
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   267
        if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   268
            m1f = m1.filesnotin(mta, repo.narrowmatch())
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   269
            m2f = m2.filesnotin(mta, repo.narrowmatch())
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   270
            baselabel = 'topological common ancestor'
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   271
            u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1f, m2f,
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   272
                                                 baselabel=baselabel)
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   273
        else:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   274
            u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1.filesnotin(mta),
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   275
                                                 m2.filesnotin(mta),
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   276
                                                 baselabel='topological common ancestor')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   277
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   278
    for f in u1u:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   279
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, data1)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   280
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   281
    for f in u2u:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   282
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   283
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   284
    copy = dict(data1['copy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   285
    copy.update(data2['copy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   286
    fullcopy = dict(data1['fullcopy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   287
    fullcopy.update(data2['fullcopy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   288
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   289
    if dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   290
        copies._combinecopies(data2['incomplete'], data1['incomplete'], copy, diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   291
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   292
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   293
        copies._combinecopies(data1['incomplete'], data2['incomplete'], copy, diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   294
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   295
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   296
    renamedelete = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   297
    renamedeleteset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   298
    divergeset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   299
    for of, fl in list(diverge.items()):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   300
        if len(fl) == 1 or of in c1 or of in c2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   301
            del diverge[of] # not actually divergent, or not a rename
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   302
            if of not in c1 and of not in c2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   303
                # renamed on one side, deleted on the other side, but filter
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   304
                # out files that have been renamed and then deleted
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   305
                renamedelete[of] = [f for f in fl if f in c1 or f in c2]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   306
                renamedeleteset.update(fl) # reverse map for below
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   307
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   308
            divergeset.update(fl) # reverse map for below
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   309
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   310
    if bothnew:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   311
        repo.ui.debug("  unmatched files new in both:\n   %s\n"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   312
                      % "\n   ".join(bothnew))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   313
    bothdiverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   314
    bothincompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   315
    remainder = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   316
    both1 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   317
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   318
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   319
             'diverge': bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   320
             'incompletediverge': bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   321
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   322
    both2 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   323
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   324
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   325
             'diverge': bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   326
             'incompletediverge': bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   327
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   328
    for f in bothnew:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   329
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, both1)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   330
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, both2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   331
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   332
    if dirtyc1 and dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   333
        pass
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   334
    elif dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   335
        # incomplete copies may only be found on the "dirty" side for bothnew
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   336
        assert not both2['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   337
        remainder = copies._combinecopies({}, both1['incomplete'], copy, bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   338
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   339
    elif dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   340
        assert not both1['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   341
        remainder = copies._combinecopies({}, both2['incomplete'], copy, bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   342
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   343
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   344
        # incomplete copies and divergences can't happen outside grafts
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   345
        assert not both1['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   346
        assert not both2['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   347
        assert not bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   348
    for f in remainder:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   349
        assert f not in bothdiverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   350
        ic = remainder[f]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   351
        if ic[0] in (m1 if dirtyc1 else m2):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   352
            # backed-out rename on one side, but watch out for deleted files
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   353
            bothdiverge[f] = ic
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   354
    for of, fl in bothdiverge.items():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   355
        if len(fl) == 2 and fl[0] == fl[1]:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   356
            copy[fl[0]] = of # not actually divergent, just matching renames
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   357
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   358
    if fullcopy and repo.ui.debugflag:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   359
        repo.ui.debug("  all copies found (* = to merge, ! = divergent, "
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   360
                      "% = renamed and deleted):\n")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   361
        for f in sorted(fullcopy):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   362
            note = ""
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   363
            if f in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   364
                note += "*"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   365
            if f in divergeset:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   366
                note += "!"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   367
            if f in renamedeleteset:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   368
                note += "%"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   369
            repo.ui.debug("   src: '%s' -> dst: '%s' %s\n" % (fullcopy[f], f,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   370
                                                              note))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   371
    del divergeset
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   372
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   373
    if not fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   374
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   375
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   376
    repo.ui.debug("  checking for directory renames\n")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   377
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   378
    # generate a directory move map
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   379
    d1, d2 = c1.dirs(), c2.dirs()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   380
    # Hack for adding '', which is not otherwise added, to d1 and d2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   381
    d1.addpath('/')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   382
    d2.addpath('/')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   383
    invalid = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   384
    dirmove = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   385
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   386
    # examine each file copy for a potential directory move, which is
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   387
    # when all the files in a directory are moved to a new directory
4714
c51fc0ae7a7e py3: switch from iteritems() to items()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4565
diff changeset
   388
    for dst, src in fullcopy.items():
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   389
        dsrc, ddst = pathutil.dirname(src), pathutil.dirname(dst)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   390
        if dsrc in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   391
            # already seen to be uninteresting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   392
            continue
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   393
        elif dsrc in d1 and ddst in d1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   394
            # directory wasn't entirely moved locally
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   395
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   396
        elif dsrc in d2 and ddst in d2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   397
            # directory wasn't entirely moved remotely
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   398
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   399
        elif dsrc + "/" in dirmove and dirmove[dsrc + "/"] != ddst + "/":
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   400
            # files from the same directory moved to two different places
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   401
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   402
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   403
            # looks good so far
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   404
            dirmove[dsrc + "/"] = ddst + "/"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   405
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   406
    for i in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   407
        if i in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   408
            del dirmove[i]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   409
    del d1, d2, invalid
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   410
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   411
    if not dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   412
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   413
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   414
    for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   415
        repo.ui.debug("   discovered dir src: '%s' -> dst: '%s'\n" %
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   416
                      (d, dirmove[d]))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   417
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   418
    movewithdir = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   419
    # check unaccounted nonoverlapping files against directory moves
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   420
    for f in u1r + u2r:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   421
        if f not in fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   422
            for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   423
                if f.startswith(d):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   424
                    # new file added in a directory that was moved, move it
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   425
                    df = dirmove[d] + f[len(d):]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   426
                    if df not in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   427
                        movewithdir[f] = df
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   428
                        repo.ui.debug(("   pending file src: '%s' -> "
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   429
                                       "dst: '%s'\n") % (f, df))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   430
                    break
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   431
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   432
    return copy, movewithdir, diverge, renamedelete, dirmove
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   433
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
   434
# hg <= 4.9 compat (7694b685bb10)
4546
e7b44e9c38d2 compat: fix a typo in compat patch
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4488
diff changeset
   435
fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
   436
if not fixupstreamed:
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   437
    copies._fullcopytracing = fixedcopytracing
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   438
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   439
if not util.safehasattr(obsutil, "_succs"):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   440
    class _succs(list):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   441
        """small class to represent a successors with some metadata about it"""
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   442
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   443
        def __init__(self, *args, **kwargs):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   444
            super(_succs, self).__init__(*args, **kwargs)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   445
            self.markers = set()
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   446
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   447
        def copy(self):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   448
            new = _succs(self)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   449
            new.markers = self.markers.copy()
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   450
            return new
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   451
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   452
        @util.propertycache
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   453
        def _set(self):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   454
            # immutable
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   455
            return set(self)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   456
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   457
        def canmerge(self, other):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   458
            return self._set.issubset(other._set)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   459
else:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   460
    from mercurial.obsutil import _succs
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   461
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   462
def wrap_succs(succs):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   463
    """ Wrap old data format of successorsets (tuple) only if if's not yet a
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   464
    _succs instance
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   465
    """
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   466
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   467
    if not util.safehasattr(succs, "markers"):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   468
        return _succs(succs)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   469
    else:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   470
        return succs
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   471
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   472
if not util.safehasattr(obsutil, "markersdates"):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   473
    MARKERS_DATE_COMPAT = True
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   474
else:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   475
    MARKERS_DATE_COMPAT = False
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   476
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   477
def markersdates(markers):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   478
    """returns the list of dates for a list of markers
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   479
    """
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   480
    if MARKERS_DATE_COMPAT is False:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   481
        return obsutil.markersdates(markers)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   482
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   483
    return [m[4] for m in markers]
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   484
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   485
if not util.safehasattr(obsutil, "markersusers"):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   486
    MARKERS_USERS_COMPAT = True
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   487
else:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   488
    MARKERS_USERS_COMPAT = False
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   489
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   490
def markersusers(markers):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   491
    """ Returns a sorted list of markers users without duplicates
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   492
    """
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   493
    if MARKERS_USERS_COMPAT is False:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   494
        return obsutil.markersusers(markers)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   495
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   496
    markersmeta = [dict(m[3]) for m in markers]
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   497
    users = set(encoding.tolocal(meta['user']) for meta in markersmeta
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   498
                if meta.get('user'))
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   499
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   500
    return sorted(users)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   501
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   502
if not util.safehasattr(obsutil, "markersoperations"):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   503
    MARKERS_OPERATIONS_COMPAT = True
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   504
else:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   505
    MARKERS_OPERATIONS_COMPAT = False
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   506
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   507
def markersoperations(markers):
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   508
    """ Returns a sorted list of markers operations without duplicates
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   509
    """
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   510
    if MARKERS_OPERATIONS_COMPAT is False:
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   511
        return obsutil.markersoperations(markers)
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   512
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   513
    markersmeta = [dict(m[3]) for m in markers]
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   514
    operations = set(meta.get('operation') for meta in markersmeta
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   515
                     if meta.get('operation'))
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   516
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   517
    return sorted(operations)