hgext3rd/topic/compat.py
author Anton Shestakov <av6@dwimlabs.net>
Fri, 06 Sep 2019 12:53:46 +0700
branchstable
changeset 4829 6b82b4f72347
parent 4743 92e3db149d7d
child 4810 03690f8d2b0a
permissions -rw-r--r--
stack: make a deep copy of `dependencies` before modifying its items The algorithm later on in this method uses .remove() to remove individual elements from items in dependencies, which before this patch modified the cached property contents. So for further use that dictionary was in the form of {1: set([])}, i.e. all sets were empty. This deep copy block could be way simpler, but the problem is that sometimes we get lists of _succs() from evolvebits.builddependencies(). Note: this happens only in topic's stack version of builddependencies() and it looks like a suboptimal way to handle multiple successors (see evolve's counterpart function). stack.builddependencies method is removed, it has served its purpose (see the previous patch).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2922
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     1
# Copyright 2017 FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     2
#
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     3
# This software may be used and distributed according to the terms of the
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     4
# GNU General Public License version 2 or any later version.
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     5
"""
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     6
Compatibility module
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     7
"""
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     8
from __future__ import absolute_import
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     9
3094
e11e018e8338 compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3064
diff changeset
    10
from mercurial import (
e11e018e8338 compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3064
diff changeset
    11
    obsolete,
4743
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    12
    pycompat,
3094
e11e018e8338 compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3064
diff changeset
    13
)
2922
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    14
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    15
getmarkers = None
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    16
successorssets = None
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    17
try:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    18
    from mercurial import obsutil
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    19
    getmarkers = getattr(obsutil, 'getmarkers', None)
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    20
    successorssets = getattr(obsutil, 'successorssets', None)
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    21
except ImportError:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    22
    pass
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    23
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    24
if getmarkers is None:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    25
    getmarkers = obsolete.getmarkers
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    26
if successorssets is None:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    27
    successorssets = obsolete.successorssets
4743
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    28
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    29
if pycompat.ispy3:
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    30
    def branchmapitems(branchmap):
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    31
        return branchmap.items()
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    32
else:
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    33
    def branchmapitems(branchmap):
92e3db149d7d py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents: 3701
diff changeset
    34
        return branchmap.iteritems()