2009-06-14 03:01:48 +04:00
|
|
|
# Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2009-06-14 03:01:48 +04:00
|
|
|
|
2018-09-28 17:08:38 +03:00
|
|
|
"""share a common history between several working directories"""
|
2009-06-21 18:45:47 +04:00
|
|
|
|
2016-07-03 19:58:24 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import error, hg, registrar
|
|
|
|
from edenscm.mercurial.i18n import _
|
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-07-03 19:58:24 +03:00
|
|
|
|
|
|
|
repository = hg.repository
|
2011-08-11 02:04:00 +04:00
|
|
|
|
2014-05-05 08:33:14 +04:00
|
|
|
cmdtable = {}
|
2016-01-09 17:07:20 +03:00
|
|
|
command = registrar.command(cmdtable)
|
2016-08-23 18:26:08 +03:00
|
|
|
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
|
2015-04-28 23:44:37 +03:00
|
|
|
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
|
|
|
|
# be specifying the version(s) of Mercurial they are tested with, or
|
|
|
|
# leave the attribute unspecified.
|
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
|
|
|
testedwith = "ships-with-hg-core"
|
|
|
|
|
|
|
|
|
|
|
|
@command(
|
|
|
|
"share",
|
|
|
|
[
|
|
|
|
("U", "noupdate", None, _("do not create a working directory")),
|
|
|
|
("B", "bookmarks", None, _("also share bookmarks")),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"relative",
|
|
|
|
None,
|
|
|
|
_("point to source using a relative path " "(EXPERIMENTAL)"),
|
|
|
|
),
|
2017-02-13 16:05:24 +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
|
|
|
_("[-U] [-B] SOURCE [DEST]"),
|
|
|
|
norepo=True,
|
|
|
|
)
|
|
|
|
def share(ui, source, dest=None, noupdate=False, bookmarks=False, relative=False):
|
2010-04-01 02:02:12 +04:00
|
|
|
"""create a new shared repository
|
2009-06-14 03:01:48 +04:00
|
|
|
|
2009-07-26 04:01:19 +04:00
|
|
|
Initialize a new repository and working directory that shares its
|
2014-12-13 22:32:46 +03:00
|
|
|
history (and optionally bookmarks) with another repository.
|
2009-06-14 03:01:48 +04:00
|
|
|
|
2010-09-22 18:23:55 +04:00
|
|
|
.. note::
|
2013-11-05 11:59:55 +04:00
|
|
|
|
2010-09-22 18:23:55 +04:00
|
|
|
using rollback or extensions that destroy/modify history (mq,
|
|
|
|
rebase, etc.) can cause considerable confusion with shared
|
|
|
|
clones. In particular, if two shared clones are both updated to
|
|
|
|
the same changeset, and one of them destroys that changeset
|
|
|
|
with rollback, the other clone will suddenly stop working: all
|
|
|
|
operations will fail with "abort: working directory has unknown
|
|
|
|
parent". The only known workaround is to use debugsetparents on
|
2013-07-12 04:26:53 +04:00
|
|
|
the broken clone to reset it to a changeset that still exists.
|
2009-06-14 03:01:48 +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
|
|
|
hg.share(
|
|
|
|
ui,
|
|
|
|
source,
|
|
|
|
dest=dest,
|
|
|
|
update=not noupdate,
|
|
|
|
bookmarks=bookmarks,
|
|
|
|
relative=relative,
|
|
|
|
)
|
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Previously, only the top level repo was shared, and then any subrepos were
cloned on demand. This is problematic because commits to the parent repo would
write an updated .hgsubstate to the share source, but the corresponding subrepo
commit would be stuck in the local subrepo. That would prevent an update in the
source repo. We already go to great lengths to avoid having inconsistent repos
(e.g., `hg push -r rev` will push _everything_ in a subrepo, even if it isn't
referenced in one of the parent's outgoing commits). Therefore, this seems like
a bug fix, and there's no option to get the old behavior. I can't imagine the
previous behavior was useful to anybody.
There shouldn't be an issue with svn, since it is centralized. Maybe --git-dir
can be used for git subrepos, but I'll leave that to someone more familiar with
git.
An integer was previously being implicitly returned from commands.share(), which
caused dispatch() to start crashing when changing over to returning the shared
repo. All error paths appear to raise, so this can be hardcoded to success.
The clone command checks for 'is None' in a similar pattern, but since
hg.clone() always returns a tuple, that seems wrong?
.. fix:: Issue 5675
Creating a share of a repository with a Mercurial subrepository will now
share the subrepository.
and
.. bc::
Mercurial subrepositories are now shared instead of cloned when the parent
repository is shared. This prevents dangling subrepository references in the
share source. Previously shared repositories with cloned subrepositories
will continue to function unchanged.
2017-10-16 05:48:02 +03:00
|
|
|
return 0
|
2009-06-14 03:01:48 +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
|
|
|
|
|
|
|
@command("unshare", [], "")
|
2011-08-11 02:04:00 +04:00
|
|
|
def unshare(ui, repo):
|
|
|
|
"""convert a shared repository to a normal one
|
|
|
|
|
|
|
|
Copy the store data to the repo and remove the sharedpath data.
|
|
|
|
"""
|
|
|
|
|
2014-12-21 02:19:10 +03:00
|
|
|
if not repo.shared():
|
2015-10-08 22:55:45 +03:00
|
|
|
raise error.Abort(_("this is not a shared repo"))
|
2011-08-11 02:04:00 +04:00
|
|
|
|
2017-10-18 04:48:56 +03:00
|
|
|
hg.unshare(ui, repo)
|