hgext3rd/evolve/compat.py
author Anton Shestakov <av6@dwimlabs.net>
Fri, 08 May 2020 20:36:29 +0800
branchmercurial-5.0
changeset 5364 be5aa681c122
parent 5193 a4d081923c81
permissions -rw-r--r--
test-compat: merge mercurial-5.1 into mercurial-5.0
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
5096
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
     9
import array
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
    10
import contextlib
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,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
    15
    obsolete,
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    16
    pycompat,
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
    17
    registrar,
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    18
    repair,
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    19
    scmutil,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
    20
    util,
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    21
    ui as uimod,
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
)
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    24
if pycompat.ispy3:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    25
    arraytobytes = array.array.tobytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    26
    arrayfrombytes = array.array.frombytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    27
else:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    28
    arraytobytes = array.array.tostring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    29
    arrayfrombytes = array.array.fromstring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    30
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
    31
# hg <= 5.2 (c21aca51b392)
4956
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    32
try:
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    33
    from mercurial import pathutil
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    34
    dirs = pathutil.dirs
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    35
except (AttributeError, ImportError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    36
    dirs = util.dirs  # pytype: disable=module-attr
4956
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    37
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    38
from . import (
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
    exthelper,
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
)
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    41
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
eh = exthelper.exthelper()
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    44
# Evolution renaming compat
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    45
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    46
TROUBLES = {
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    47
    r'ORPHAN': b'orphan',
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    48
    r'CONTENTDIVERGENT': b'content-divergent',
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    49
    r'PHASEDIVERGENT': b'phase-divergent',
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    50
}
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    51
5043
db341dafdccb compat: add hg version to progress compatibility code
Anton Shestakov <av6@dwimlabs.net>
parents: 5039
diff changeset
    52
# hg <= 4.6 (bec1212eceaa)
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    53
if util.safehasattr(uimod.ui, 'makeprogress'):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    54
    def progress(ui, topic, pos, item=b"", unit=b"", total=None):
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    55
        progress = ui.makeprogress(topic, unit, total)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    56
        if pos is not None:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    57
            progress.update(pos, item=item)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    58
        else:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    59
            progress.complete()
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    60
else:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    61
    def progress(ui, topic, pos, item=b"", unit=b"", total=None):
4565
393a58d71b30 evolve: fix progress display with hg<4.7
Martin von Zweigbergk <martinvonz@google.com>
parents: 4546
diff changeset
    62
        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
    63
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    64
# 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
    65
if r'predecessors' not in dir(obsolete.obsstore):
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    66
    @property
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    67
    def predecessors(self):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    68
        return self.precursors
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    69
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    70
    obsolete.obsstore.predecessors = predecessors
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
    71
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    72
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
    73
    # XXX Would it be better at the module level?
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    74
    varnames = context.memfilectx.__init__.__code__.co_varnames  # pytype: disable=attribute-error
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    75
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
    76
    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
    77
        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    78
                                  islink=b'l' in flags,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    79
                                  isexec=b'x' in flags,
4460
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
    80
                                  copysource=copied.get(path))
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
    81
    # hg <= 4.9 (550a172a603b)
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
    elif varnames[2] == r"changectx":
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    83
        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    84
                                  islink=b'l' in flags,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    85
                                  isexec=b'x' in flags,
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    86
                                  copied=copied.get(path))  # pytype: disable=wrong-keyword-args
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    87
    return mctx
3408
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
    88
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    89
try:
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
    90
    # hg <= 4.6 (46c2b19a1263)
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    91
    bmrevset = repair.stripbmrevset  # pytype: disable=module-attr
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    92
except AttributeError:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    93
    bmrevset = scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    94
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
    95
hg48 = util.safehasattr(copies, 'stringutil')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
    96
# 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
    97
def fixedcopytracing(repo, c1, c2, base):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
    98
    """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
    99
    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
   100
    converted in a compat function once https://phab.mercurial-scm.org/D3896
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
   101
    gets in and once we drop support for 4.6, this should be removed."""
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   102
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   103
    from mercurial import pathutil
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   104
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   105
    # 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
   106
    # 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
   107
    # 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
   108
    # 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
   109
    # 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
   110
    # 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
   111
    # determine that here.
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   112
    #
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   113
    # 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
   114
    _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
   115
    _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
   116
    # 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
   117
    # 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
   118
    # 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
   119
    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
   120
        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
   121
        dirtyc2 = not base.isancestorof(_c2)
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
   122
    else: # hg <= 4.6 (fbec9c0b32d3)
