hgext3rd/evolve/compat.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Wed, 04 Mar 2020 16:30:19 +0100
changeset 5181 c979d64a2589
parent 5180 515d425c0a05
child 5182 df5e6e3884bc
permissions -rw-r--r--
compat: drop 4.5 compatibility layer for log utility
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
import inspect
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    12
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    13
from mercurial import (
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    14
    context,
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
    15
    copies,
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,
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    18
    pycompat,
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
    19
    registrar,
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
)
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    26
if pycompat.ispy3:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    27
    arraytobytes = array.array.tobytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    28
    arrayfrombytes = array.array.frombytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    29
else:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    30
    arraytobytes = array.array.tostring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    31
    arrayfrombytes = array.array.fromstring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
    32
4956
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    33
# hg <= 5.3 (c21aca51b392)
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    34
try:
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    35
    from mercurial import pathutil
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    36
    dirs = pathutil.dirs
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
    37
except (AttributeError, ImportError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    38
    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
    39
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
from . import (
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    41
    exthelper,
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
)
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
eh = exthelper.exthelper()
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    46
# Evolution renaming compat
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    47
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    48
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
    49
    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
    50
    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
    51
    r'PHASEDIVERGENT': b'phase-divergent',
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
    52
}
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    53
5043
db341dafdccb compat: add hg version to progress compatibility code
Anton Shestakov <av6@dwimlabs.net>
parents: 5039
diff changeset
    54
# hg <= 4.6 (bec1212eceaa)
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    55
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
    56
    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
    57
        progress = ui.makeprogress(topic, unit, total)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    58
        if pos is not None:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    59
            progress.update(pos, item=item)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    60
        else:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    61
            progress.complete()
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
    62
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
    63
    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
    64
        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
    65
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    66
# 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
    67
