annotate hgext3rd/evolve/compat.py @ 5608:d9ee2706487f stable

compat: add support for upstream rename of merge.update() to _update() The function was renamed in Mercurial commit 2c86b9587740.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 25 Sep 2020 09:13:57 -0700
parents d83b24d38853
children 24a1ff0677a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
1 # Copyright 2017 Octobus <contact@octobus.net>
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
2 #
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
3 # This software may be used and distributed according to the terms of the
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
4 # GNU General Public License version 2 or any later version.
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
5 """
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
6 Compatibility module
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
7 """
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
8
5096
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
9 import array
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
10 import contextlib
3499
512706514555 obsfate: fix changeset description diff computing
Boris Feld <boris.feld@octobus.net>
parents: 3483
diff changeset
11
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
12 from mercurial import (
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
13 context,
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
14 copies,
5431
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
15 merge as mergemod,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
16 obsolete,
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
17 pycompat,
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
18 registrar,
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
19 repair,
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
20 scmutil,
2751
4f560f117fff compat: use 'safehasattr' over 'hasattr'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2693
diff changeset
21 util,
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
22 ui as uimod,
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
23 )
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
24
4745
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
25 if pycompat.ispy3:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
26 arraytobytes = array.array.tobytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
27 arrayfrombytes = array.array.frombytes
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
28 else:
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
29 arraytobytes = array.array.tostring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
30 arrayfrombytes = array.array.fromstring
854637e3d2d0 py3: use array.array.{to,from}bytes() on py3
Martin von Zweigbergk <martinvonz@google.com>
parents: 4716
diff changeset
31
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
32 # hg <= 5.2 (c21aca51b392)
4956
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
33 try:
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
34 from mercurial import pathutil
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
35 dirs = pathutil.dirs
0fe5d74134d6 compat: compatibility for pathuril.dirs vs util.dirs
Anton Shestakov <av6@dwimlabs.net>
parents: 4814
diff changeset
36 except (AttributeError, ImportError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
37 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
38
5431
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
39 # hg <= 5.4 (b7808443ed6a)
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
40 try:
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
41 from mercurial import mergestate as mergestatemod
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
42 mergestate = mergestatemod.mergestate
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
43 except (AttributeError, ImportError):
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
44 mergestate = mergemod.mergestate # pytype: disable=module-attr
b34af5087714 compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents: 5193
diff changeset
45
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
46 from . import (
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
47 exthelper,
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
48 )
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
49
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
50 eh = exthelper.exthelper()
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
51
2834
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
52 # Evolution renaming compat
38db1466c6fb log: unstable was renamed into orphan
Boris Feld <boris.feld@octobus.net>
parents: 2794
diff changeset
53
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
54 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
55 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
56 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
57 r'PHASEDIVERGENT': b'phase-divergent',
4429
e10ebc58926e compat: remove old vocabulary change fallbacks
Anton Shestakov <av6@dwimlabs.net>
parents: 4388
diff changeset
58 }
2836
feaa52680682 log: bumped was renamed into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents: 2835
diff changeset
59
5043
db341dafdccb compat: add hg version to progress compatibility code
Anton Shestakov <av6@dwimlabs.net>
parents: 5039
diff changeset
60 # hg <= 4.6 (bec1212eceaa)
4341
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
61 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
62 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
63 progress = ui.makeprogress(topic, unit, total)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
64 if pos is not None:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
65 progress.update(pos, item=item)
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
66 else:
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
67 progress.complete()
d1aab9d82f5b evolve: adapt for deprecated ui.progress()
Martin von Zweigbergk <martinvonz@google.com>
parents: 4328
diff changeset
68 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
69 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
70 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
71
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
72 # 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
73 if r'predecessors' not in dir(obsolete.obsstore):
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
74 @property
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
75 def predecessors(self):
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
76 return self.precursors
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
77
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2839
diff changeset
78 obsolete.obsstore.predecessors = predecessors
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2841
diff changeset
79
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
80 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
81 # 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
82 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
83
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 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
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,
4460
dd679f5fc96f compat: add support for new arg name in memfilectx.__init__
Martin von Zweigbergk <martinvonz@google.com>
parents: 4388
diff changeset
88 copysource=copied.get(path))
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
89 # hg <= 4.9 (550a172a603b)
4804
079dbf36e884 python3: add raw prefix in cases harder to analyze at the token level
Raphaël Gomès <rgomes@octobus.net>
parents: 4746
diff changeset
90 elif varnames[2] == r"changectx":
3298
f4b06f44d274 memfilectx: changectx argument is not mandatory
Boris Feld <boris.feld@octobus.net>
parents: 3283
diff changeset
91 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
92 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
93 isexec=b'x' in flags,
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
94 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
95 return mctx
3408
f4ea9652661d cachevfs: use a compatibility later for all access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
96
3767
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
97 try:
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
98 # hg <= 4.6 (46c2b19a1263)
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
99 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
100 except AttributeError:
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
101 bmrevset = scmutil.bookmarkrevs
115caa4e5278 evolve: add compat for repair.stripbmrevset which is moved to scmutil
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3701
diff changeset
102
4223
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
103 hg48 = util.safehasattr(copies, 'stringutil')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
104 # 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
105 def fixedcopytracing(repo, c1, c2, base):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
106 """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
107 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
108 converted in a compat function once https://phab.mercurial-scm.org/D3896
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
109 gets in and once we drop support for 4.6, this should be removed."""
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
110
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
111 from mercurial import pathutil
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
112
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
113 # 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
114 # 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
115 # 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
116 # 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
117 # 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
118 # 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
119 # determine that here.
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
120 #
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
121 # 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
122 _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
123 _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
124 # 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
125 # 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
126 # 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
127 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
128 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
129 dirtyc2 = not base.isancestorof(_c2)
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
130 else: # hg <= 4.6 (fbec9c0b32d3)
3908
2af10d0a59e0 compat: use older API for older version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3882
diff changeset
131 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
132 dirtyc2 = not base.descendant(_c2)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
133 graft = dirtyc1 or dirtyc2
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
134 tca = base
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
135 if graft:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
136 tca = _c1.ancestor(_c2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
137
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
138 # hg <= 4.9 (dc50121126ae)
4388
20d1ceef2df2 compat: pass contexts to _findlimit() (issue6066)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4341
diff changeset
139 try:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
140 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
141 except (AttributeError, TypeError):
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
142 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
143 if limit is None:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
144 # no common ancestor, no copies
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
145 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
146 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
147
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
148 m1 = c1.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
149 m2 = c2.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
150 mb = base.manifest()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
151
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
152 # gather data from _checkcopies:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
153 # - 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
154 # - 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
155 # - 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
156 # - 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
157 # - incompletediverge = record divergent partial copies here
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
158 diverge = {} # divergence data is shared
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
159 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
160 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
161 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
162 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
163 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
164 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
165 }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
166 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
167 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
168 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
169 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
170 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
171 }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
172
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
173 # 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
174 if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
175 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
176 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
177 else:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
178 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
179 addedinm2 = m2.filesnotin(mb)
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
180 bothnew = sorted(addedinm1 & addedinm2)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
181 if tca == base:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
182 # unmatched file from base
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
183 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
184 u1u, u2u = u1r, u2r
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
185 else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
186 # 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
187 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
188 baselabel=b'base')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
189 # 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
190 # 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
191 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
192 if hg48:
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
193 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
194 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
195 baselabel = b'topological common ancestor'
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
196 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
197 baselabel=baselabel)
4a3d588e5311 compat: fix fixedcopytracing compatibility with mercurial 4.8 and narrow
Boris Feld <boris.feld@octobus.net>
parents: 3932
diff changeset
198 else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
199 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
200 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
201 baselabel=b'topological common ancestor')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
202
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
203 for f in u1u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
204 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
205
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
206 for f in u2u:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
207 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
208
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
209 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
210 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
211 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
212 fullcopy.update(data2[b'fullcopy'])
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
213
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
214 if dirtyc1:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
215 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
216 incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
217 else:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
218 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
219 incompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
220
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
221 renamedelete = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
222 renamedeleteset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
223 divergeset = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
224 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
225 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
226 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
227 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
228 # 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
229 # 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
230 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
231 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
232 else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
233 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
234
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
235 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
236 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
237 % b"\n ".join(bothnew))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
238 bothdiverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
239 bothincompletediverge = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
240 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
241 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
242 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
243 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
244 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
245 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
246 }
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
247 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
248 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
249 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
250 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
251 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
252 }
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
253 for f in bothnew:
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
254 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
255 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
256
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
257 if dirtyc1 and dirtyc2:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
258 pass
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
259 elif dirtyc1:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
260 # 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
261 assert not both2[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
262 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
263 bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
264 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
265 assert not both1[b'incomplete']
5039
778286176016 compat: ask pytype to ignore some warnings
Anton Shestakov <av6@dwimlabs.net>
parents: 4963
diff changeset
266 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
267 bothincompletediverge)
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
268 else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
269 # 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
270 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
271 assert not both2[b'incomplete']
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
272 assert not bothincompletediverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
273 for f in remainder:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
274 assert f not in bothdiverge
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
275 ic = remainder[f]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
276 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
277 # 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
278 bothdiverge[f] = ic
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
279 for of, fl in bothdiverge.items():
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
280 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
281 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
282
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
283 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
284 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
285 b"% = renamed and deleted):\n")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
286 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
287 note = b""
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
288 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
289 note += b"*"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
290 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
291 note += b"!"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
292 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
293 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
294 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
295 note))
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
296 del divergeset
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
297
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
298 if not fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
299 return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
300
4814
48b30ff742cb python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents: 4805
diff changeset
301 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
302
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
303 # generate a directory move map
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
304 d1, d2 = c1.dirs(), c2.dirs()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
305 # 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
306 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
307 d2.addpath(b'/')
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
308 invalid = set()
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
309 dirmove = {}
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 # 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
312 # 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
313 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
314 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
315 if dsrc in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
316 # already seen to be uninteresting
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
317 continue
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
318 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
319 # 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
320 invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
321 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
322 # 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
323 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
324 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
325 # 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
326 invalid.add(dsrc + b"/")
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
327 else:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
328 # 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
329 dirmove[dsrc + b"/"] = ddst + b"/"
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
330
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
331 for i in invalid:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
332 if i in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
333 del dirmove[i]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
334 del d1, d2, invalid
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
335
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
336 if not dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
337 return copy, {}, diverge, renamedelete, {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
338
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
339 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
340 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
341 (d, dirmove[d]))
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
342
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
343 movewithdir = {}
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
344 # 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
345 for f in u1r + u2r:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
346 if f not in fullcopy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
347 for d in dirmove:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
348 if f.startswith(d):
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
349 # 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
350 df = dirmove[d] + f[len(d):]
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
351 if df not in copy:
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
352 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
353 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
354 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
355 break
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
356
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
357 return copy, movewithdir, diverge, renamedelete, dirmove
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
358
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
359 # hg <= 4.9 (7694b685bb10)
4546
e7b44e9c38d2 compat: fix a typo in compat patch
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4488
diff changeset
360 fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
4439
2eafdca7ba4b evolve: preserve compatibility for hg < 4.8 versions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 4429
diff changeset
361 if not fixupstreamed:
3882
55b8c7e7e352 compat: temporarily move copies fix to compat.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3767
diff changeset
362 copies._fullcopytracing = fixedcopytracing
3932
35b2d201eb71 compat: fix obslog compatiblity with 4.3
Boris Feld <boris.feld@octobus.net>
parents: 3931
diff changeset
363
4894
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
364 # help category compatibility
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
365 # hg <= 4.7 (c303d65d2e34)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
366 def helpcategorykwargs(categoryname):
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
367 """Backwards-compatible specification of the helpategory argument."""
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
368 category = getattr(registrar.command, categoryname, None)
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
369 if not category:
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
370 return {}
f9743b13de6d help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents: 4814
diff changeset
371 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
372
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
373 # nodemap.get and index.[has_node|rev|get_rev]
5193
a4d081923c81 compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents: 5190
diff changeset
374 # hg <= 5.2 (02802fa87b74)
4957
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
375 def getgetrev(cl):
e8302f760a54 compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents: 4956
diff changeset
376 """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
377 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
378 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
379 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
380
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
381 @contextlib.contextmanager
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
382 def parentchange(repo):
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
383 try:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
384 yield
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
385 finally:
6742ce189373 compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents: 4957
diff changeset
386 # 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
387 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
388 repo._quick_access_changeid_invalidate()
5548
7370725cdba7 compat: add a cleanupnodes() function
Martin von Zweigbergk <martinvonz@google.com>
parents: 5431
diff changeset
389
7370725cdba7 compat: add a cleanupnodes() function
Martin von Zweigbergk <martinvonz@google.com>
parents: 5431
diff changeset
390 def cleanupnodes(repo, replacements, operation, moves=None, metadata=None):
5549
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
391 # Use this condition as a proxy since the commit we care about
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
392 # (b99903534e06) didn't change any signatures.
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
393 if util.safehasattr(scmutil, 'nullrev'):
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
394 fixedreplacements = replacements
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
395 else:
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
396 # hg <= 4.7 (b99903534e06)
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
397 fixedreplacements = {}
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
398 for oldnodes, newnodes in replacements.items():
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
399 for oldnode in oldnodes:
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
400 fixedreplacements[oldnode] = newnodes
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
401
d83b24d38853 compat: let cleanupnodes() handle compat across hg commit b99903534e06
Martin von Zweigbergk <martinvonz@google.com>
parents: 5548
diff changeset
402 scmutil.cleanupnodes(repo, replacements=fixedreplacements, operation=operation,
5548
7370725cdba7 compat: add a cleanupnodes() function
Martin von Zweigbergk <martinvonz@google.com>
parents: 5431
diff changeset
403 moves=moves, metadata=metadata)
5608
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
404
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
405 if util.safehasattr(mergemod, '_update'):
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
406 def update(*args, **kwargs):
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
407 return mergemod._update(*args, **kwargs)
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
408 else:
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
409 # hg <= 5.5 (2c86b9587740)
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
410 def update(*args, **kwargs):
d9ee2706487f compat: add support for upstream rename of merge.update() to _update()
Martin von Zweigbergk <martinvonz@google.com>
parents: 5549
diff changeset
411 return mergemod.update(*args, **kwargs)