hgext3rd/evolve/compat.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Aug 2018 01:31:02 +0200
branchstable
changeset 3921 28824ad64a12
parent 3908 2af10d0a59e0
child 3931 b627e165ad20
permissions -rw-r--r--
compat: restore compatibility with Mercurial <= 4.5 The __init__ arguments changed a lot in 4.6 and 4.7, lets do be as transparent as possible
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
# Copyright 2017 Octobus <contact@octobus.net>
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
#
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
# This software may be used and distributed according to the terms of the
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
# GNU General Public License version 2 or any later version.
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
"""
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
Compatibility module
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
"""
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
     9
import inspect
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    10
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    11
from mercurial import (
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    12
    context,
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
    13
    copies,
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
    14
    mdiff,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
    15
    obsolete,
3693
105d2d2c6a2e compat: drop obsutile layer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3692
diff changeset
    16
    obsutil,
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
    17
    repair,
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    18
    revset,
3767
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,
3692
f9988919d69e compat: drop vfsmod compat layer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3680
diff changeset
    21
    vfs as vfsmod,
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
)
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
    23
from mercurial.hgweb import hgweb_mod
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    25
# hg < 4.6 compat (c8e2d6ed1f9e)
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    26
try:
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    27
    from mercurial import logcmdutil
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    28
    changesetdisplayer = logcmdutil.changesetdisplayer
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    29
    changesetprinter = logcmdutil.changesetprinter
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    30
    displaygraph = logcmdutil.displaygraph
3921
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3908
diff changeset
    31
    changesetdiffer = logcmdutil.changesetdiffer
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    32
except (AttributeError, ImportError):
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    33
    from mercurial import cmdutil
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    34
    changesetdisplayer = cmdutil.show_changeset
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    35
    changesetprinter = cmdutil.changeset_printer
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    36
    displaygraph = cmdutil.displaygraph
