amend: remove hiddenoverride

Summary:
`hiddenoverride` is a hacky implementation that preserves part of another hacky
`inhibit` extension. With our modern setup (inhibit or narrow-heads),
`hiddenoverride` is less useful. Therefore just remove it.

Reviewed By: sfilipco

Differential Revision: D20148011

fbshipit-source-id: f4a5f05b67ae6f315e9b07d50ef03018d6d05df5
This commit is contained in:
Jun Wu 2020-02-28 17:42:44 -08:00 committed by Facebook Github Bot
parent 059c9bbcfc
commit 5d253a75df
7 changed files with 9 additions and 164 deletions

View File

@ -71,7 +71,6 @@ from .. import histedit, rebase as rebasemod
from . import (
common,
fold,
hiddenoverride,
hide,
metaedit,
movement,
@ -182,7 +181,6 @@ def hintsplitphabricator(advice):
def uisetup(ui):
hiddenoverride.uisetup(ui)
entry = extensions.wrapcommand(commands.table, "commit", commit)
for opt in amendopts:
opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3])

View File

@ -1,146 +0,0 @@
# 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.
# hiddenoverride.py - lightweight hidden-ness override
from __future__ import absolute_import
from edenscm.hgext import extutil
from edenscm.mercurial import (
dispatch,
error,
extensions,
obsolete,
repoview,
scmutil,
util,
visibility,
)
from edenscm.mercurial.node import short
def uisetup(ui):
extensions.wrapfunction(repoview, "pinnedrevs", pinnedrevs)
extensions.wrapfunction(dispatch, "runcommand", runcommand)
extensions.wrapfunction(obsolete, "createmarkers", createmarkers)
extensions.wrapfunction(scmutil, "cleanupnodes", cleanupnodes)
def pinnedrevs(orig, repo):
revs = orig(repo)
if "visibleheads" not in repo.storerequirements and not visibility.enabled(repo):
nodemap = repo.changelog.nodemap
pinnednodes = set(loadpinnednodes(repo))
tounpin = getattr(repo, "_tounpinnodes", set())
pinnednodes -= tounpin
revs.update(nodemap[n] for n in pinnednodes)
return revs
def loadpinnednodes(repo):
"""yield pinned nodes that are obsoleted and should be visible"""
if repo is None or not repo.local():
return
# the "pinned nodes" file name is "obsinhibit" for compatibility reason
content = repo.svfs.tryread("obsinhibit") or ""
unfi = repo.unfiltered()
nodemap = unfi.changelog.nodemap
offset = 0
result = []
while True:
node = content[offset : offset + 20]
if not node:
break
if node in nodemap:
result.append(node)
offset += 20
return result
def shouldpinnodes(repo):
"""get nodes that should be pinned: working parent + bookmarks for now"""
result = set()
if repo and repo.local():
# working copy parent
try:
wnode = repo.localvfs("dirstate").read(20)
result.add(wnode)
except Exception:
pass
# bookmarks
result.update(repo.unfiltered()._bookmarks.values())
return result
def savepinnednodes(repo, newpin, newunpin, fullargs):
# take a narrowed lock so it does not affect repo lock
with extutil.flock(repo.svfs.join("obsinhibit.lock"), "save pinned nodes"):
orignodes = loadpinnednodes(repo)
nodes = set(orignodes)
nodes |= set(newpin)
nodes -= set(newunpin)
with util.atomictempfile(repo.svfs.join("obsinhibit")) as f:
f.write(b"".join(nodes))
desc = lambda s: [short(n) for n in s]
repo.ui.log(
"pinnednodes",
"pinnednodes: %r newpin=%r newunpin=%r " "before=%r after=%r\n",
fullargs,
desc(newpin),
desc(newunpin),
desc(orignodes),
desc(nodes),
)
def runcommand(orig, lui, repo, cmd, fullargs, *args):
# return directly for non-repo command
if not repo or "visibleheads" in repo.storerequirements:
return orig(lui, repo, cmd, fullargs, *args)
shouldpinbefore = shouldpinnodes(repo) | set(loadpinnednodes(repo))
result = orig(lui, repo, cmd, fullargs, *args)
# after a command completes, make sure working copy parent and all
# bookmarks get "pinned".
newpin = shouldpinnodes(repo) - shouldpinbefore
newunpin = getattr(repo.unfiltered(), "_tounpinnodes", set())
# filter newpin by obsolte - ex. if newpin is on a non-obsoleted commit,
# ignore it.
if newpin:
unfi = repo.unfiltered()
obsoleted = unfi.revs("obsolete()")
nodemap = unfi.changelog.nodemap
newpin = set(n for n in newpin if n in nodemap and nodemap[n] in obsoleted)
# only do a write if something has changed
if newpin or newunpin:
savepinnednodes(repo, newpin, newunpin, fullargs)
return result
def createmarkers(orig, repo, rels, *args, **kwargs):
# this is a way to unpin revs - precursors are unpinned
# note: hg debugobsolete does not call this function
if "visibleheads" not in repo.storerequirements:
unfi = repo.unfiltered()
tounpin = getattr(unfi, "_tounpinnodes", set())
for r in rels:
try:
tounpin.add(r[0].node())
except error.RepoLookupError:
pass
unfi._tounpinnodes = tounpin
return orig(repo, rels, *args, **kwargs)
def cleanupnodes(orig, repo, mapping, *args, **kwargs):
# this catches cases where cleanupnodes is called but createmarkers is not
# called. unpin nodes from mapping
if "visibleheads" not in repo.storerequirements:
unfi = repo.unfiltered()
tounpin = getattr(unfi, "_tounpinnodes", set())
tounpin.update(mapping)
unfi._tounpinnodes = tounpin
return orig(repo, mapping, *args, **kwargs)