if r'predecessors' not in dir(obsolete.obsstore):
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    68
    @property
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    69
    def predecessors(self):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    70
        return self.precursors
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    71
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
    72
    obsolete.obsstore.predecessors = predecessors
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
    73
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    74
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
    75
    # 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
    76
    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
    77
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
    78
    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
    79
        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
    80
                                  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
    81
                                  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
    82
                                  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
    83
    # 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
    84
    elif varnames[2] == r"changectx":
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    85
        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
    86
                                  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
    87
                                  isexec=b'x' in flags,
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    88
                                  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
    89
    else:
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
    90
        mctx = context.memfilectx(repo, 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
    91
                                  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
    92
                                  isexec=b'x' in flags,
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
    93
                                  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
    94
    return mctx
3408
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
    95
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    96
def strdiff(a, b, fn1, fn2):
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    97
    """ 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
    98
    """
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
    99
    args = [a, b'', b, b'', fn1, fn2]
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   100
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   101
    # 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
   102
    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
   103
        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
   104
        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
   105
    else:
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   106
        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
   107
        needsbinary = r'binary' in argspec.args
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   108
4746
724c67878d98 py3: use inspect.signature() instead of inspect.getargspec() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4745
diff changeset
   109
    if needsbinary:
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   110
        args.append(False)
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   111
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   112
    return mdiff.unidiff(*args)
3514
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   113
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   114
# 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
   115
# scmutil.bookmarkrevs
5180
515d425c0a05 compat: drop 4.5 related compatibility around wireprotocol module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 5179
diff changeset
   116
# This change is a part of 4.7 cycle, so drop this when we drop support for hg <= 4.6
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   117
try:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   118
    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
   119
except AttributeError:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   120
    bmrevset = scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   121
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   122
hg48 = util.safehasattr(copies, 'stringutil')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   123
# 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
   124
def fixedcopytracing(repo, c1, c2, base):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   125
    """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
   126
    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
   127
    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
   128
    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
   129
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   130
    from mercurial import pathutil
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   131
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   132
    # 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
   133
    # 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
   134
    # 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
   135
    # 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
   136
    # 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
   137
    # 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
   138
    # determine that here.
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
    # 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
   141
    _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
   142
    _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
   143
    # 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
   144
    # 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
   145
    # 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
   146
    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
   147
        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
   148
        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
   149
    else: # hg <= 4.6
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   150
        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
   151
        dirtyc2 = not base.descendant(_c2)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   152
    graft = dirtyc1 or dirtyc2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   153
    tca = base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   154
    if graft:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   155
        tca = _c1.ancestor(_c2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   156
4388
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   157
    # hg < 4.8 compat (dc50121126ae)
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
   158
    try:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   159
        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
   160
    except (AttributeError, TypeError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   161
        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
   162
    if limit is None:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   163
        # no common ancestor, no copies
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   164
        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
   165
    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
   166
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   167
    m1 = c1.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   168
    m2 = c2.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   169
    mb = base.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   170
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   171
    # gather data from _checkcopies:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   172
    # - 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
   173
    # - 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
   174
    # - 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
   175
    # - 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
   176
    # - incompletediverge = record divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   177
    diverge = {} # divergence data is shared
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   178
    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
   179
    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
   180
             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
   181
             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
   182
             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
   183
             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
   184
             }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   185
    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
   186
             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
   187
             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
   188
             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
   189
             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
   190
             }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   191
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   192
    # 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
   193
    if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   194
        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
   195
        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
   196
    else:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   197
        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
   198
        addedinm2 = m2.filesnotin(mb)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   199
    bothnew = sorted(addedinm1 & addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   200
    if tca == base:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   201
        # unmatched file from base
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   202
        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
   203
        u1u, u2u = u1r, u2r
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   204
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   205
        # 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
   206
        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
   207
                                             baselabel=b'base')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   208
        # 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
   209
        # 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
   210
        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
   211
        if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   212
            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
   213
            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
   214
            baselabel = b'topological common ancestor'
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   215
            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
   216
                                                 baselabel=baselabel)
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
   217
        else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   218
            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
   219
                                                 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
   220
                                                 baselabel=b'topological common ancestor')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   221
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   222
    for f in u1u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   223
        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
   224
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   225
    for f in u2u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   226
        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
   227
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
    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
   229
    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
   230
    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
   231
    fullcopy.update(data2[b'fullcopy'])
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   232
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   233
    if dirtyc1:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   234
        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
   235
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   236
    else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   237
        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
   238
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   239
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   240
    renamedelete = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   241
    renamedeleteset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   242
    divergeset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   243
    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
   244
        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
   245
            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
   246
            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
   247
                # 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
   248
                # 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
   249
                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
   250
                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
   251
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   252
            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
   253
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   254
    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
   255
        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
   256
                      % b"\n   ".join(bothnew))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   257
    bothdiverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   258
    bothincompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   259
    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
   260
    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
   261
             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
   262
             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
             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
   264
             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
   265
             }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   266
    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
   267
             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
   268
             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
   269
             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
   270
             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
   271
             }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   272
    for f in bothnew:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   273
        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
   274
        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
   275
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   276
    if dirtyc1 and dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   277
        pass
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   278
    elif dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   279
        # 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
   280
        assert not both2[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   281
        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
   282
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   283
    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
   284
        assert not both1[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
   285
        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
   286
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   287
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   288
        # 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
   289
        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
   290
        assert not both2[b'incomplete']
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   291
        assert not bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   292
    for f in remainder:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   293
        assert f not in bothdiverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   294
        ic = remainder[f]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   295
        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
   296
            # 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
   297
            bothdiverge[f] = ic
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   298
    for of, fl in bothdiverge.items():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   299
        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
   300
            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
   301
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   302
    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
   303
        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
   304
                      b"% = renamed and deleted):\n")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   305
        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
   306
            note = b""
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   307
            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
   308
                note += b"*"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   309
            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
   310
                note += b"!"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   311
            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
   312
                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
   313
            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
   314
                                                               note))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   315
    del divergeset
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   316
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   317
    if not fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   318
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   319
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
   320
    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
   321
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   322
    # generate a directory move map
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   323
    d1, d2 = c1.dirs(), c2.dirs()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   324
    # 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
   325
    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
   326
    d2.addpath(b'/')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   327
    invalid = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   328
    dirmove = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   329
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   330
    # 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
   331
    # 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
   332
    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
   333
        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
   334
        if dsrc in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   335
            # already seen to be uninteresting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   336
            continue
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   337
        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
   338
            # 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
   339
            invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   340
        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
   341
            # 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
   342
            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
   343
        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
   344
            # 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
   345
            invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   346
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   347
            # 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
   348
            dirmove[dsrc + b"/"] = ddst + b"/"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   349
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   350
    for i in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   351
        if i in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   352
            del dirmove[i]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   353
    del d1, d2, invalid
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   354
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   355
    if not dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   356
        return copy, {}, diverge, renamedelete, {}
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
    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
   359
        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
   360
                      (d, dirmove[d]))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   361
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   362
    movewithdir = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   363
    # 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
   364
    for f in u1r + u2r:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   365
        if f not in fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   366
            for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   367
                if f.startswith(d):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   368
                    # 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
   369
                    df = dirmove[d] + f[len(d):]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   370
                    if df not in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   371
                        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
   372
                        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
   373
                                       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
   374
                    break
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
    return copy, movewithdir, diverge, renamedelete, dirmove
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   377
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
   378
# hg <= 4.9 compat (7694b685bb10)
4546
e7b44e9c38d2 compat: fix a typo in compat patch
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4488
diff changeset
   379
fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
   380
if not fixupstreamed:
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   381
    copies._fullcopytracing = fixedcopytracing
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
   382
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   383
# help category compatibility
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   384
# hg <= 4.7 (c303d65d2e34)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   385
def helpcategorykwargs(categoryname):
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   386
    """Backwards-compatible specification of the helpategory argument."""
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   387
    category = getattr(registrar.command, categoryname, None)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   388
    if not category:
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   389
        return {}
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
   390
    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
   391
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   392
# nodemap.get and index.[has_node|rev|get_rev]
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   393
# hg <= 5.3 (02802fa87b74)
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   394
def getgetrev(cl):
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
   395
    """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
   396
    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
   397
        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
   398
    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
   399
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   400
@contextlib.contextmanager
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   401
def parentchange(repo):
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   402
    try:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   403
        yield
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   404
    finally:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
   405
        # 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
   406
        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
   407
            repo._quick_access_changeid_invalidate()