3921
28824ad64a12 compat: restore compatibility with Mercurial <= 4.5
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3908
diff changeset
    37
    changesetdiffer = None
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3408
diff changeset
    38
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
from . import (
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
    exthelper,
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
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
eh = exthelper.exthelper()
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
3283
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    45
def isobsnotesupported():
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    46
    # hack to know obsnote is supported. The patches for obsnote support was
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    47
    # pushed before the obsfateprinter patches, so this will serve as a good
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    48
    # check
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    49
    if not obsutil:
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    50
        return False
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    51
    return util.safehasattr(obsutil, 'obsfateprinter')
039c4b8dc3ed obsnote: warn if user try to store a note in obsmarker on an older hg
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3074
diff changeset
    52
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    53
# Evolution renaming compat
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    54
2854
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2849
diff changeset
    55
TROUBLES = {}
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2849
diff changeset
    56
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    57
if not util.safehasattr(context.basectx, 'orphan'):
2854
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2849
diff changeset
    58
    TROUBLES['ORPHAN'] = 'unstable'
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    59
    context.basectx.orphan = context.basectx.unstable
2854
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2849
diff changeset
    60
else:
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2849
diff changeset
    61
    TROUBLES['ORPHAN'] = 'orphan'
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    62
2835
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    63
if not util.safehasattr(context.basectx, 'contentdivergent'):
2856
f6517779a7c4 warning: rename warning message
Boris Feld <boris.feld@octobus.net>
parents: 2855
diff changeset
    64
    TROUBLES['CONTENTDIVERGENT'] = 'divergent'
2835
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    65
    context.basectx.contentdivergent = context.basectx.divergent
2856
f6517779a7c4 warning: rename warning message
Boris Feld <boris.feld@octobus.net>
parents: 2855
diff changeset
    66
else:
2858
4b934144ed11 messages: use hyphenated '{phase,content}-divergent' in user messages
Martin von Zweigbergk <martinvonz@google.com>
parents: 2856
diff changeset
    67
    TROUBLES['CONTENTDIVERGENT'] = 'content-divergent'
2835
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    68
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    69
if not util.safehasattr(context.basectx, 'phasedivergent'):
2855
1db0137297f4 warning: rename bumped warning message
Boris Feld <boris.feld@octobus.net>
parents: 2854
diff changeset
    70
    TROUBLES['PHASEDIVERGENT'] = 'bumped'
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    71
    context.basectx.phasedivergent = context.basectx.bumped
2855
1db0137297f4 warning: rename bumped warning message
Boris Feld <boris.feld@octobus.net>
parents: 2854
diff changeset
    72
else:
2858
4b934144ed11 messages: use hyphenated '{phase,content}-divergent' in user messages
Martin von Zweigbergk <martinvonz@google.com>
parents: 2856
diff changeset
    73
    TROUBLES['PHASEDIVERGENT'] = 'phase-divergent'
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    74
2839
f9c8c754a528 context: troubled was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2836
diff changeset
    75
if not util.safehasattr(context.basectx, 'isunstable'):
f9c8c754a528 context: troubled was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2836
diff changeset
    76
    context.basectx.isunstable = context.basectx.troubled
f9c8c754a528 context: troubled was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2836
diff changeset
    77
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    78
if not util.safehasattr(revset, 'orphan'):
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    79
    @eh.revset('orphan')
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    80
    def oprhanrevset(*args, **kwargs):
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    81
        return revset.unstable(*args, **kwargs)
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    82
2835
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    83
if not util.safehasattr(revset, 'contentdivergent'):
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    84
    @eh.revset('contentdivergent')
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    85
    def contentdivergentrevset(*args, **kwargs):
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    86
        return revset.divergent(*args, **kwargs)
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
    87
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    88
if not util.safehasattr(revset, 'phasedivergent'):
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    89
    @eh.revset('phasedivergent')
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    90
    def phasedivergentrevset(*args, **kwargs):
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    91
        return revset.bumped(*args, **kwargs)
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
    92
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    93
if not util.safehasattr(context.basectx, 'instabilities'):
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    94
    def instabilities(self):
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    95
        """return the list of instabilities affecting this changeset.
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    96
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    97
        Instabilities are returned as strings. possible values are:
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    98
         - orphan,
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
    99
         - phase-divergent,
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   100
         - content-divergent.
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   101
         """
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   102
        instabilities = []
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   103
        if self.orphan():
2849
95470e817c00 compat: fix instabilities compat
Boris Feld <boris.feld@octobus.net>
parents: 2847
diff changeset
   104
            instabilities.append('orphan')
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
   105
        if self.phasedivergent():
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
   106
            instabilities.append('phase-divergent')
2835
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
   107
        if self.contentdivergent():
20c2499ce8bc log: divergent was renamed into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents: 2834
diff changeset
   108
            instabilities.append('content-divergent')
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   109
        return instabilities
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   110
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
   111
    context.basectx.instabilities = instabilities
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   112
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   113
# XXX: Better detection of property cache
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   114
if 'predecessors' not in dir(obsolete.obsstore):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   115
    @property
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   116
    def predecessors(self):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   117
        return self.precursors
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   118
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
   119
    obsolete.obsstore.predecessors = predecessors
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
   120
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
   121
if not util.safehasattr(obsolete, '_computeorphanset'):
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
   122
    obsolete._computeorphanset = obsolete.cachefor('orphan')(obsolete._computeunstableset)
2846
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
   123
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
   124
if not util.safehasattr(obsolete, '_computecontentdivergentset'):
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
   125
    obsolete._computecontentdivergentset = obsolete.cachefor('contentdivergent')(obsolete._computedivergentset)
2847
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
   126
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
   127
if not util.safehasattr(obsolete, '_computephasedivergentset'):
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
   128
    obsolete._computephasedivergentset = obsolete.cachefor('phasedivergent')(obsolete._computebumpedset)
3064
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2858
diff changeset
   129
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   130
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
   131
    # XXX Would it be better at the module level?
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   132
    varnames = context.memfilectx.__init__.__code__.co_varnames
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   133
    ctxmandatory = varnames[2] == "changectx"
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   134
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   135
    if ctxmandatory:
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   136
        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   137
                                  islink='l' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   138
                                  isexec='x' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   139
                                  copied=copied.get(path))
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   140
    else:
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   141
        mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   142
                                  islink='l' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   143
                                  isexec='x' in flags,
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   144
                                  copied=copied.get(path))
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
   145
    return mctx
3408
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   146
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   147
def getcachevfs(repo):
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   148
    cachevfs = getattr(repo, 'cachevfs', None)
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   149
    if cachevfs is None:
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   150
        cachevfs = vfsmod.vfs(repo.vfs.join('cache'))
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   151
        cachevfs.createmode = repo.store.createmode
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
   152
    return cachevfs
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   153
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   154
def strdiff(a, b, fn1, fn2):
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   155
    """ 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
   156
    """
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   157
    args = [a, '', b, '', fn1, fn2]
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   158
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   159
    # hg < 4.6 compat 8b6dd3922f70
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   160
    argspec = inspect.getargspec(mdiff.unidiff)
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   161
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   162
    if 'binary' in argspec.args:
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   163
        args.append(False)
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   164
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
   165
    return mdiff.unidiff(*args)
3514
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   166
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   167
# date related
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   168
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   169
try:
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   170
    import mercurial.utils.dateutil
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   171
    makedate = mercurial.utils.dateutil.makedate
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   172
    parsedate = mercurial.utils.dateutil.parsedate
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   173
except ImportError as e:
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   174
    import mercurial.util
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   175
    makedate = mercurial.util.makedate