View File

@ -83,7 +83,7 @@ Test that updating to new head after hiding current head works as expected.
1 changeset hidden
$ hg up -qr "heads(.::)"
$ hg log -r "." -T "{node|short}\n"
c1b6fe8fce73
f8b49bf62d4d
Check hg up on another client.
Commit should be pulled from backup storage.

View File

@ -808,8 +808,6 @@ Sync in client 2. It doesn't have the new destination of midbook, so should omi
$ tglogp
o 10: 2ace67ee4791 draft 'oldstack-mar4 amended'
|
| x 9: 2b8dce7bd745 draft 'oldstack-mar4'
|/
o 8: d16408588b2d draft 'oldstack-feb4'
|
o 7: 1f9ebd6d1390 draft 'oldstack-feb1'
@ -823,8 +821,6 @@ Sync in client 2. It doesn't have the new destination of midbook, so should omi
|
| @ 10: 2ace67ee4791 draft 'oldstack-mar4 amended'
| |
| | x 9: 2b8dce7bd745 draft 'oldstack-mar4'
| |/
| o 2: d16408588b2d draft 'oldstack-feb4'
| |
| o 1: 1f9ebd6d1390 draft 'oldstack-feb1'

View File

@ -443,10 +443,11 @@ hiddenoverride, but commit cloud ignores it).
$ cd ../client2
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
detected obsmarker inconsistency (fixing by obsoleting [] and reviving [878302dcadc7])
commitcloud: commits synchronized
finished in * (glob)
$ tglogp -r $F::
x 7: 878302dcadc7 draft 'G'
o 7: 878302dcadc7 draft 'G'
|
o 6: 64b4d9634423 draft 'F'
|
@ -457,10 +458,11 @@ In client 1 the obsmarker inconsistency is finally detected and fixed.
$ cd ../client1
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
detected obsmarker inconsistency (fixing by obsoleting [878302dcadc7] and reviving [])
commitcloud: commits synchronized
finished in * (glob)
$ tglogp -r $F::
o 7: 878302dcadc7 draft 'G'
|
o 4: 64b4d9634423 draft 'F'
|
~
@ -474,19 +476,19 @@ Everything is stable now.
$ cd ../client2
$ hg cloud sync -q
$ tglogp -r $F::
x 7: 878302dcadc7 draft 'G'
o 7: 878302dcadc7 draft 'G'
|
o 6: 64b4d9634423 draft 'F'
|
~
$ python $TESTTMP/dumpcommitcloudmetadata.py
version: 6
version: 5
bookmarks:
foo => 5817a557f93f46ab290e8571c89624ff856130c0
heads:
65299708466caa8f13c05d82e76d611c183defee
27ad028060800678c2de95fea2e826bbd4bf2c21
64b4d963442377cb7aa4b0997eeca249ac8643c9
878302dcadc7a800f326d8e06a5e9beec77e5a1c
Make a new commit. Copy it to the other client via a bundle, and then hide it
with commit cloud inactive.

View File

@ -615,8 +615,6 @@ Expected result: client2 should be moved to 68e035cc1996
|/
| o 6: 8134e74ecdc8 'commit2 amended amended' bookmark1
|/
| x 5: 41f3b9359864 'commit2 amended'
|/
o 3: a7bb357e7299 'commit1 amended' bookmark1-testhost
|
o 0: d20a80d4def3 'base'
@ -632,11 +630,10 @@ Clean up by hiding some commits, and create a new stack
$ hg update d20a80d4def3 -q
$ hg hide a7bb357e7299
hiding commit a7bb357e7299 "commit1 amended"
hiding commit 41f3b9359864 "commit2 amended"
hiding commit 8134e74ecdc8 "commit2 amended amended"
hiding commit fada67350ab0 "commit2 amended amended amended amended amended"
hiding commit 68e035cc1996 "commit2 amended amended rebased amended rebased am"
5 changesets hidden
4 changesets hidden
removing bookmark "bookmark1 (was at: 8134e74ecdc8)"
removing bookmark "bookmark1-testhost (was at: a7bb357e7299)"
2 bookmarks removed

View File

@ -180,7 +180,5 @@ Hidden changesets are not considered as successors
hint[strip-hide]: 'hg strip' may be deprecated in the future - use 'hg hide' instead
hint[hint-ack]: use 'hg hint --ack strip-hide' to silence these hints
$ hg log -T "{rev} {node|short} {amendsuccessors % '(amend as {short(amendsuccessor)}) '}\n" -G -r 'all()'
x 1 66f7d451a68b
|
@ 0 1ea73414a91b