3908
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   123
        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
   124
        dirtyc2 = not base.descendant(_c2)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   125
    graft = dirtyc1 or dirtyc2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   126
    tca = base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   127
    if graft:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   128
        tca = _c1.ancestor(_c2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   129
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
   130
    # hg <= 4.9 (dc50121126ae)
4388
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   131
    try:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   132
        limit = copies._findlimit(repo, c1, c2)  # pytype: disable=module-attr
4388
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   133
    except (AttributeError, TypeError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   134
        limit = copies._findlimit(repo, c1.rev(), c2.rev())  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   135
    if limit is None:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   136
        # no common ancestor, no copies
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   137
        return {}, {}, {}, {}, {}
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   138
    repo.ui.debug(b"  searching for copies back to rev %d\n" % limit)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   139
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   140
    m1 = c1.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   141
    m2 = c2.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   142
    mb = base.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   143
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   144
    # gather data from _checkcopies:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   145
    # - 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
   146
    # - 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
   147
    # - 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
   148
    # - 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
   149
    # - incompletediverge = record divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   150
    diverge = {} # divergence data is shared
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   151
    incompletediverge = {}
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   152
    data1 = {b'copy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   153
             b'fullcopy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   154
             b'incomplete': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   155
             b'diverge': diverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   156
             b'incompletediverge': incompletediverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   157
             }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   158
    data2 = {b'copy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   159
             b'fullcopy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   160
             b'incomplete': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   161
             b'diverge': diverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   162
             b'incompletediverge': incompletediverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   163
             }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   164
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   165
    # 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
   166
    if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   167
        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
   168
        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
   169
    else:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   170
        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
   171
        addedinm2 = m2.filesnotin(mb)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   172
    bothnew = sorted(addedinm1 & addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   173
    if tca == base:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   174
        # unmatched file from base
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   175
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2)  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   176
        u1u, u2u = u1r, u2r
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   177
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   178
        # unmatched file from base (DAG rotation in the graft case)
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   179
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2,  # pytype: disable=module-attr
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   180
                                             baselabel=b'base')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   181
        # 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
   182
        # 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
   183
        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
   184
        if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   185
            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
   186
            m2f = m2.filesnotin(mta, repo.narrowmatch())
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   187
            baselabel = b'topological common ancestor'
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   188
            u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1f, m2f,  # pytype: disable=module-attr
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   189
                                                 baselabel=baselabel)
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   190
        else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   191
            u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1.filesnotin(mta),  # pytype: disable=module-attr
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   192
                                                 m2.filesnotin(mta),
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   193
                                                 baselabel=b'topological common ancestor')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   194
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   195
    for f in u1u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   196
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, data1)  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   197
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   198
    for f in u2u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   199
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2)  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   200
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   201
    copy = dict(data1[b'copy'])
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   202
    copy.update(data2[b'copy'])
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   203
    fullcopy = dict(data1[b'fullcopy'])
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   204
    fullcopy.update(data2[b'fullcopy'])
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   205
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   206
    if dirtyc1:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   207
        copies._combinecopies(data2[b'incomplete'], data1[b'incomplete'], copy, diverge,  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   208
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   209
    else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   210
        copies._combinecopies(data1[b'incomplete'], data2[b'incomplete'], copy, diverge,  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   211
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   212
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   213
    renamedelete = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   214
    renamedeleteset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   215
    divergeset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   216
    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
   217
        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
   218
            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
   219
            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
   220
                # 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
   221
                # 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
   222
                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
   223
                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
   224
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   225
            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
   226
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   227
    if bothnew:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   228
        repo.ui.debug(b"  unmatched files new in both:\n   %s\n"
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   229
                      % b"\n   ".join(bothnew))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   230
    bothdiverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   231
    bothincompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   232
    remainder = {}
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   233
    both1 = {b'copy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   234
             b'fullcopy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   235
             b'incomplete': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   236
             b'diverge': bothdiverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   237
             b'incompletediverge': bothincompletediverge
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   238
             }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   239
    both2 = {b'copy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   240
             b'fullcopy': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   241
             b'incomplete': {},
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   242
             b'diverge': bothdiverge,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   243
             b'incompletediverge': bothincompletediverge
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   244
             }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   245
    for f in bothnew:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   246
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, both1)  # pytype: disable=module-attr
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   247
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, both2)  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   248
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   249
    if dirtyc1 and dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   250
        pass
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   251
    elif dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   252
        # incomplete copies may only be found on the "dirty" side for bothnew
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   253
        assert not both2[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   254
        remainder = copies._combinecopies({}, both1[b'incomplete'], copy, bothdiverge,  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   255
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   256
    elif dirtyc2:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   257
        assert not both1[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   258
        remainder = copies._combinecopies({}, both2[b'incomplete'], copy, bothdiverge,  # pytype: disable=module-attr
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   259
                                          bothincompletediverge)
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
        # incomplete copies and divergences can't happen outside grafts
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   262
        assert not both1[b'incomplete']
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   263
        assert not both2[b'incomplete']
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   264
        assert not bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   265
    for f in remainder:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   266
        assert f not in bothdiverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   267
        ic = remainder[f]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   268
        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
   269
            # 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
   270
            bothdiverge[f] = ic
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   271
    for of, fl in bothdiverge.items():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   272
        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
   273
            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
   274
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   275
    if fullcopy and repo.ui.debugflag:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   276
        repo.ui.debug(b"  all copies found (* = to merge, ! = divergent, "
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   277
                      b"% = renamed and deleted):\n")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   278
        for f in sorted(fullcopy):
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   279
            note = b""
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   280
            if f in copy:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   281
                note += b"*"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   282
            if f in divergeset:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   283
                note += b"!"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   284
            if f in renamedeleteset:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   285
                note += b"%"
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   286
            repo.ui.debug(b"   src: '%s' -> dst: '%s' %s\n" % (fullcopy[f], f,
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   287
                                                               note))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   288
    del divergeset
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   289
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   290
    if not fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   291
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   292
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   293
    repo.ui.debug(b"  checking for directory renames\n")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   294
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   295
    # generate a directory move map
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   296
    d1, d2 = c1.dirs(), c2.dirs()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   297
    # Hack for adding '', which is not otherwise added, to d1 and d2
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   298
    d1.addpath(b'/')
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   299
    d2.addpath(b'/')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   300
    invalid = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   301
    dirmove = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   302
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   303
    # 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
   304
    # 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
   305
    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
   306
        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
   307
        if dsrc in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   308
            # already seen to be uninteresting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   309
            continue
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   310
        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
   311
            # directory wasn't entirely moved locally
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   312
            invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   313
        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
   314
            # directory wasn't entirely moved remotely
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   315
            invalid.add(dsrc + b"/")
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   316
        elif dsrc + b"/" in dirmove and dirmove[dsrc + b"/"] != ddst + b"/":
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   317
            # files from the same directory moved to two different places
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   318
            invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   319
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   320
            # looks good so far
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   321
            dirmove[dsrc + b"/"] = ddst + b"/"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   322
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   323
    for i in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   324
        if i in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   325
            del dirmove[i]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   326
    del d1, d2, invalid
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
    if not dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   329
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   330
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   331
    for d in dirmove:
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   332
        repo.ui.debug(b"   discovered dir src: '%s' -> dst: '%s'\n" %
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   333
                      (d, dirmove[d]))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   334
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   335
    movewithdir = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   336
    # 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
   337
    for f in u1r + u2r:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   338
        if f not in fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   339
            for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   340
                if f.startswith(d):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   341
                    # 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
   342
                    df = dirmove[d] + f[len(d):]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   343
                    if df not in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   344
                        movewithdir[f] = df
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   345
                        repo.ui.debug((b"   pending file src: '%s' -> "
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   346
                                       b"dst: '%s'\n") % (f, df))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   347
                    break
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   348
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   349
    return copy, movewithdir, diverge, renamedelete, dirmove
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   350
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
   351
# hg <= 4.9 (7694b685bb10)
4546
e7b44e9c38d2 compat: fix a typo in compat patch
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4488
diff changeset
   352
fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
   353
if not fixupstreamed:
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   354
    copies._fullcopytracing = fixedcopytracing
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   355
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   356
# help category compatibility
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   357
# hg <= 4.7 (c303d65d2e34)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   358
def helpcategorykwargs(categoryname):
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   359
    """Backwards-compatible specification of the helpategory argument."""
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   360
    category = getattr(registrar.command, categoryname, None)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   361
    if not category:
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   362
        return {}
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   363
    return {'helpcategory': category}
4957
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   364
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   365
# nodemap.get and index.[has_node|rev|get_rev]
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
   366
# hg <= 5.2 (02802fa87b74)
4957
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   367
def getgetrev(cl):
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   368
    """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial)."""
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   369
    if util.safehasattr(cl.index, 'get_rev'):
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   370
        return cl.index.get_rev
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   371
    return cl.nodemap.get
5096
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   372
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   373
@contextlib.contextmanager
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   374
def parentchange(repo):
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   375
    try:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   376
        yield
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   377
    finally:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   378
        # hg <= 5.2 (85c4cd73996b)
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   379
        if util.safehasattr(repo, '_quick_access_changeid_invalidate'):
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   380
            repo._quick_access_changeid_invalidate()