498f782ccb4b compat: add compat layer for date related functions
Boris Feld <boris.feld@octobus.net>
parents: 3499
diff changeset
   176
    parsedate = mercurial.util.parsedate
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   177
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   178
def wireprotocommand(exthelper, name, args='', permission='pull'):
3680
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   179
    try:
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   180
        # Since b4d85bc1
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   181
        from mercurial.wireprotov1server import wireprotocommand
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   182
        return wireprotocommand(name, args, permission=permission)
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   183
    except (ImportError, AttributeError):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   184
        from mercurial import wireproto
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   185
3524
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   186
    if 3 <= len(wireproto.wireprotocommand.func_defaults):
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   187
        return wireproto.wireprotocommand(name, args, permission=permission)
6d4095e6bdd3 obsdiscovery: add compatibility layer to register wireproto command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3514
diff changeset
   188
3680
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   189
    # <= hg-4.5 permission must be registered in dictionnary
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   190
    def decorator(func):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   191
        @eh.extsetup
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   192
        def install(ui):
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   193
            hgweb_mod.perms[name] = permission
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   194
            wireproto.commands[name] = (func, args)
e2a91d4d207d evolve: handle wireproto module deletion for registering new commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3668
diff changeset
   195
    return decorator
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   196
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   197
# mercurial <= 4.5 do not have the updateresult object
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   198
try:
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   199
    from mercurial.merge import updateresult
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   200
except (ImportError, AttributeError):
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   201
    updateresult = None
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   202
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   203
# 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
   204
# scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   205
# This change is a part of 4.7 cycle, so drop this when we drop support for 4.6
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   206
try:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   207
    bmrevset = repair.stripbmrevset
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   208
except AttributeError:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   209
    bmrevset = scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
   210
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   211
def hasconflict(upres):
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   212
    if updateresult is None:
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   213
        return bool(upres[-1])
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3575
diff changeset
   214
    return bool(upres.unresolvedcount)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   215
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   216
# 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
   217
