2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2011-02-10 22:46:27 +03:00
|
|
|
# Mercurial bookmark support code
|
|
|
|
#
|
|
|
|
# Copyright 2008 David Soria Parra <dsp@php.net>
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
2015-08-08 05:49:21 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-10-14 19:51:04 +04:00
|
|
|
import errno
|
2017-10-15 15:59:55 +03:00
|
|
|
import struct
|
2020-01-31 05:39:19 +03:00
|
|
|
import typing
|
2015-08-08 05:49:21 +03:00
|
|
|
|
|
|
|
from . import (
|
|
|
|
encoding,
|
2016-06-14 00:50:26 +03:00
|
|
|
error,
|
2015-08-08 05:49:21 +03:00
|
|
|
lock as lockmod,
|
2019-03-08 14:01:08 +03:00
|
|
|
mutation,
|
2017-06-27 02:40:34 +03:00
|
|
|
obsutil,
|
2017-06-24 17:25:01 +03:00
|
|
|
pycompat,
|
2017-06-11 09:32:58 +03:00
|
|
|
scmutil,
|
bookmarks: check HG_PENDING strictly
Before this patch, checking HG_PENDING in bookmarks.py might cause
unintentional reading unrelated '.hg/bookmarks.pending' in, because it
just examines existence of HG_PENDING environment variable.
This patch uses txnutil.trypending() to check HG_PENDING strictly.
This patch also changes share extension.
Enabling share extension (+ bookmark sharing) makes
bookmarks._getbkfile() receive repo to be shared (= "srcrepo"). On the
other hand, HG_PENDING always refers current working repo (=
"currepo"), and bookmarks.pending is written only into currepo.
Therefore, we should try to read .hg/bookmarks.pending of currepo in
at first. If it doesn't exist, we try to read .hg/bookmarks of srcrepo
in.
Even after this patch, an external hook spawned in currepo can't see
pending changes in currepo via srcrepo, even though such changes
become visible after closing transaction, because there is no easy and
cheap way to know existence of pending changes in currepo via srcrepo.
Please see https://www.mercurial-scm.org/wiki/SharedRepository, too.
BTW, this patch may cause failure of bisect in the repository of
Mercurial itself, if examination at bisecting assumes that an external
hook can see all pending changes while nested transactions across
repositories.
This invisibility issue will be fixed by subsequent patch, which
allows HG_PENDING to refer multiple repositories.
2017-02-20 19:21:00 +03:00
|
|
|
txnutil,
|
2015-08-08 05:49:21 +03:00
|
|
|
util,
|
|
|
|
)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from .i18n import _
|
2020-03-26 18:23:49 +03:00
|
|
|
from .node import bin, hex, nullid, short, wdirid
|
2020-01-29 18:38:41 +03:00
|
|
|
from .pycompat import decodeutf8, encodeutf8
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-02-10 22:46:27 +03:00
|
|
|
|
2017-06-21 01:56:29 +03:00
|
|
|
# label constants
|
|
|
|
# until 3.5, bookmarks.current was the advertised name, not
|
|
|
|
# bookmarks.active, so we must use both to avoid breaking old
|
|
|
|
# custom styles
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
activebookmarklabel = "bookmarks.active bookmarks.current"
|
|
|
|
|
2020-03-26 18:23:49 +03:00
|
|
|
# namespace to use when recording an hg journal entry
|
|
|
|
journalremotebookmarktype = "remotebookmark"
|
|
|
|
|
2020-03-26 18:23:49 +03:00
|
|
|
# name of the file that is used to mark that transition to selectivepull has
|
|
|
|
# happened
|
|
|
|
_selectivepullenabledfile = "selectivepullenabled"
|
|
|
|
_selectivepullenabledfilelock = "selectivepullenabled.lock"
|
|
|
|
_selectivepullaccessedbookmarks = "selectivepullaccessedbookmarks"
|
|
|
|
# separate lock to update accessed bookmarks
|
|
|
|
_selectivepullaccessedbookmarkslock = "selectivepullaccessedbookmarks.lock"
|
|
|
|
|
2017-06-21 01:56:29 +03:00
|
|
|
|
2015-11-12 04:45:38 +03:00
|
|
|
def _getbkfile(repo):
|
|
|
|
"""Hook so that extensions that mess with the store can hook bm storage.
|
|
|
|
|
|
|
|
For core, this just handles wether we should see pending
|
|
|
|
bookmarks or the committed ones. Other extensions (like share)
|
|
|
|
may need to tweak this behavior further.
|
|
|
|
"""
|
2018-09-28 17:08:38 +03:00
|
|
|
|
2019-11-27 22:34:50 +03:00
|
|
|
fp, pending = txnutil.trypending(repo.root, repo.svfs, "bookmarks")
|
bookmarks: check HG_PENDING strictly
Before this patch, checking HG_PENDING in bookmarks.py might cause
unintentional reading unrelated '.hg/bookmarks.pending' in, because it
just examines existence of HG_PENDING environment variable.
This patch uses txnutil.trypending() to check HG_PENDING strictly.
This patch also changes share extension.
Enabling share extension (+ bookmark sharing) makes
bookmarks._getbkfile() receive repo to be shared (= "srcrepo"). On the
other hand, HG_PENDING always refers current working repo (=
"currepo"), and bookmarks.pending is written only into currepo.
Therefore, we should try to read .hg/bookmarks.pending of currepo in
at first. If it doesn't exist, we try to read .hg/bookmarks of srcrepo
in.
Even after this patch, an external hook spawned in currepo can't see
pending changes in currepo via srcrepo, even though such changes
become visible after closing transaction, because there is no easy and
cheap way to know existence of pending changes in currepo via srcrepo.
Please see https://www.mercurial-scm.org/wiki/SharedRepository, too.
BTW, this patch may cause failure of bisect in the repository of
Mercurial itself, if examination at bisecting assumes that an external
hook can see all pending changes while nested transactions across
repositories.
This invisibility issue will be fixed by subsequent patch, which
allows HG_PENDING to refer multiple repositories.
2017-02-20 19:21:00 +03:00
|
|
|
return fp
|
2015-11-12 04:45:38 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-11-08 02:21:39 +04:00
|
|
|
class bmstore(dict):
|
|
|
|
"""Storage for bookmarks.
|
2011-02-10 22:46:27 +03:00
|
|
|
|
2015-11-12 05:18:02 +03:00
|
|
|
This object should do all bookmark-related reads and writes, so
|
|
|
|
that it's fairly simple to replace the storage underlying
|
|
|
|
bookmarks without having to clone the logic surrounding
|
|
|
|
bookmarks. This type also should manage the active bookmark, if
|
|
|
|
any.
|
2012-11-08 02:21:39 +04:00
|
|
|
|
|
|
|
This particular bmstore implementation stores bookmarks as
|
|
|
|
{hash}\s{name}\n (the same format as localtags) in
|
|
|
|
.hg/bookmarks. The mapping is stored as {name: nodeid}.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, repo):
|
2020-04-21 19:16:34 +03:00
|
|
|
if util.istest():
|
|
|
|
repo.hook("pre-bookmark-load", throw=True)
|
2012-11-08 02:21:39 +04:00
|
|
|
dict.__init__(self)
|
|
|
|
self._repo = repo
|
2017-06-07 21:32:16 +03:00
|
|
|
self._clean = True
|
|
|
|
self._aclean = True
|
2017-06-08 00:26:43 +03:00
|
|
|
nm = repo.changelog.nodemap
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
tonode = bin # force local lookup
|
2017-06-07 21:13:09 +03:00
|
|
|
setitem = dict.__setitem__
|
2012-11-08 02:21:39 +04:00
|
|
|
try:
|
2017-06-10 03:59:22 +03:00
|
|
|
with _getbkfile(repo) as bkfile:
|
|
|
|
for line in bkfile:
|
2020-01-29 18:38:41 +03:00
|
|
|
line = decodeutf8(line)
|
2017-06-10 03:59:22 +03:00
|
|
|
line = line.strip()
|
|
|
|
if not line:
|
|
|
|
continue
|
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sha, refspec = line.split(" ", 1)
|
2017-06-10 03:59:22 +03:00
|
|
|
node = tonode(sha)
|
|
|
|
except (TypeError, ValueError):
|
|
|
|
# TypeError:
|
|
|
|
# - bin(...)
|
|
|
|
# ValueError:
|
|
|
|
# - node in nm, for non-20-bytes entry
|
|
|
|
# - split(...), for string without ' '
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
repo.ui.warn(_("malformed line in .hg/bookmarks: %r\n") % line)
|
2020-04-21 19:16:34 +03:00
|
|
|
else:
|
|
|
|
if node in nm:
|
|
|
|
refspec = encoding.tolocal(refspec)
|
|
|
|
setitem(self, refspec, node)
|
|
|
|
else:
|
|
|
|
# This might happen if:
|
|
|
|
# - changelog was loaded, bookmarks are not loaded
|
|
|
|
# - bookmarks was changed to point to unknown nodes
|
|
|
|
# - bookmarks are loaded
|
|
|
|
#
|
|
|
|
# Try to mitigate by reloading changelog.
|
|
|
|
repo.invalidate(clearfilecache=True)
|
|
|
|
nm = repo.changelog.nodemap
|
|
|
|
if node in nm:
|
|
|
|
refspec = encoding.tolocal(refspec)
|
|
|
|
setitem(self, refspec, node)
|
|
|
|
repo.ui.log(
|
|
|
|
"features", feature="fix-bookmark-changelog-order"
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
repo.ui.log(
|
|
|
|
"features",
|
|
|
|
feature="fix-bookmark-changelog-order-failed",
|
|
|
|
)
|
|
|
|
repo.ui.warn(
|
|
|
|
_("unknown reference in .hg/bookmarks: %s %s\n")
|
|
|
|
% (refspec, sha)
|
|
|
|
)
|
|
|
|
|
2015-06-24 08:20:08 +03:00
|
|
|
except IOError as inst:
|
2012-11-08 02:21:39 +04:00
|
|
|
if inst.errno != errno.ENOENT:
|
|
|
|
raise
|
2015-11-12 05:18:02 +03:00
|
|
|
self._active = _readactive(repo, self)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def active(self):
|
|
|
|
return self._active
|
|
|
|
|
|
|
|
@active.setter
|
|
|
|
def active(self, mark):
|
|
|
|
if mark is not None and mark not in self:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise AssertionError("bookmark %s does not exist!" % mark)
|
2015-11-12 05:18:02 +03:00
|
|
|
|
|
|
|
self._active = mark
|
|
|
|
self._aclean = False
|
2015-11-12 05:01:23 +03:00
|
|
|
|
|
|
|
def __setitem__(self, *args, **kwargs):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
msg = "'bookmarks[name] = node' is deprecated, " "use 'bookmarks.applychanges'"
|
|
|
|
self._repo.ui.deprecwarn(msg, "4.3")
|
2017-07-10 22:47:34 +03:00
|
|
|
self._set(*args, **kwargs)
|
|
|
|
|
|
|
|
def _set(self, key, value):
|
2015-11-12 05:01:23 +03:00
|
|
|
self._clean = False
|
2017-07-10 22:47:34 +03:00
|
|
|
return dict.__setitem__(self, key, value)
|
2015-11-12 05:01:23 +03:00
|
|
|
|
|
|
|
def __delitem__(self, key):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
msg = "'del bookmarks[name]' is deprecated, " "use 'bookmarks.applychanges'"
|
|
|
|
self._repo.ui.deprecwarn(msg, "4.3")
|
2017-07-10 22:49:37 +03:00
|
|
|
self._del(key)
|
|
|
|
|
|
|
|
def _del(self, key):
|
2015-11-12 05:01:23 +03:00
|
|
|
self._clean = False
|
|
|
|
return dict.__delitem__(self, key)
|
2012-11-08 02:21:39 +04:00
|
|
|
|
2017-07-10 18:01:34 +03:00
|
|
|
def applychanges(self, repo, tr, changes):
|
|
|
|
"""Apply a list of changes to bookmarks
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
bmchanges = tr.changes.get("bookmarks")
|
2017-07-10 18:01:34 +03:00
|
|
|
for name, node in changes:
|
2017-07-10 21:26:53 +03:00
|
|
|
old = self.get(name)
|
2017-07-10 18:01:34 +03:00
|
|
|
if node is None:
|
2017-07-10 22:49:37 +03:00
|
|
|
self._del(name)
|
2017-07-10 18:01:34 +03:00
|
|
|
else:
|
2017-07-10 22:47:34 +03:00
|
|
|
self._set(name, node)
|
2017-07-10 21:26:53 +03:00
|
|
|
if bmchanges is not None:
|
|
|
|
# if a previous value exist preserve the "initial" value
|
|
|
|
previous = bmchanges.get(name)
|
|
|
|
if previous is not None:
|
|
|
|
old = previous[0]
|
|
|
|
bmchanges[name] = (old, node)
|
2017-07-10 21:10:03 +03:00
|
|
|
self._recordchange(tr)
|
2017-07-10 18:01:34 +03:00
|
|
|
|
2014-09-28 11:41:55 +04:00
|
|
|
def recordchange(self, tr):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
msg = "'bookmarks.recorchange' is deprecated, " "use 'bookmarks.applychanges'"
|
|
|
|
self._repo.ui.deprecwarn(msg, "4.3")
|
2017-07-10 21:10:03 +03:00
|
|
|
return self._recordchange(tr)
|
|
|
|
|
|
|
|
def _recordchange(self, tr):
|
2014-09-28 11:41:55 +04:00
|
|
|
"""record that bookmarks have been changed in a transaction
|
|
|
|
|
|
|
|
The transaction is then responsible for updating the file content."""
|
2019-11-27 22:34:50 +03:00
|
|
|
tr.addfilegenerator("bookmarks", ("bookmarks",), self._write, location="")
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
tr.hookargs["bookmark_moved"] = "1"
|
2012-11-08 02:21:39 +04:00
|
|
|
|
2015-11-12 05:18:02 +03:00
|
|
|
def _writeactive(self):
|
|
|
|
if self._aclean:
|
|
|
|
return
|
2016-01-16 00:14:45 +03:00
|
|
|
with self._repo.wlock():
|
2015-11-12 05:18:02 +03:00
|
|
|
if self._active is not None:
|
2018-09-28 17:08:40 +03:00
|
|
|
f = self._repo.localvfs(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"bookmarks.current", "w", atomictemp=True, checkambig=True
|
|
|
|
)
|
2015-11-12 05:18:02 +03:00
|
|
|
try:
|
2020-01-29 18:38:41 +03:00
|
|
|
f.write(encodeutf8(encoding.fromlocal(self._active)))
|
2015-11-12 05:18:02 +03:00
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
else:
|
2018-09-28 17:08:40 +03:00
|
|
|
self._repo.localvfs.tryunlink("bookmarks.current")
|
2015-11-12 05:18:02 +03:00
|
|
|
self._aclean = True
|
|
|
|
|
2014-09-27 14:10:33 +04:00
|
|
|
def _write(self, fp):
|
2020-03-16 20:18:18 +03:00
|
|
|
for name, node in sorted(pycompat.iteritems(self)):
|
2020-01-29 18:38:41 +03:00
|
|
|
name = encoding.fromlocal(name)
|
|
|
|
fp.write(encodeutf8("%s %s\n" % (hex(node), name)))
|
2015-11-12 05:01:23 +03:00
|
|
|
self._clean = True
|
2016-05-05 05:44:30 +03:00
|
|
|
self._repo.invalidatevolatilesets()
|
2014-09-27 14:10:33 +04:00
|
|
|
|
2016-02-20 00:28:09 +03:00
|
|
|
def expandname(self, bname):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if bname == ".":
|
2016-06-14 00:50:26 +03:00
|
|
|
if self.active:
|
|
|
|
return self.active
|
|
|
|
else:
|
|
|
|
raise error.Abort(_("no active bookmark"))
|
2016-02-20 00:28:09 +03:00
|
|
|
return bname
|
|
|
|
|
2017-06-11 09:42:38 +03:00
|
|
|
def checkconflict(self, mark, force=False, target=None):
|
|
|
|
"""check repo for a potential clash of mark with an existing bookmark,
|
|
|
|
branch, or hash
|
|
|
|
|
|
|
|
If target is supplied, then check that we are moving the bookmark
|
|
|
|
forward.
|
|
|
|
|
|
|
|
If force is supplied, then forcibly move the bookmark to a new commit
|
|
|
|
regardless if it is a move forward.
|
2017-07-10 21:02:32 +03:00
|
|
|
|
|
|
|
If divergent bookmark are to be deleted, they will be returned as list.
|
2017-06-11 09:42:38 +03:00
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cur = self._repo.changectx(".").node()
|
2017-06-11 09:42:38 +03:00
|
|
|
if mark in self and not force:
|
|
|
|
if target:
|
|
|
|
if self[mark] == target and target == cur:
|
|
|
|
# re-activating a bookmark
|
2017-07-10 21:02:32 +03:00
|
|
|
return []
|
2017-06-11 09:42:38 +03:00
|
|
|
rev = self._repo[target].rev()
|
|
|
|
anc = self._repo.changelog.ancestors([rev])
|
|
|
|
bmctx = self._repo[self[mark]]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
divs = [
|
|
|
|
self._repo[b].node()
|
|
|
|
for b in self
|
|
|
|
if b.split("@", 1)[0] == mark.split("@", 1)[0]
|
|
|
|
]
|
2017-06-11 09:42:38 +03:00
|
|
|
|
|
|
|
# allow resolving a single divergent bookmark even if moving
|
|
|
|
# the bookmark across branches when a revision is specified
|
|
|
|
# that contains a divergent bookmark
|
|
|
|
if bmctx.rev() not in anc and target in divs:
|
2017-07-10 21:02:32 +03:00
|
|
|
return divergent2delete(self._repo, [target], mark)
|
2017-06-11 09:42:38 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
deletefrom = [
|
|
|
|
b for b in divs if self._repo[b].rev() in anc or b == target
|
|
|
|
]
|
2017-07-10 21:02:32 +03:00
|
|
|
delbms = divergent2delete(self._repo, deletefrom, mark)
|
2017-06-11 09:42:38 +03:00
|
|
|
if validdest(self._repo, bmctx, self._repo[target]):
|
|
|
|
self._repo.ui.status(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_("moving bookmark '%s' forward from %s\n")
|
|
|
|
% (mark, short(bmctx.node()))
|
|
|
|
)
|
2017-07-10 21:02:32 +03:00
|
|
|
return delbms
|
2017-06-11 09:42:38 +03:00
|
|
|
raise error.Abort(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_("bookmark '%s' already exists " "(use -f to force)") % mark
|
|
|
|
)
|
2017-06-11 09:42:38 +03:00
|
|
|
if len(mark) > 3 and not force:
|
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
shadowhash = mark in self._repo
|
2017-06-11 09:42:38 +03:00
|
|
|
except error.LookupError: # ambiguous identifier
|
|
|
|
shadowhash = False
|
|
|
|
if shadowhash:
|
|
|
|
self._repo.ui.warn(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_(
|
|
|
|
"bookmark %s matches a changeset hash\n"
|
|
|
|
"(did you leave a -r out of an 'hg bookmark' "
|
|
|
|
"command?)\n"
|
|
|
|
)
|
|
|
|
% mark
|
|
|
|
)
|
2017-07-10 21:02:32 +03:00
|
|
|
return []
|
2017-06-11 09:42:38 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-11-12 05:18:02 +03:00
|
|
|
def _readactive(repo, marks):
|
2015-04-14 09:03:13 +03:00
|
|
|
"""
|
|
|
|
Get the active bookmark. We can have an active bookmark that updates
|
|
|
|
itself as we commit. This function returns the name of that bookmark.
|
|
|
|
It is stored in .hg/bookmarks.current
|
|
|
|
"""
|
2020-01-29 18:38:41 +03:00
|
|
|
mark = repo.localvfs.tryreadutf8("bookmarks.current") or None
|
|
|
|
if mark and mark not in marks:
|
|
|
|
mark = None
|
2011-02-10 22:46:27 +03:00
|
|
|
return mark
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-14 08:27:01 +03:00
|
|
|
def activate(repo, mark):
|
|
|
|
"""
|
|
|
|
Set the given bookmark to be 'active', meaning that this bookmark will
|
|
|
|
follow new commits that are made.
|
2011-02-10 22:46:27 +03:00
|
|
|
The name is recorded in .hg/bookmarks.current
|
2015-04-14 08:27:01 +03:00
|
|
|
"""
|
2015-11-12 05:18:02 +03:00
|
|
|
repo._bookmarks.active = mark
|
|
|
|
repo._bookmarks._writeactive()
|
2011-02-10 22:46:27 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-14 07:53:37 +03:00
|
|
|
def deactivate(repo):
|
|
|
|
"""
|
2015-10-17 01:58:46 +03:00
|
|
|
Unset the active bookmark in this repository.
|
2015-04-14 07:53:37 +03:00
|
|
|
"""
|
2015-11-12 05:18:02 +03:00
|
|
|
repo._bookmarks.active = None
|
|
|
|
repo._bookmarks._writeactive()
|
2012-02-29 01:47:46 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-14 22:45:15 +03:00
|
|
|
def isactivewdirparent(repo):
|
|
|
|
"""
|
|
|
|
Tell whether the 'active' bookmark (the one that follows new commits)
|
|
|
|
points to one of the parents of the current working directory (wdir).
|
|
|
|
|
|
|
|
While this is normally the case, it can on occasion be false; for example,
|
|
|
|
immediately after a pull, the active bookmark can be moved to point
|
|
|
|
to a place different than the wdir. This is solved by running `hg update`.
|
|
|
|
"""
|
|
|
|
mark = repo._activebookmark
|
2013-01-21 23:47:10 +04:00
|
|
|
marks = repo._bookmarks
|
2015-04-14 22:45:15 +03:00
|
|
|
parents = [p.node() for p in repo[None].parents()]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return mark in marks and marks[mark] in parents
|
|
|
|
|
2013-01-21 23:47:10 +04:00
|
|
|
|
2017-07-10 20:08:17 +03:00
|
|
|
def divergent2delete(repo, deletefrom, bm):
|
|
|
|
"""find divergent versions of bm on nodes in deletefrom.
|
|
|
|
|
|
|
|
the list of bookmark to delete."""
|
|
|
|
todelete = []
|
2013-01-31 03:35:00 +04:00
|
|
|
marks = repo._bookmarks
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
divergent = [b for b in marks if b.split("@", 1)[0] == bm.split("@", 1)[0]]
|
2013-01-31 03:35:00 +04:00
|
|
|
for mark in divergent:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if mark == "@" or "@" not in mark:
|
2014-07-08 23:45:55 +04:00
|
|
|
# can't be divergent by definition
|
|
|
|
continue
|
2013-01-31 03:35:00 +04:00
|
|
|
if mark and marks[mark] in deletefrom:
|
|
|
|
if mark != bm:
|
2017-07-10 20:08:17 +03:00
|
|
|
todelete.append(mark)
|
|
|
|
return todelete
|
2013-01-31 03:35:00 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-05-18 23:43:56 +03:00
|
|
|
def headsforactive(repo):
|
|
|
|
"""Given a repo with an active bookmark, return divergent bookmark nodes.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
repo: A repository with an active bookmark.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A list of binary node ids that is the full list of other
|
|
|
|
revisions with bookmarks divergent from the active bookmark. If
|
|
|
|
there were no divergent bookmarks, then this list will contain
|
|
|
|
only one entry.
|
|
|
|
"""
|
|
|
|
if not repo._activebookmark:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise ValueError("headsforactive() only makes sense with an active bookmark")
|
|
|
|
name = repo._activebookmark.split("@", 1)[0]
|
2017-05-18 23:43:56 +03:00
|
|
|
heads = []
|
2020-01-29 03:25:29 +03:00
|
|
|
for mark, n in pycompat.iteritems(repo._bookmarks):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if mark.split("@", 1)[0] == name:
|
2017-05-18 23:43:56 +03:00
|
|
|
heads.append(n)
|
|
|
|
return heads
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-08-02 06:43:14 +04:00
|
|
|
def calculateupdate(ui, repo, checkout):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Return a tuple (targetrev, movemarkfrom) indicating the rev to
|
|
|
|
check out and where to move the active bookmark from, if needed."""
|
2013-08-02 06:43:14 +04:00
|
|
|
movemarkfrom = None
|
|
|
|
if checkout is None:
|
2015-04-14 22:53:48 +03:00
|
|
|
activemark = repo._activebookmark
|
2015-04-14 22:45:15 +03:00
|
|
|
if isactivewdirparent(repo):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
movemarkfrom = repo["."].node()
|
2015-04-14 22:53:48 +03:00
|
|
|
elif activemark:
|
|
|
|
ui.status(_("updating to active bookmark %s\n") % activemark)
|
|
|
|
checkout = activemark
|
2013-08-02 06:43:14 +04:00
|
|
|
return (checkout, movemarkfrom)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-02-10 22:46:27 +03:00
|
|
|
def update(repo, parents, node):
|
2013-05-02 00:34:45 +04:00
|
|
|
deletefrom = parents
|
2011-02-10 22:46:27 +03:00
|
|
|
marks = repo._bookmarks
|
2015-11-12 05:18:02 +03:00
|
|
|
active = marks.active
|
2015-04-14 22:53:48 +03:00
|
|
|
if not active:
|
2012-05-12 23:28:10 +04:00
|
|
|
return False
|
|
|
|
|
2017-07-10 20:40:23 +03:00
|
|
|
bmchanges = []
|
2015-04-14 22:53:48 +03:00
|
|
|
if marks[active] in parents:
|
2013-01-31 03:35:00 +04:00
|
|
|
new = repo[node]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
divs = [repo[b] for b in marks if b.split("@", 1)[0] == active.split("@", 1)[0]]
|
2013-05-02 00:34:45 +04:00
|
|
|
anc = repo.changelog.ancestors([new.rev()])
|
|
|
|
deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
|
2015-04-14 22:53:48 +03:00
|
|
|
if validdest(repo, repo[marks[active]], new):
|
2017-07-10 20:40:23 +03:00
|
|
|
bmchanges.append((active, new.node()))
|
2013-01-31 03:35:00 +04:00
|
|
|
|
2017-07-10 20:12:25 +03:00
|
|
|
for bm in divergent2delete(repo, deletefrom, active):
|
|
|
|
bmchanges.append((bm, None))
|
2013-01-31 03:35:00 +04:00
|
|
|
|
2017-07-10 20:12:25 +03:00
|
|
|
if bmchanges:
|
2015-11-17 23:49:57 +03:00
|
|
|
lock = tr = None
|
|
|
|
try:
|
|
|
|
lock = repo.lock()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
tr = repo.transaction("bookmark")
|
2017-07-10 20:40:23 +03:00
|
|
|
marks.applychanges(repo, tr, bmchanges)
|
2015-11-17 23:49:57 +03:00
|
|
|
tr.close()
|
|
|
|
finally:
|
|
|
|
lockmod.release(tr, lock)
|
2017-07-10 20:12:25 +03:00
|
|
|
return bool(bmchanges)
|
2011-02-10 22:46:27 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-11-17 11:59:41 +03:00
|
|
|
def listbinbookmarks(repo):
|
|
|
|
# We may try to list bookmarks on a repo type that does not
|
2019-08-10 02:12:58 +03:00
|
|
|
# support it.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
marks = getattr(repo, "_bookmarks", {})
|
2016-11-17 11:59:41 +03:00
|
|
|
|
|
|
|
hasnode = repo.changelog.hasnode
|
2020-01-29 03:25:29 +03:00
|
|
|
for k, v in pycompat.iteritems(marks):
|
2016-11-17 11:59:41 +03:00
|
|
|
# don't expose local divergent bookmarks
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if hasnode(v) and ("@" not in k or k.endswith("@")):
|
2016-11-17 11:59:41 +03:00
|
|
|
yield k, v
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-02-10 22:46:27 +03:00
|
|
|
def listbookmarks(repo):
|
|
|
|
d = {}
|
2016-11-17 11:59:41 +03:00
|
|
|
for book, node in listbinbookmarks(repo):
|
|
|
|
d[book] = hex(node)
|
2011-02-10 22:46:27 +03:00
|
|
|
return d
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-02-10 22:46:27 +03:00
|
|
|
def pushbookmark(repo, key, old, new):
|
2014-09-29 04:35:33 +04:00
|
|
|
w = l = tr = None
|
2011-02-10 22:46:27 +03:00
|
|
|
try:
|
2014-09-29 04:35:33 +04:00
|
|
|
w = repo.wlock()
|
|
|
|
l = repo.lock()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
tr = repo.transaction("bookmarks")
|
2011-02-10 22:46:27 +03:00
|
|
|
marks = repo._bookmarks
|
2020-04-10 02:25:49 +03:00
|
|
|
existing = hex(marks.get(key, b""))
|
2014-08-26 15:58:41 +04:00
|
|
|
if existing != old and existing != new:
|
2011-02-10 22:46:27 +03:00
|
|
|
return False
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if new == "":
|
2017-07-10 18:24:28 +03:00
|
|
|
changes = [(key, None)]
|
2011-02-10 22:46:27 +03:00
|
|
|
else:
|
|
|
|
if new not in repo:
|
|
|
|
return False
|
2017-07-10 18:24:28 +03:00
|
|
|
changes = [(key, repo[new].node())]
|
|
|
|
marks.applychanges(repo, tr, changes)
|
2014-09-29 04:35:33 +04:00
|
|
|
tr.close()
|
2011-02-10 22:46:27 +03:00
|
|
|
return True
|
|
|
|
finally:
|
2014-09-29 04:35:33 +04:00
|
|
|
lockmod.release(tr, l, w)
|
2011-02-10 22:46:27 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-12-09 14:22:26 +03:00
|
|
|
def comparebookmarks(repo, srcmarks, dstmarks, targets=None):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Compare bookmarks between srcmarks and dstmarks
|
2013-11-08 07:45:52 +04:00
|
|
|
|
|
|
|
This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
|
|
|
|
differ, invalid)", each are list of bookmarks below:
|
|
|
|
|
|
|
|
:addsrc: added on src side (removed on dst side, perhaps)
|
|
|
|
:adddst: added on dst side (removed on src side, perhaps)
|
|
|
|
:advsrc: advanced on src side
|
|
|
|
:advdst: advanced on dst side
|
|
|
|
:diverge: diverge
|
|
|
|
:differ: changed, but changeset referred on src is unknown on dst
|
|
|
|
:invalid: unknown on both side
|
2014-10-24 21:40:37 +04:00
|
|
|
:same: same on both side
|
2013-11-08 07:45:52 +04:00
|
|
|
|
|
|
|
Each elements of lists in result tuple is tuple "(bookmark name,
|
|
|
|
changeset ID on source side, changeset ID on destination
|
|
|
|
side)". Each changeset IDs are 40 hexadecimal digit string or
|
|
|
|
None.
|
|
|
|
|
|
|
|
Changeset IDs of tuples in "addsrc", "adddst", "differ" or
|
|
|
|
"invalid" list may be unknown for repo.
|
|
|
|
|
|
|
|
If "targets" is specified, only bookmarks listed in it are
|
|
|
|
examined.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
2013-11-08 07:45:52 +04:00
|
|
|
|
|
|
|
if targets:
|
|
|
|
bset = set(targets)
|
|
|
|
else:
|
|
|
|
srcmarkset = set(srcmarks)
|
|
|
|
dstmarkset = set(dstmarks)
|
2014-10-24 21:40:37 +04:00
|
|
|
bset = srcmarkset | dstmarkset
|
2013-11-08 07:45:52 +04:00
|
|
|
|
2014-10-24 21:40:37 +04:00
|
|
|
results = ([], [], [], [], [], [], [], [])
|
2013-11-08 07:45:52 +04:00
|
|
|
addsrc = results[0].append
|
|
|
|
adddst = results[1].append
|
|
|
|
advsrc = results[2].append
|
|
|
|
advdst = results[3].append
|
|
|
|
diverge = results[4].append
|
|
|
|
differ = results[5].append
|
|
|
|
invalid = results[6].append
|
2014-10-24 21:40:37 +04:00
|
|
|
same = results[7].append
|
2013-11-08 07:45:52 +04:00
|
|
|
|
|
|
|
for b in sorted(bset):
|
|
|
|
if b not in srcmarks:
|
|
|
|
if b in dstmarks:
|
2016-12-09 14:22:26 +03:00
|
|
|
adddst((b, None, dstmarks[b]))
|
2013-11-08 07:45:52 +04:00
|
|
|
else:
|
|
|
|
invalid((b, None, None))
|
|
|
|
elif b not in dstmarks:
|
2016-12-09 14:22:26 +03:00
|
|
|
addsrc((b, srcmarks[b], None))
|
2013-11-08 07:45:52 +04:00
|
|
|
else:
|
2016-12-09 14:22:26 +03:00
|
|
|
scid = srcmarks[b]
|
|
|
|
dcid = dstmarks[b]
|
2014-10-24 21:40:37 +04:00
|
|
|
if scid == dcid:
|
|
|
|
same((b, scid, dcid))
|
|
|
|
elif scid in repo and dcid in repo:
|
2013-11-08 07:45:52 +04:00
|
|
|
sctx = repo[scid]
|
|
|
|
dctx = repo[dcid]
|
|
|
|
if sctx.rev() < dctx.rev():
|
|
|
|
if validdest(repo, sctx, dctx):
|
|
|
|
advdst((b, scid, dcid))
|
|
|
|
else:
|
|
|
|
diverge((b, scid, dcid))
|
|
|
|
else:
|
|
|
|
if validdest(repo, dctx, sctx):
|
|
|
|
advsrc((b, scid, dcid))
|
|
|
|
else:
|
|
|
|
diverge((b, scid, dcid))
|
|
|
|
else:
|
|
|
|
# it is too expensive to examine in detail, in this case
|
|
|
|
differ((b, scid, dcid))
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-17 12:20:24 +03:00
|
|
|
def _diverge(ui, b, path, localmarks, remotenode):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Return appropriate diverged bookmark for specified ``path``
|
2015-03-17 12:20:24 +03:00
|
|
|
|
|
|
|
This returns None, if it is failed to assign any divergent
|
|
|
|
bookmark name.
|
2015-03-17 12:20:24 +03:00
|
|
|
|
|
|
|
This reuses already existing one with "@number" suffix, if it
|
|
|
|
refers ``remotenode``.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
|
|
|
if b == "@":
|
|
|
|
b = ""
|
2013-11-08 07:45:52 +04:00
|
|
|
# try to use an @pathalias suffix
|
|
|
|
# if an @pathalias already exists, we overwrite (update) it
|
2014-10-03 01:43:50 +04:00
|
|
|
if path.startswith("file:"):
|
|
|
|
path = util.url(path).path
|
2013-11-08 07:45:52 +04:00
|
|
|
for p, u in ui.configitems("paths"):
|
2014-10-03 01:43:50 +04:00
|
|
|
if u.startswith("file:"):
|
|
|
|
u = util.url(u).path
|
2013-11-08 07:45:52 +04:00
|
|
|
if path == u:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return "%s@%s" % (b, p)
|
2015-03-17 12:20:24 +03:00
|
|
|
|
|
|
|
# assign a unique "@number" suffix newly
|
|
|
|
for x in range(1, 100):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
n = "%s@%d" % (b, x)
|
2015-03-17 12:20:24 +03:00
|
|
|
if n not in localmarks or localmarks[n] == remotenode:
|
2015-03-17 12:20:24 +03:00
|
|
|
return n
|
|
|
|
|
|
|
|
return None
|
2013-11-08 07:45:52 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-12-09 14:22:26 +03:00
|
|
|
def unhexlifybookmarks(marks):
|
|
|
|
binremotemarks = {}
|
|
|
|
for name, node in marks.items():
|
|
|
|
binremotemarks[name] = bin(node)
|
|
|
|
return binremotemarks
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
_binaryentry = struct.Struct(">20sH")
|
|
|
|
|
2017-10-15 15:59:55 +03:00
|
|
|
|
|
|
|
def binaryencode(bookmarks):
|
2020-01-31 05:39:19 +03:00
|
|
|
# type: (typing.Iterable[typing.Tuple[str, bytes]]) -> bytes
|
2017-10-15 15:59:55 +03:00
|
|
|
"""encode a '(bookmark, node)' iterable into a binary stream
|
|
|
|
|
|
|
|
the binary format is:
|
|
|
|
|
|
|
|
<node><bookmark-length><bookmark-name>
|
|
|
|
|
|
|
|
:node: is a 20 bytes binary node,
|
|
|
|
:bookmark-length: an unsigned short,
|
|
|
|
:bookmark-name: the name of the bookmark (of length <bookmark-length>)
|
|
|
|
|
|
|
|
wdirid (all bits set) will be used as a special value for "missing"
|
|
|
|
"""
|
|
|
|
binarydata = []
|
|
|
|
for book, node in bookmarks:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if not node: # None or ''
|
2017-10-15 15:59:55 +03:00
|
|
|
node = wdirid
|
|
|
|
binarydata.append(_binaryentry.pack(node, len(book)))
|
2020-01-31 05:39:19 +03:00
|
|
|
binarydata.append(pycompat.encodeutf8(book))
|
|
|
|
return b"".join(binarydata)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-15 15:59:55 +03:00
|
|
|
|
|
|
|
def binarydecode(stream):
|
|
|
|
"""decode a binary stream into an '(bookmark, node)' iterable
|
|
|
|
|
|
|
|
the binary format is:
|
|
|
|
|
|
|
|
<node><bookmark-length><bookmark-name>
|
|
|
|
|
|
|
|
:node: is a 20 bytes binary node,
|
|
|
|
:bookmark-length: an unsigned short,
|
|
|
|
:bookmark-name: the name of the bookmark (of length <bookmark-length>))
|
|
|
|
|
|
|
|
wdirid (all bits set) will be used as a special value for "missing"
|
|
|
|
"""
|
|
|
|
entrysize = _binaryentry.size
|
|
|
|
books = []
|
|
|
|
while True:
|
|
|
|
entry = stream.read(entrysize)
|
|
|
|
if len(entry) < entrysize:
|
|
|
|
if entry:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(_("bad bookmark stream"))
|
2017-10-15 15:59:55 +03:00
|
|
|
break
|
|
|
|
node, length = _binaryentry.unpack(entry)
|
|
|
|
bookmark = stream.read(length)
|
|
|
|
if len(bookmark) < length:
|
|
|
|
if entry:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(_("bad bookmark stream"))
|
2017-10-15 15:59:55 +03:00
|
|
|
if node == wdirid:
|
|
|
|
node = None
|
2020-02-18 01:47:28 +03:00
|
|
|
books.append((decodeutf8(bookmark), node))
|
2017-10-15 15:59:55 +03:00
|
|
|
return books
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-09-29 02:21:38 +04:00
|
|
|
def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
|
2011-03-14 02:10:43 +03:00
|
|
|
ui.debug("checking for updated bookmarks\n")
|
2012-11-08 02:21:39 +04:00
|
|
|
localmarks = repo._bookmarks
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
(addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same) = comparebookmarks(
|
|
|
|
repo, remotemarks, localmarks
|
|
|
|
)
|
2013-11-08 07:45:52 +04:00
|
|
|
|
2014-10-02 21:16:07 +04:00
|
|
|
status = ui.status
|
|
|
|
warn = ui.warn
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if ui.configbool("ui", "quietbookmarkmove"):
|
2014-10-02 21:16:07 +04:00
|
|
|
status = warn = ui.debug
|
|
|
|
|
2014-09-29 01:07:56 +04:00
|
|
|
explicit = set(explicit)
|
2013-11-08 07:45:52 +04:00
|
|
|
changed = []
|
|
|
|
for b, scid, dcid in addsrc:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if scid in repo: # add remote bookmarks for changes we already have
|
2020-05-07 19:05:16 +03:00
|
|
|
changed.append((b, scid, status, _("adding remote bookmark %s\n") % b))
|
2015-06-12 03:19:48 +03:00
|
|
|
elif b in explicit:
|
|
|
|
explicit.remove(b)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.warn(
|
|
|
|
_("remote bookmark %s points to locally missing %s\n")
|
|
|
|
% (b, hex(scid)[:12])
|
|
|
|
)
|
2015-06-12 03:19:48 +03:00
|
|
|
|
2013-11-08 07:45:52 +04:00
|
|
|
for b, scid, dcid in advsrc:
|
2020-05-07 19:05:16 +03:00
|
|
|
changed.append((b, scid, status, _("updating bookmark %s\n") % b))
|
2014-09-29 01:07:56 +04:00
|
|
|
# remove normal movement from explicit set
|
|
|
|
explicit.difference_update(d[0] for d in changed)
|
|
|
|
|
2013-11-08 07:45:52 +04:00
|
|
|
for b, scid, dcid in diverge:
|
2014-09-29 01:07:56 +04:00
|
|
|
if b in explicit:
|
|
|
|
explicit.discard(b)
|
2020-05-07 19:05:16 +03:00
|
|
|
changed.append((b, scid, status, _("importing bookmark %s\n") % b))
|
2014-09-29 01:07:56 +04:00
|
|
|
else:
|
2016-12-09 14:22:26 +03:00
|
|
|
db = _diverge(ui, b, path, localmarks, scid)
|
2015-03-17 12:20:24 +03:00
|
|
|
if db:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
changed.append(
|
|
|
|
(
|
|
|
|
db,
|
|
|
|
scid,
|
|
|
|
warn,
|
|
|
|
_("divergent bookmark %s stored as %s\n") % (b, db),
|
|
|
|
)
|
|
|
|
)
|
2015-03-17 12:20:24 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
warn(
|
|
|
|
_(
|
|
|
|
"warning: failed to assign numbered name "
|
|
|
|
"to divergent bookmark %s\n"
|
|
|
|
)
|
2020-05-07 19:05:16 +03:00
|
|
|
% b
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2014-09-29 01:07:56 +04:00
|
|
|
for b, scid, dcid in adddst + advdst:
|
|
|
|
if b in explicit:
|
|
|
|
explicit.discard(b)
|
2020-05-07 19:05:16 +03:00
|
|
|
changed.append((b, scid, status, _("importing bookmark %s\n") % b))
|
2015-06-12 03:19:48 +03:00
|
|
|
for b, scid, dcid in differ:
|
|
|
|
if b in explicit:
|
|
|
|
explicit.remove(b)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.warn(
|
|
|
|
_("remote bookmark %s points to locally missing %s\n")
|
|
|
|
% (b, hex(scid)[:12])
|
|
|
|
)
|
2014-09-29 01:07:56 +04:00
|
|
|
|
2011-03-14 02:10:43 +03:00
|
|
|
if changed:
|
2014-09-29 02:21:38 +04:00
|
|
|
tr = trfunc()
|
2017-07-10 18:22:17 +03:00
|
|
|
changes = []
|
2013-11-08 07:45:52 +04:00
|
|
|
for b, node, writer, msg in sorted(changed):
|
2017-07-10 18:22:17 +03:00
|
|
|
changes.append((b, node))
|
2013-11-08 07:45:52 +04:00
|
|
|
writer(msg)
|
2017-07-10 18:22:17 +03:00
|
|
|
localmarks.applychanges(repo, tr, changes)
|
2011-03-14 02:10:43 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-19 17:36:05 +03:00
|
|
|
def incoming(ui, repo, other):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Show bookmarks incoming from other to repo
|
|
|
|
"""
|
2015-03-19 17:36:05 +03:00
|
|
|
ui.status(_("searching for changed bookmarks\n"))
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
remotemarks = unhexlifybookmarks(other.listkeys("bookmarks"))
|
2016-12-09 14:22:26 +03:00
|
|
|
r = comparebookmarks(repo, remotemarks, repo._bookmarks)
|
2015-03-19 17:36:05 +03:00
|
|
|
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
|
|
|
|
|
|
|
|
incomings = []
|
|
|
|
if ui.debugflag:
|
|
|
|
getid = lambda id: id
|
|
|
|
else:
|
|
|
|
getid = lambda id: id[:12]
|
2015-04-07 20:56:19 +03:00
|
|
|
if ui.verbose:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
def add(b, id, st):
|
|
|
|
incomings.append(" %-25s %s %s\n" % (b, getid(id), st))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
def add(b, id, st):
|
|
|
|
incomings.append(" %-25s %s\n" % (b, getid(id)))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-19 17:36:05 +03:00
|
|
|
for b, scid, dcid in addsrc:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "added" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("added"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in advsrc:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "advanced" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("advanced"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in diverge:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "diverged" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("diverged"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in differ:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "changed" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("changed"))
|
2015-03-19 17:36:05 +03:00
|
|
|
|
|
|
|
if not incomings:
|
|
|
|
ui.status(_("no changed bookmarks found\n"))
|
|
|
|
return 1
|
|
|
|
|
|
|
|
for s in sorted(incomings):
|
|
|
|
ui.write(s)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-19 17:36:05 +03:00
|
|
|
def outgoing(ui, repo, other):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Show bookmarks outgoing from repo to other
|
|
|
|
"""
|
2015-03-19 17:36:05 +03:00
|
|
|
ui.status(_("searching for changed bookmarks\n"))
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
remotemarks = unhexlifybookmarks(other.listkeys("bookmarks"))
|
2016-12-09 14:22:26 +03:00
|
|
|
r = comparebookmarks(repo, repo._bookmarks, remotemarks)
|
2015-03-19 17:36:05 +03:00
|
|
|
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
|
|
|
|
|
|
|
|
outgoings = []
|
|
|
|
if ui.debugflag:
|
|
|
|
getid = lambda id: id
|
|
|
|
else:
|
|
|
|
getid = lambda id: id[:12]
|
2015-04-07 20:56:19 +03:00
|
|
|
if ui.verbose:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
def add(b, id, st):
|
|
|
|
outgoings.append(" %-25s %s %s\n" % (b, getid(id), st))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-04-07 20:56:19 +03:00
|
|
|
def add(b, id, st):
|
|
|
|
outgoings.append(" %-25s %s\n" % (b, getid(id)))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-19 17:36:05 +03:00
|
|
|
for b, scid, dcid in addsrc:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "added refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("added"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in adddst:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "deleted" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, " " * 40, _("deleted"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in advsrc:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "advanced" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("advanced"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in diverge:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "diverged" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("diverged"))
|
2015-04-07 20:56:19 +03:00
|
|
|
for b, scid, dcid in differ:
|
2015-04-22 03:02:08 +03:00
|
|
|
# i18n: "changed" refers to a bookmark
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
add(b, hex(scid), _("changed"))
|
2015-03-19 17:36:05 +03:00
|
|
|
|
|
|
|
if not outgoings:
|
|
|
|
ui.status(_("no changed bookmarks found\n"))
|
|
|
|
return 1
|
|
|
|
|
|
|
|
for s in sorted(outgoings):
|
|
|
|
ui.write(s)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-19 17:36:06 +03:00
|
|
|
def summary(repo, other):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Compare bookmarks between repo and other for "hg summary" output
|
2015-03-19 17:36:06 +03:00
|
|
|
|
|
|
|
This returns "(# of incoming, # of outgoing)" tuple.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
|
|
|
remotemarks = unhexlifybookmarks(other.listkeys("bookmarks"))
|
2016-12-09 14:22:26 +03:00
|
|
|
r = comparebookmarks(repo, remotemarks, repo._bookmarks)
|
2015-03-19 17:36:06 +03:00
|
|
|
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
|
|
|
|
return (len(addsrc), len(adddst))
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-08-26 02:28:56 +04:00
|
|
|
def validdest(repo, old, new):
|
|
|
|
"""Is the new bookmark destination a valid update from the old one"""
|
2012-10-08 19:26:23 +04:00
|
|
|
repo = repo.unfiltered()
|
2012-08-26 03:28:22 +04:00
|
|
|
if old == new:
|
|
|
|
# Old == new -> nothing to update.
|
2012-09-18 16:39:12 +04:00
|
|
|
return False
|
2012-08-26 03:28:22 +04:00
|
|
|
elif not old:
|
|
|
|
# old is nullrev, anything is valid.
|
|
|
|
# (new != nullrev has been excluded by the previous check)
|
2012-09-18 16:39:12 +04:00
|
|
|
return True
|
2019-03-08 14:01:08 +03:00
|
|
|
elif mutation.enabled(repo):
|
|
|
|
return new.node() in mutation.foreground(repo, [old.node()])
|
2012-08-26 03:28:22 +04:00
|
|
|
elif repo.obsstore:
|
2017-06-27 02:40:34 +03:00
|
|
|
return new.node() in obsutil.foreground(repo, [old.node()])
|
2012-08-26 03:28:22 +04:00
|
|
|
else:
|
2015-01-18 04:38:57 +03:00
|
|
|
# still an independent clause as it is lazier (and therefore faster)
|
2012-09-18 16:39:12 +04:00
|
|
|
return old.descendant(new)
|
2017-06-11 09:32:58 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-11 09:32:58 +03:00
|
|
|
def checkformat(repo, mark):
|
|
|
|
"""return a valid version of a potential bookmark name
|
|
|
|
|
|
|
|
Raises an abort error if the bookmark name is not valid.
|
|
|
|
"""
|
|
|
|
mark = mark.strip()
|
|
|
|
if not mark:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(_("bookmark names cannot consist entirely of " "whitespace"))
|
|
|
|
scmutil.checknewlabel(repo, mark, "bookmark")
|
2017-06-11 09:32:58 +03:00
|
|
|
return mark
|
2017-06-13 09:02:48 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-13 09:02:48 +03:00
|
|
|
def delete(repo, tr, names):
|
|
|
|
"""remove a mark from the bookmark store
|
|
|
|
|
|
|
|
Raises an abort error if mark does not exist.
|
|
|
|
"""
|
|
|
|
marks = repo._bookmarks
|
2017-07-10 18:04:16 +03:00
|
|
|
changes = []
|
2017-06-13 09:02:48 +03:00
|
|
|
for mark in names:
|
|
|
|
if mark not in marks:
|
|
|
|
raise error.Abort(_("bookmark '%s' does not exist") % mark)
|
|
|
|
if mark == repo._activebookmark:
|
|
|
|
deactivate(repo)
|
2017-07-10 18:04:16 +03:00
|
|
|
changes.append((mark, None))
|
|
|
|
marks.applychanges(repo, tr, changes)
|
2017-06-13 21:10:22 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-13 21:10:22 +03:00
|
|
|
def rename(repo, tr, old, new, force=False, inactive=False):
|
|
|
|
"""rename a bookmark from old to new
|
|
|
|
|
|
|
|
If force is specified, then the new name can overwrite an existing
|
|
|
|
bookmark.
|
|
|
|
|
|
|
|
If inactive is specified, then do not activate the new bookmark.
|
|
|
|
|
|
|
|
Raises an abort error if old is not in the bookmark store.
|
|
|
|
"""
|
|
|
|
marks = repo._bookmarks
|
|
|
|
mark = checkformat(repo, new)
|
|
|
|
if old not in marks:
|
|
|
|
raise error.Abort(_("bookmark '%s' does not exist") % old)
|
2017-07-10 21:02:32 +03:00
|
|
|
changes = []
|
|
|
|
for bm in marks.checkconflict(mark, force):
|
|
|
|
changes.append((bm, None))
|
|
|
|
changes.extend([(mark, marks[old]), (old, None)])
|
2017-07-10 18:08:20 +03:00
|
|
|
marks.applychanges(repo, tr, changes)
|
2017-06-13 21:10:22 +03:00
|
|
|
if repo._activebookmark == old and not inactive:
|
|
|
|
activate(repo, mark)
|
2017-06-21 01:18:40 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-21 01:18:40 +03:00
|
|
|
def addbookmarks(repo, tr, names, rev=None, force=False, inactive=False):
|
|
|
|
"""add a list of bookmarks
|
|
|
|
|
|
|
|
If force is specified, then the new name can overwrite an existing
|
|
|
|
bookmark.
|
|
|
|
|
|
|
|
If inactive is specified, then do not activate any bookmark. Otherwise, the
|
|
|
|
first bookmark is activated.
|
|
|
|
|
|
|
|
Raises an abort error if old is not in the bookmark store.
|
|
|
|
"""
|
|
|
|
marks = repo._bookmarks
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cur = repo.changectx(".").node()
|
2017-06-21 01:18:40 +03:00
|
|
|
newact = None
|
2017-07-10 18:10:56 +03:00
|
|
|
changes = []
|
2017-06-21 01:18:40 +03:00
|
|
|
for mark in names:
|
|
|
|
mark = checkformat(repo, mark)
|
|
|
|
if newact is None:
|
|
|
|
newact = mark
|
|
|
|
if inactive and mark == repo._activebookmark:
|
|
|
|
deactivate(repo)
|
|
|
|
return
|
|
|
|
tgt = cur
|
|
|
|
if rev:
|
|
|
|
tgt = scmutil.revsingle(repo, rev).node()
|
2017-07-10 21:02:32 +03:00
|
|
|
for bm in marks.checkconflict(mark, force, tgt):
|
|
|
|
changes.append((bm, None))
|
2017-07-10 18:10:56 +03:00
|
|
|
changes.append((mark, tgt))
|
|
|
|
marks.applychanges(repo, tr, changes)
|
2017-06-21 01:18:40 +03:00
|
|
|
if not inactive and cur == marks[newact] and not rev:
|
|
|
|
activate(repo, newact)
|
|
|
|
elif cur != tgt and newact == repo._activebookmark:
|
|
|
|
deactivate(repo)
|
2017-06-21 02:36:25 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-21 03:18:20 +03:00
|
|
|
def _printbookmarks(ui, repo, bmarks, **opts):
|
|
|
|
"""private method to print bookmarks
|
2017-06-21 02:36:25 +03:00
|
|
|
|
2017-06-21 03:18:20 +03:00
|
|
|
Provides a way for extensions to control how bookmarks are printed (e.g.
|
|
|
|
prepend or postpend names)
|
2017-06-21 02:36:25 +03:00
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fm = ui.formatter("bookmarks", opts)
|
2017-06-21 02:36:25 +03:00
|
|
|
hexfn = fm.hexfunc
|
2017-06-21 03:18:20 +03:00
|
|
|
if len(bmarks) == 0 and fm.isplain():
|
2017-06-21 02:36:25 +03:00
|
|
|
ui.status(_("no bookmarks set\n"))
|
2020-01-29 03:25:29 +03:00
|
|
|
for bmark, (n, prefix, label) in sorted(pycompat.iteritems(bmarks)):
|
2017-06-21 02:36:25 +03:00
|
|
|
fm.startitem()
|
|
|
|
if not ui.quiet:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fm.plain(" %s " % prefix, label=label)
|
|
|
|
fm.write("bookmark", "%s", bmark, label=label)
|
2017-06-21 02:36:25 +03:00
|
|
|
pad = " " * (25 - encoding.colwidth(bmark))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fm.condwrite(
|
|
|
|
not ui.quiet,
|
|
|
|
"rev node",
|
|
|
|
pad + " %d:%s",
|
|
|
|
repo.changelog.rev(n),
|
|
|
|
hexfn(n),
|
|
|
|
label=label,
|
|
|
|
)
|
2017-06-21 03:18:20 +03:00
|
|
|
fm.data(active=(activebookmarklabel in label))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fm.plain("\n")
|
2017-06-21 02:36:25 +03:00
|
|
|
fm.end()
|
2017-06-21 03:18:20 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-21 03:18:20 +03:00
|
|
|
def printbookmarks(ui, repo, **opts):
|
|
|
|
"""print bookmarks to a formatter
|
|
|
|
|
|
|
|
Provides a way for extensions to control how bookmarks are printed.
|
|
|
|
"""
|
|
|
|
marks = repo._bookmarks
|
|
|
|
bmarks = {}
|
2020-01-29 03:25:29 +03:00
|
|
|
for bmark, n in sorted(pycompat.iteritems(marks)):
|
2017-06-21 03:18:20 +03:00
|
|
|
active = repo._activebookmark
|
|
|
|
if bmark == active:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
prefix, label = "*", activebookmarklabel
|
2017-06-21 03:18:20 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
prefix, label = " ", ""
|
2017-06-21 03:18:20 +03:00
|
|
|
|
|
|
|
bmarks[bmark] = (n, prefix, label)
|
|
|
|
_printbookmarks(ui, repo, bmarks, **opts)
|
2017-10-10 18:53:42 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-10 18:53:42 +03:00
|
|
|
def preparehookargs(name, old, new):
|
|
|
|
if new is None:
|
2020-02-18 01:47:28 +03:00
|
|
|
new = b""
|
2017-10-10 18:53:42 +03:00
|
|
|
if old is None:
|
2020-02-18 01:47:28 +03:00
|
|
|
old = b""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return {"bookmark": name, "node": hex(new), "oldnode": hex(old)}
|
2019-06-03 18:42:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
def reachablerevs(repo, bookmarks):
|
|
|
|
"""revisions reachable only from the given bookmarks
|
|
|
|
|
|
|
|
Returns a revset matching all commits that are only reachable by the given
|
|
|
|
bookmarks.
|
|
|
|
"""
|
|
|
|
repobookmarks = repo._bookmarks
|
|
|
|
if not bookmarks.issubset(repobookmarks):
|
|
|
|
raise error.Abort(
|
|
|
|
_("bookmark not found: %s")
|
|
|
|
% ", ".join(
|
|
|
|
"'%s'" % bookmark
|
|
|
|
for bookmark in sorted(bookmarks - set(repobookmarks.keys()))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
nodes = [repobookmarks[bookmark] for bookmark in bookmarks]
|
|
|
|
|
|
|
|
# Compute nodes that are pointed to by other bookmarks. This is not the
|
|
|
|
# same as 'bookmark() - nodes', as it includes nodes that are pointed to by
|
|
|
|
# both bookmarks we are deleting and other bookmarks.
|
|
|
|
othernodes = [
|
|
|
|
node
|
2020-01-29 03:25:29 +03:00
|
|
|
for bookmark, node in pycompat.iteritems(repobookmarks)
|
2019-06-03 18:42:57 +03:00
|
|
|
if bookmark not in bookmarks
|
|
|
|
]
|
|
|
|
|
|
|
|
return repo.revs("(%ln) %% (head() - (%ln) + (%ln))", nodes, nodes, othernodes)
|
2020-03-26 18:23:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
class remotenames(dict):
|
|
|
|
"""This class encapsulates all the remotenames state. It also contains
|
|
|
|
methods to access that state in convenient ways. Remotenames are lazy
|
|
|
|
loaded. Whenever client code needs to ensure the freshest copy of
|
|
|
|
remotenames, use the `clearnames` method to force an eventual load.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, repo, *args):
|
|
|
|
dict.__init__(self, *args)
|
|
|
|
self._repo = repo
|
|
|
|
self.clearnames()
|
2020-04-03 05:24:05 +03:00
|
|
|
self._accessedbookmarks = list(
|
|
|
|
_readremotenamesfrom(repo.sharedvfs, _selectivepullaccessedbookmarks)
|
|
|
|
)
|
2020-03-26 18:23:49 +03:00
|
|
|
|
|
|
|
def clearnames(self):
|
|
|
|
"""Clear all remote names state"""
|
|
|
|
self["bookmarks"] = lazyremotenamedict("bookmarks", self._repo)
|
|
|
|
self._invalidatecache()
|
|
|
|
self._loadednames = False
|
|
|
|
|
|
|
|
def _invalidatecache(self):
|
|
|
|
self._node2marks = None
|
|
|
|
self._hoist2nodes = None
|
|
|
|
self._node2hoists = None
|
|
|
|
self._node2branch = None
|
|
|
|
|
|
|
|
def applychanges(self, changes):
|
|
|
|
# Only supported for bookmarks
|
|
|
|
bmchanges = changes.get("bookmarks", {})
|
|
|
|
remotepathbooks = {}
|
|
|
|
for remotename, node in pycompat.iteritems(bmchanges):
|
|
|
|
path, name = splitremotename(remotename)
|
|
|
|
remotepathbooks.setdefault(path, {})[name] = node
|
|
|
|
|
|
|
|
saveremotenames(self._repo, remotepathbooks)
|
|
|
|
|
|
|
|
def mark2nodes(self):
|
|
|
|
return self["bookmarks"]
|
|
|
|
|
|
|
|
def node2marks(self):
|
|
|
|
if not self._node2marks:
|
|
|
|
mark2nodes = self.mark2nodes()
|
|
|
|
self._node2marks = {}
|
2020-04-10 19:51:25 +03:00
|
|
|
for name, node in mark2nodes.items():
|
2020-03-26 18:23:49 +03:00
|
|
|
self._node2marks.setdefault(node[0], []).append(name)
|
|
|
|
return self._node2marks
|
|
|
|
|
|
|
|
def hoist2nodes(self, hoist):
|
|
|
|
if not self._hoist2nodes:
|
|
|
|
mark2nodes = self.mark2nodes()
|
|
|
|
self._hoist2nodes = {}
|
|
|
|
hoist += "/"
|
2020-04-10 19:51:25 +03:00
|
|
|
for name, node in mark2nodes.items():
|
2020-03-26 18:23:49 +03:00
|
|
|
if name.startswith(hoist):
|
|
|
|
name = name[len(hoist) :]
|
|
|
|
self._hoist2nodes[name] = node
|
|
|
|
return self._hoist2nodes
|
|
|
|
|
|
|
|
def node2hoists(self, hoist):
|
|
|
|
if not self._node2hoists:
|
|
|
|
mark2nodes = self.mark2nodes()
|
|
|
|
self._node2hoists = {}
|
|
|
|
hoist += "/"
|
2020-04-10 19:51:25 +03:00
|
|
|
for name, node in mark2nodes.items():
|
2020-03-26 18:23:49 +03:00
|
|
|
if name.startswith(hoist):
|
|
|
|
name = name[len(hoist) :]
|
|
|
|
self._node2hoists.setdefault(node[0], []).append(name)
|
|
|
|
return self._node2hoists
|
|
|
|
|
|
|
|
|
|
|
|
def saveremotenames(repo, remotebookmarks, override=True):
|
|
|
|
"""
|
|
|
|
remotebookmarks has the format {name: {name: hexnode | None}}.
|
|
|
|
For example: {"remote": {"master": "0" * 40}}
|
|
|
|
|
|
|
|
If override is False, update existing entries.
|
|
|
|
If override is True, bookmarks with the same "remote" name (ex. "remote")
|
|
|
|
will be replaced.
|
|
|
|
"""
|
|
|
|
if not remotebookmarks:
|
|
|
|
return
|
|
|
|
|
|
|
|
from . import extensions
|
|
|
|
|
|
|
|
svfs = repo.svfs
|
|
|
|
with repo.wlock(), repo.lock():
|
|
|
|
if extensions.isenabled(repo.ui, "remotenames"):
|
|
|
|
transition(repo, repo.ui)
|
|
|
|
|
|
|
|
tr = repo.currenttransaction()
|
|
|
|
if tr is not None:
|
|
|
|
tr.addbackup("remotenames")
|
|
|
|
|
|
|
|
# read in all data first before opening file to write
|
|
|
|
olddata = set(readremotenames(repo))
|
|
|
|
oldbooks = {}
|
|
|
|
|
|
|
|
remotepaths = remotebookmarks.keys()
|
|
|
|
f = svfs("remotenames", "w", atomictemp=True)
|
|
|
|
for node, nametype, remote, rname in olddata:
|
|
|
|
if remote not in remotepaths:
|
|
|
|
_writesingleremotename(f, remote, nametype, rname, node)
|
|
|
|
elif nametype == "bookmarks":
|
|
|
|
oldbooks[(remote, rname)] = node
|
|
|
|
if not override and rname not in remotebookmarks[remote]:
|
|
|
|
_writesingleremotename(f, remote, nametype, rname, node)
|
|
|
|
|
|
|
|
journal = []
|
|
|
|
nm = repo.unfiltered().changelog.nodemap
|
|
|
|
missingnode = False
|
|
|
|
for remote, rmbookmarks in pycompat.iteritems(remotebookmarks):
|
|
|
|
rmbookmarks = {} if rmbookmarks is None else rmbookmarks
|
|
|
|
for name, node in pycompat.iteritems(rmbookmarks):
|
|
|
|
oldnode = oldbooks.get((remote, name), hex(nullid))
|
|
|
|
newnode = node
|
|
|
|
if not bin(newnode) in nm:
|
|
|
|
# node is unknown locally, don't change the bookmark
|
|
|
|
missingnode = True
|
|
|
|
newnode = oldnode
|
|
|
|
if newnode != hex(nullid):
|
|
|
|
_writesingleremotename(f, remote, "bookmarks", name, newnode)
|
|
|
|
if newnode != oldnode:
|
|
|
|
journal.append(
|
|
|
|
(joinremotename(remote, name), bin(oldnode), bin(newnode))
|
|
|
|
)
|
|
|
|
repo.ui.log("remotenamesmissingnode", remotenamesmissingnode=str(missingnode))
|
|
|
|
|
|
|
|
_recordbookmarksupdate(repo, journal)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# Old paths have been deleted, refresh remotenames
|
|
|
|
if util.safehasattr(repo, "_remotenames"):
|
|
|
|
repo._remotenames.clearnames()
|
|
|
|
|
|
|
|
# If narrowheads is enabled, updating remotenames can affect phases
|
|
|
|
# (and other revsets). Therefore invalidate them.
|
|
|
|
if "narrowheads" in repo.storerequirements:
|
|
|
|
repo.invalidatevolatilesets()
|
|
|
|
|
|
|
|
|
|
|
|
class lazyremotenamedict(pycompat.Mapping):
|
|
|
|
"""Read-only dict-like Class to lazily resolve remotename entries
|
|
|
|
|
|
|
|
We are doing that because remotenames startup was slow.
|
|
|
|
We lazily read the remotenames file once to figure out the potential entries
|
|
|
|
and store them in self.potentialentries. Then when asked to resolve an
|
|
|
|
entry, if it is not in self.potentialentries, then it isn't there, if it
|
|
|
|
is in self.potentialentries we resolve it and store the result in
|
|
|
|
self.cache. We cannot be lazy is when asked all the entries (keys).
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, kind, repo):
|
|
|
|
self.cache = {}
|
|
|
|
self.potentialentries = {}
|
|
|
|
assert kind == "bookmarks" # only support bookmarks
|
|
|
|
self._kind = kind
|
|
|
|
self._repo = repo
|
|
|
|
self.loaded = False
|
|
|
|
|
|
|
|
def _load(self):
|
|
|
|
"""Read the remotenames file, store entries matching selected kind"""
|
|
|
|
self.loaded = True
|
|
|
|
repo = self._repo
|
|
|
|
alias_default = repo.ui.configbool("remotenames", "alias.default")
|
|
|
|
for node, nametype, remote, rname in readremotenames(repo):
|
|
|
|
if nametype != self._kind:
|
|
|
|
continue
|
|
|
|
# handle alias_default here
|
|
|
|
if remote != "default" and rname == "default" and alias_default:
|
|
|
|
name = remote
|
|
|
|
else:
|
|
|
|
name = joinremotename(remote, rname)
|
|
|
|
self.potentialentries[name] = (node, nametype, remote, rname)
|
|
|
|
|
|
|
|
def _resolvedata(self, potentialentry):
|
|
|
|
"""Check that the node for potentialentry exists and return it"""
|
|
|
|
if not potentialentry in self.potentialentries:
|
|
|
|
return None
|
|
|
|
node, nametype, remote, rname = self.potentialentries[potentialentry]
|
|
|
|
repo = self._repo
|
|
|
|
binnode = bin(node)
|
|
|
|
# if the node doesn't exist, skip it
|
|
|
|
try:
|
|
|
|
repo.changelog.rev(binnode)
|
|
|
|
except LookupError:
|
|
|
|
return None
|
|
|
|
# Skip closed branches
|
|
|
|
if nametype == "branches" and repo[binnode].closesbranch():
|
|
|
|
return None
|
|
|
|
return [binnode]
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
if not self.loaded:
|
|
|
|
self._load()
|
|
|
|
val = self._fetchandcache(key)
|
|
|
|
if val is not None:
|
|
|
|
return val
|
|
|
|
else:
|
|
|
|
raise KeyError()
|
|
|
|
|
|
|
|
def _fetchandcache(self, key):
|
|
|
|
if key in self.cache:
|
|
|
|
return self.cache[key]
|
|
|
|
val = self._resolvedata(key)
|
|
|
|
if val is not None:
|
|
|
|
self.cache[key] = val
|
|
|
|
return val
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def keys(self):
|
|
|
|
# type: () -> typing.AbstractSet[str]
|
|
|
|
"""Get a list of bookmark names"""
|
|
|
|
if not self.loaded:
|
|
|
|
self._load()
|
|
|
|
return self.potentialentries.keys()
|
|
|
|
|
2020-04-10 19:51:25 +03:00
|
|
|
def items(self):
|
2020-03-26 18:23:49 +03:00
|
|
|
"""Iterate over (name, node) tuples"""
|
|
|
|
if not self.loaded:
|
|
|
|
self._load()
|
|
|
|
for k, vtup in pycompat.iteritems(self.potentialentries):
|
|
|
|
yield (k, [bin(vtup[0])])
|
|
|
|
|
|
|
|
def __iter__(self):
|
2020-04-10 19:51:25 +03:00
|
|
|
for k, v in self.items():
|
2020-03-26 18:23:49 +03:00
|
|
|
yield k
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
return len(list(self.keys()))
|
|
|
|
|
|
|
|
|
|
|
|
def transition(repo, ui):
|
|
|
|
"""
|
|
|
|
Help with transitioning to using a remotenames workflow.
|
|
|
|
|
|
|
|
Allows deleting matching local bookmarks defined in a config file:
|
|
|
|
|
|
|
|
[remotenames]
|
|
|
|
transitionbookmarks = master
|
|
|
|
stable
|
|
|
|
|
|
|
|
TODO: Remove this once remotenames is default on everywhere.
|
|
|
|
"""
|
|
|
|
transmarks = ui.configlist("remotenames", "transitionbookmarks")
|
|
|
|
localmarks = repo._bookmarks
|
|
|
|
changes = []
|
|
|
|
for mark in transmarks:
|
|
|
|
if mark in localmarks:
|
|
|
|
changes.append((mark, None)) # delete this bookmark
|
|
|
|
if changes:
|
|
|
|
with repo.lock(), repo.transaction("remotenames") as tr:
|
|
|
|
localmarks.applychanges(repo, tr, changes)
|
|
|
|
|
|
|
|
message = ui.config("remotenames", "transitionmessage")
|
|
|
|
if message:
|
|
|
|
ui.warn(message + "\n")
|
|
|
|
|
|
|
|
|
|
|
|
def _writesingleremotename(fd, remote, nametype, name, node):
|
|
|
|
remotename = joinremotename(remote, name)
|
|
|
|
fd.write(pycompat.encodeutf8("%s %s %s\n" % (node, nametype, remotename)))
|
|
|
|
|
|
|
|
|
|
|
|
def readremotenames(repo=None, svfs=None):
|
|
|
|
if repo is not None:
|
|
|
|
svfs = repo.svfs
|
|
|
|
else:
|
|
|
|
assert svfs is not None, "either repo or svfs should be set"
|
|
|
|
return _readremotenamesfrom(svfs, "remotenames")
|
|
|
|
|
|
|
|
|
|
|
|
def _readremotenamesfrom(vfs, filename):
|
|
|
|
try:
|
|
|
|
fileobj = vfs(filename)
|
|
|
|
except EnvironmentError as er:
|
|
|
|
if er.errno != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
return
|
|
|
|
|
|
|
|
with fileobj as f:
|
|
|
|
for line in f:
|
|
|
|
nametype = None
|
|
|
|
line = line.strip()
|
|
|
|
if not line:
|
|
|
|
continue
|
|
|
|
line = pycompat.decodeutf8(line)
|
|
|
|
nametype = None
|
|
|
|
remote, rname = None, None
|
|
|
|
|
|
|
|
try:
|
|
|
|
node, name = line.split(" ", 1)
|
|
|
|
except ValueError:
|
|
|
|
raise error.CorruptedState(
|
|
|
|
_("corrupt entry in file %s: %s") % (filename, line)
|
|
|
|
)
|
|
|
|
|
|
|
|
# check for nametype being written into the file format
|
|
|
|
if " " in name:
|
|
|
|
try:
|
|
|
|
nametype, name = name.split(" ", 1)
|
|
|
|
except ValueError:
|
|
|
|
raise error.CorruptedState(
|
|
|
|
_("corrupt entry in file %s: %s") % (filename, line)
|
|
|
|
)
|
|
|
|
|
|
|
|
remote, rname = splitremotename(name)
|
|
|
|
|
|
|
|
# skip old data that didn't write the name (only wrote the alias)
|
|
|
|
if not rname:
|
|
|
|
continue
|
|
|
|
|
|
|
|
yield node, nametype, remote, rname
|
|
|
|
|
|
|
|
|
2020-04-30 15:37:51 +03:00
|
|
|
def selectivepullbookmarknames(repo, remote=None, includeaccessed=True):
|
2020-03-26 18:23:49 +03:00
|
|
|
"""Returns the bookmark names that should be pulled during a pull."""
|
|
|
|
initbooks = set(repo.ui.configlist("remotenames", "selectivepulldefault"))
|
|
|
|
|
2020-04-30 15:37:51 +03:00
|
|
|
if remote is not None and includeaccessed:
|
2020-04-16 05:18:26 +03:00
|
|
|
vfs = repo.sharedvfs
|
|
|
|
try:
|
|
|
|
accessedbooks = _readremotenamesfrom(vfs, _selectivepullaccessedbookmarks)
|
|
|
|
except error.CorruptedState:
|
|
|
|
# if the file is corrupted, let's remove it
|
|
|
|
repo.ui.warn(
|
|
|
|
_(
|
|
|
|
"'selectivepullaccessedbookmarks' file was corrupted, removing it and proceeding further\n"
|
|
|
|
)
|
2020-03-26 18:23:49 +03:00
|
|
|
)
|
2020-04-16 05:18:26 +03:00
|
|
|
with lockmod.lock(vfs, _selectivepullaccessedbookmarkslock):
|
|
|
|
vfs.unlink(_selectivepullaccessedbookmarks)
|
2020-03-26 18:23:49 +03:00
|
|
|
|
2020-04-16 05:18:26 +03:00
|
|
|
for node, nametype, remotepath, name in accessedbooks:
|
|
|
|
if nametype == "bookmarks" and remotepath == remote:
|
|
|
|
initbooks.add(name)
|
2020-03-26 18:23:49 +03:00
|
|
|
|
|
|
|
if not initbooks:
|
|
|
|
raise error.Abort(_("no bookmarks to subscribe specified for selectivepull"))
|
|
|
|
|
|
|
|
return initbooks
|
|
|
|
|
|
|
|
|
2020-03-26 18:23:49 +03:00
|
|
|
def _recordbookmarksupdate(repo, changes):
|
|
|
|
"""writes remotebookmarks changes to the journal
|
|
|
|
|
|
|
|
'changes' - is a list of tuples '(remotebookmark, oldnode, newnode)''"""
|
|
|
|
if util.safehasattr(repo, "journal"):
|
|
|
|
repo.journal.recordmany(journalremotebookmarktype, changes)
|
|
|
|
|
|
|
|
|
|
|
|
def joinremotename(remote, ref):
|
|
|
|
if ref:
|
|
|
|
remote += "/" + ref
|
|
|
|
return remote
|
|
|
|
|
|
|
|
|
|
|
|
def splitremotename(remote):
|
|
|
|
name = ""
|
|
|
|
if "/" in remote:
|
|
|
|
remote, name = remote.split("/", 1)
|
|
|
|
return remote, name
|
2020-03-26 18:23:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
def _trackaccessedbookmarks(ui):
|
|
|
|
return ui.configbool("remotenames", "selectivepullaccessedbookmarks")
|
|
|
|
|
|
|
|
|
|
|
|
def updateaccessedbookmarks(repo, remotepath, bookmarks):
|
|
|
|
if not _trackaccessedbookmarks(repo.ui):
|
|
|
|
return
|
|
|
|
|
|
|
|
# Are bookmarks already marked as accessed?
|
|
|
|
existing = set(
|
|
|
|
name
|
2020-04-03 05:24:05 +03:00
|
|
|
for _node, _nametype, oldremote, name in repo._remotenames._accessedbookmarks
|
2020-03-26 18:23:49 +03:00
|
|
|
if oldremote == remotepath
|
|
|
|
)
|
|
|
|
newdata = set(bookmarks)
|
|
|
|
if existing.issuperset(newdata):
|
|
|
|
# If so, then skip updating the accessed file.
|
|
|
|
# Note: we ignore the "node" portion of the data since it's not
|
|
|
|
# actually used.
|
|
|
|
return
|
|
|
|
|
|
|
|
vfs = repo.sharedvfs
|
|
|
|
|
|
|
|
totalaccessednames = 0
|
|
|
|
with lockmod.lock(vfs, _selectivepullaccessedbookmarkslock):
|
|
|
|
knownbooks = _readremotenamesfrom(vfs, _selectivepullaccessedbookmarks)
|
|
|
|
|
|
|
|
with vfs(_selectivepullaccessedbookmarks, "w", atomictemp=True) as f:
|
|
|
|
newbookmarks = {}
|
|
|
|
for node, nametype, oldremote, rname in knownbooks:
|
|
|
|
if nametype != "bookmarks":
|
|
|
|
continue
|
|
|
|
|
|
|
|
if oldremote != remotepath:
|
|
|
|
totalaccessednames += 1
|
|
|
|
_writesingleremotename(f, oldremote, nametype, rname, node)
|
|
|
|
else:
|
|
|
|
newbookmarks[rname] = node
|
|
|
|
|
|
|
|
nodemap = repo.unfiltered().changelog.nodemap
|
|
|
|
for rname, node in pycompat.iteritems(bookmarks):
|
|
|
|
# if the node is known locally, update the old value or add new
|
|
|
|
if bin(node) in nodemap:
|
|
|
|
newbookmarks[rname] = node
|
|
|
|
|
|
|
|
for rname, node in pycompat.iteritems(newbookmarks):
|
|
|
|
totalaccessednames += 1
|
|
|
|
_writesingleremotename(f, remotepath, "bookmarks", rname, node)
|
|
|
|
|
2020-04-03 05:24:05 +03:00
|
|
|
repo._remotenames._accessedbookmarks = list(
|
2020-03-26 18:23:49 +03:00
|
|
|
_readremotenamesfrom(repo.sharedvfs, _selectivepullaccessedbookmarks)
|
|
|
|
)
|
|
|
|
|
|
|
|
# log the number of accessed bookmarks currently tracked
|
|
|
|
repo.ui.log("accessedremotenames", accessedremotenames_totalnum=totalaccessednames)
|