def fixedcopytracing(repo, c1, c2, base):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   218
    """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
   219
    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
   220
    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
   221
    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
   222
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   223
    from mercurial import pathutil
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
    # 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
   226
    # 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
   227
    # 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
   228
    # 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
   229
    # 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
   230
    # 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
   231
    # determine that here.
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
    # 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
   234
    _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
   235
    _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
   236
    # 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
   237
    # 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
   238
    # 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
   239
    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
   240
        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
   241
        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
   242
    else: # hg <= 4.6
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
   243
        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
   244
        dirtyc2 = not base.descendant(_c2)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   245
    graft = dirtyc1 or dirtyc2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   246
    tca = base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   247
    if graft:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   248
        tca = _c1.ancestor(_c2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   249
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   250
    limit = copies._findlimit(repo, c1.rev(), c2.rev())
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   251
    if limit is None:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   252
        # no common ancestor, no copies
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   253
        return {}, {}, {}, {}, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   254
    repo.ui.debug("  searching for copies back to rev %d\n" % limit)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   255
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   256
    m1 = c1.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   257
    m2 = c2.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   258
    mb = base.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   259
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   260
    # gather data from _checkcopies:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   261
    # - 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
   262
    # - 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
   263
    # - 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
   264
    # - 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
   265
    # - incompletediverge = record divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   266
    diverge = {} # divergence data is shared
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   267
    incompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   268
    data1 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   269
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   270
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   271
             'diverge': diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   272
             'incompletediverge': incompletediverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   273
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   274
    data2 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   275
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   276
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   277
             'diverge': diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   278
             'incompletediverge': incompletediverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   279
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   280
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   281
    # find interesting file sets from manifests
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   282
    addedinm1 = m1.filesnotin(mb)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   283
    addedinm2 = m2.filesnotin(mb)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   284
    bothnew = sorted(addedinm1 & addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   285
    if tca == base:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   286
        # unmatched file from base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   287
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   288
        u1u, u2u = u1r, u2r
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   289
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   290
        # unmatched file from base (DAG rotation in the graft case)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   291
        u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   292
                                             baselabel='base')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   293
        # 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
   294
        # 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
   295
        mta = tca.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   296
        u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1.filesnotin(mta),
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   297
                                             m2.filesnotin(mta),
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   298
                                             baselabel='topological common ancestor')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   299
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   300
    for f in u1u:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   301
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, data1)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   302
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   303
    for f in u2u:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   304
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   305
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   306
    copy = dict(data1['copy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   307
    copy.update(data2['copy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   308
    fullcopy = dict(data1['fullcopy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   309
    fullcopy.update(data2['fullcopy'])
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   310
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   311
    if dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   312
        copies._combinecopies(data2['incomplete'], data1['incomplete'], copy, diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   313
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   314
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   315
        copies._combinecopies(data1['incomplete'], data2['incomplete'], copy, diverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   316
                              incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   317
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   318
    renamedelete = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   319
    renamedeleteset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   320
    divergeset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   321
    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
   322
        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
   323
            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
   324
            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
   325
                # 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
   326
                # 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
   327
                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
   328
                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
   329
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   330
            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
   331
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   332
    if bothnew:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   333
        repo.ui.debug("  unmatched files new in both:\n   %s\n"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   334
                      % "\n   ".join(bothnew))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   335
    bothdiverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   336
    bothincompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   337
    remainder = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   338
    both1 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   339
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   340
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   341
             'diverge': bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   342
             'incompletediverge': bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   343
            }
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   344
    both2 = {'copy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   345
             'fullcopy': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   346
             'incomplete': {},
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   347
             'diverge': bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   348
             'incompletediverge': bothincompletediverge
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 f in bothnew:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   351
        copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, both1)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   352
        copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, both2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   353
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   354
    if dirtyc1 and dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   355
        pass
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   356
    elif dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   357
        # incomplete copies may only be found on the "dirty" side for bothnew
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   358
        assert not both2['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   359
        remainder = copies._combinecopies({}, both1['incomplete'], copy, bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   360
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   361
    elif dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   362
        assert not both1['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   363
        remainder = copies._combinecopies({}, both2['incomplete'], copy, bothdiverge,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   364
                                          bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   365
    else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   366
        # incomplete copies and divergences can't happen outside grafts
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   367
        assert not both1['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   368
        assert not both2['incomplete']
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   369
        assert not bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   370
    for f in remainder:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   371
        assert f not in bothdiverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   372
        ic = remainder[f]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   373
        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
   374
            # 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
   375
            bothdiverge[f] = ic
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   376
    for of, fl in bothdiverge.items():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   377
        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
   378
            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
   379
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   380
    if fullcopy and repo.ui.debugflag:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   381
        repo.ui.debug("  all copies found (* = to merge, ! = divergent, "
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   382
                      "% = renamed and deleted):\n")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   383
        for f in sorted(fullcopy):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   384
            note = ""
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   385
            if f in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   386
                note += "*"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   387
            if f in divergeset:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   388
                note += "!"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   389
            if f in renamedeleteset:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   390
                note += "%"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   391
            repo.ui.debug("   src: '%s' -> dst: '%s' %s\n" % (fullcopy[f], f,
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   392
                                                              note))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   393
    del divergeset
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   394
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   395
    if not fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   396
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   397
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   398
    repo.ui.debug("  checking for directory renames\n")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   399
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   400
    # generate a directory move map
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   401
    d1, d2 = c1.dirs(), c2.dirs()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   402
    # Hack for adding '', which is not otherwise added, to d1 and d2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   403
    d1.addpath('/')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   404
    d2.addpath('/')
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   405
    invalid = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   406
    dirmove = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   407
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   408
    # 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
   409
    # when all the files in a directory are moved to a new directory
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   410
    for dst, src in fullcopy.iteritems():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   411
        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
   412
        if dsrc in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   413
            # already seen to be uninteresting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   414
            continue
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   415
        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
   416
            # directory wasn't entirely moved locally
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   417
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   418
        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
   419
            # directory wasn't entirely moved remotely
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   420
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   421
        elif dsrc + "/" in dirmove and dirmove[dsrc + "/"] != ddst + "/":
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   422
            # files from the same directory moved to two different places
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   423
            invalid.add(dsrc + "/")
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   424
        else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   425
            # looks good so far
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   426
            dirmove[dsrc + "/"] = ddst + "/"
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   427
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   428
    for i in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   429
        if i in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   430
            del dirmove[i]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   431
    del d1, d2, invalid
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   432
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   433
    if not dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   434
        return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   435
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   436
    for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   437
        repo.ui.debug("   discovered dir src: '%s' -> dst: '%s'\n" %
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   438
                      (d, dirmove[d]))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   439
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   440
    movewithdir = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   441
    # 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
   442
    for f in u1r + u2r:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   443
        if f not in fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   444
            for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   445
                if f.startswith(d):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   446
                    # 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
   447
                    df = dirmove[d] + f[len(d):]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   448
                    if df not in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   449
                        movewithdir[f] = df
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   450
                        repo.ui.debug(("   pending file src: '%s' -> "
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   451
                                       "dst: '%s'\n") % (f, df))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   452
                    break
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   453
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   454
    return copy, movewithdir, diverge, renamedelete, dirmove
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   455
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   456
if util.safehasattr(copies, '_fullcopytracing'):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
   457
    copies._fullcopytracing = fixedcopytracing