remove accessed bookmarks feature

Summary:
Remove selectivepullaccessedbookmarks feature because it contains bugs and causes many undesired issues.

This was added to migrate existing repos to selective pull and is not needed anymore.

Main effects are:

* if you enable selectivepull for an existing repo, it won't reduce number of subscribed bookmarks.
* some operations like `hg push` or `hg pull -r` in their underlying implementation update all subscribed bookmarks, not just accessed like before.
This drives changes to the tests. Reminder, the bookmark has been marked as "accessed" if the repo has been ever updated to that bookmark.

All tests fixed accordingly.

Reviewed By: markbt

Differential Revision: D26460435

fbshipit-source-id: f839b9f207bfc478a0336ec807b720d35a0bb12e
This commit is contained in:
Liubov Dmitrieva 2021-02-18 04:00:22 -08:00 committed by Facebook GitHub Bot
parent 08a4201285
commit 84280e36c3
21 changed files with 107 additions and 510 deletions

View File

@ -130,13 +130,14 @@ check unhydrated infinitepush pulls
sending listkeys command
received listkey for "bookmarks": 57 bytes
sending lookup command
sending lookup command
preparing listkeys for "bookmarks"
sending listkeys command
received listkey for "bookmarks": 57 bytes
query 1; heads
sending batch command
searching for changes
local heads: 1; remote heads: 1 (explicit: 1); initial common: 1
local heads: 1; remote heads: 1 (explicit: 2); initial common: 1
all remote heads known locally
sending getbundle command
bundle2-input-bundle: 1 params with-transaction
@ -212,13 +213,14 @@ check hydrated infinitepush pulls
sending listkeys command
received listkey for "bookmarks": 57 bytes
sending lookup command
sending lookup command
preparing listkeys for "bookmarks"
sending listkeys command
received listkey for "bookmarks": 57 bytes
query 1; heads
sending batch command
searching for changes
local heads: 1; remote heads: 1 (explicit: 1); initial common: 1
local heads: 1; remote heads: 1 (explicit: 2); initial common: 1
all remote heads known locally
sending getbundle command
bundle2-input-bundle: 1 params with-transaction

View File

@ -191,7 +191,7 @@ pull the infinitepush commit again in a new repo
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files
added 2 changesets with 0 changes to 0 files
$ hgmn up 60ab8a6c8e652ea968be7ffdb658b49de35d3621
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg debughistorypack ../cachepath/repo-pull2/packs/e5e1a8b81e9d2360fe54412f8370812c06c6cadb
@ -214,6 +214,6 @@ NOTE: Mononoke gave us the public commit as the linknode
$ hg log -T '{node} {desc} ({remotenames})\n' -f file
linkrevfixup: file b4aa7b980f00bcd3ea58510798c1425dcdc511f3
60ab8a6c8e652ea968be7ffdb658b49de35d3621 branch ()
d998012a9c34a2423757a3d40f8579c78af1b342 base (default/master_bookmark)
d998012a9c34a2423757a3d40f8579c78af1b342 base ()
NOTE: linkrevfixup was called to fix up the linkrev

View File

@ -150,6 +150,7 @@ blobimport
$ hg log -G
@ commit: * (glob)
bookmark: head_bookmark
bookmark: default/head_bookmark
user: user
date: * (glob)
summary: [MEGAREPO CATCHUP DELETE] deletion commit (1)
@ -172,7 +173,6 @@ blobimport
summary: move files in small repo
o commit: b662a919caea
bookmark: default/head_bookmark
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new commit in large repo

View File

@ -339,7 +339,7 @@ Perform ovrsource pushrebase, make sure it is push-redirected into Fbsource
updating bookmark master_bookmark
-- pushredirected_3 was correctly pushed to master_bookmark in ovrsource
$ log -r master_bookmark
@ pushredirected_3 [public;rev=4;4355e6b9eafb] default/master_bookmark
@ pushredirected_3 [public;rev=5;4355e6b9eafb] default/master_bookmark
~
-- pushredirected_3 is also present in megarepo

View File

@ -427,7 +427,7 @@ Test non-fast-forward force pushrebase
adding changesets
adding manifests
adding file changes
added 8 changesets with 0 changes to 0 files
added 12 changesets with 0 changes to 0 files
$ hgmn up newbook
7 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hgmn debugsh -c 'ui.write("%s\n" % m.node.hex(repo["."].filectx("was_a_lively_fellow").getnodeinfo()[2]))'

View File

@ -279,8 +279,6 @@ def cloudjoin(ui, repo, **opts):
for key in sync._getremotebookmarks(repo).keys()
}
sync._updateremotebookmarks(repo, tr, bmremove)
# erase state of the remote accessed bookmarks as well
bookmarksmod.cleanselectivepullaccessedbookmarks(repo)
# erase state if the repo has been connected before to the destination workspace
syncstate.SyncState.erasestate(repo, workspacename)
# clear subscription

View File

@ -57,11 +57,8 @@ from edenscm.mercurial import (
)
from edenscm.mercurial.bookmarks import (
_readremotenamesfrom,
_selectivepullaccessedbookmarks,
_selectivepullaccessedbookmarkslock,
_selectivepullenabledfile,
_selectivepullenabledfilelock,
_trackaccessedbookmarks,
_writesingleremotename,
_enableselectivepullforremote,
_disableselectivepull,
@ -71,7 +68,6 @@ from edenscm.mercurial.bookmarks import (
saveremotenames,
selectivepullbookmarknames,
splitremotename,
updateaccessedbookmarks,
)
from edenscm.mercurial.i18n import _
from edenscm.mercurial.node import bin, hex, nullid, short
@ -102,7 +98,6 @@ configitem("remotenames", "pushanonheads", default=False)
configitem("remotenames", "pushrev", default=None)
configitem("remotenames", "resolvenodes", default=True)
configitem("remotenames", "selectivepull", default=False)
configitem("remotenames", "selectivepullaccessedbookmarks", default=False)
configitem("remotenames", "syncbookmarks", default=False)
configitem("remotenames", "tracking", default=True)
configitem("remotenames", "transitionbookmarks", default=[])
@ -183,10 +178,6 @@ def _listremotebookmarks(remote, bookmarks):
return result
def _reportaccessedbookmarks(ui, accessedremotenames):
ui.log("accessedremotenames", accessedremotenames_totalnum=len(accessedremotenames))
def expull(orig, repo, remote, heads=None, force=False, **kwargs):
if not kwargs.get("opargs", {}).get("extras", {}).get("bookmarks", True):
# The callsite disables the bookmarks pulling.
@ -236,13 +227,6 @@ def _expull(orig, repo, remote, heads=None, force=False, **kwargs):
else:
_disableselectivepull(repo)
if _trackaccessedbookmarks(repo.ui):
pulledbookmarks = kwargs.get("bookmarks", [])
if pulledbookmarks:
accessedbookmarks = _listremotebookmarks(remote, pulledbookmarks)
remotepath = activepath(repo.ui, remote)
updateaccessedbookmarks(repo, remotepath, accessedbookmarks)
return res
@ -673,7 +657,6 @@ def extsetup(ui):
bookcmd = extensions.wrapcommand(commands.table, "bookmarks", exbookmarks)
pushcmd = extensions.wrapcommand(commands.table, "push", expushcmd)
localrepo.localrepository._wlockfreeprefix.add("selectivepullaccessedbookmarks")
localrepo.localrepository._wlockfreeprefix.add("selectivepullenabled")
if _tracking(ui):

View File

@ -397,7 +397,6 @@ def interestingheads(repo, subset, x):
for name in _reposnames(repo.ui):
nodes = ns.namemap(repo, name)
if nodes:
ns.accessed(repo, name)
heads.add(rev(nodes[0]))
return subset & smartset.baseset(heads, repo=repo)

View File

@ -45,9 +45,6 @@ journalremotebookmarktype = "remotebookmark"
# happened
_selectivepullenabledfile = "selectivepullenabled"
_selectivepullenabledfilelock = "selectivepullenabled.lock"
_selectivepullaccessedbookmarks = "selectivepullaccessedbookmarks"
# separate lock to update accessed bookmarks
_selectivepullaccessedbookmarkslock = "selectivepullaccessedbookmarks.lock"
def _getbkfile(repo):
@ -1019,9 +1016,6 @@ class remotenames(dict):
dict.__init__(self, *args)
self._repo = repo
self.clearnames()
self._accessedbookmarks = list(
_readremotenamesfrom(repo.sharedvfs, _selectivepullaccessedbookmarks)
)
def clearnames(self):
"""Clear all remote names state"""
@ -1348,12 +1342,6 @@ def mainbookmark(repo):
return names[0]
def cleanselectivepullaccessedbookmarks(repo):
vfs = repo.sharedvfs
with lockmod.lock(vfs, _selectivepullaccessedbookmarkslock):
vfs.tryunlink(_selectivepullaccessedbookmarks)
def selectivepullinitbookmarknames(repo):
"""Returns set of initial remote bookmarks"""
return set(repo.ui.configlist("remotenames", "selectivepulldefault"))
@ -1362,28 +1350,12 @@ def selectivepullinitbookmarknames(repo):
def selectivepullbookmarknames(repo, remote=None, includeaccessed=True):
"""Returns the bookmark names that should be pulled during a pull."""
initbooks = set(repo.ui.configlist("remotenames", "selectivepulldefault"))
if remote is not None and includeaccessed:
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"
)
)
with lockmod.lock(vfs, _selectivepullaccessedbookmarkslock):
vfs.unlink(_selectivepullaccessedbookmarks)
for node, nametype, remotepath, name in accessedbooks:
if remote is not None:
for node, nametype, remotepath, name in readremotenames(repo):
if nametype == "bookmarks" and remotepath == remote:
initbooks.add(name)
if not initbooks:
raise error.Abort(_("no bookmarks to subscribe specified for selectivepull"))
return initbooks
@ -1413,63 +1385,6 @@ def remotenameforurl(ui, url):
return ui.paths.getname(url, forremotenames=True)
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
for _node, _nametype, oldremote, name in repo._remotenames._accessedbookmarks
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.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)
repo._remotenames._accessedbookmarks = list(
_readremotenamesfrom(repo.sharedvfs, _selectivepullaccessedbookmarks)
)
# log the number of accessed bookmarks currently tracked
repo.ui.log("accessedremotenames", accessedremotenames_totalnum=totalaccessednames)
def _readisselectivepullenabledfile(repo):
try:
with repo.sharedvfs(_selectivepullenabledfile, "rb") as f:

View File

@ -4993,12 +4993,6 @@ def _newpull(ui, repo, source, **opts):
# Update the file marking selectivepull is enabled.
bookmarks._enableselectivepullforremote(repo, remotename)
# Update accessed bookmarks with -B parameters.
if bookmarks._trackaccessedbookmarks(repo.ui):
accessed = namestonamehex(opts.get("bookmark") or [])
if accessed:
bookmarks.updateaccessedbookmarks(repo, remotename, accessed)
# Decide return value.
if oldlen == newlen:
# Not changed.

View File

@ -11,7 +11,6 @@
from __future__ import absolute_import
from . import error, pycompat, registrar, templatekw, util
from .bookmarks import _trackaccessedbookmarks, splitremotename, updateaccessedbookmarks
from .i18n import _
from .node import hex
@ -68,14 +67,6 @@ def branches(repo):
def remotebookmarks(repo):
namemap = lambda repo, name: repo._remotenames.mark2nodes().get(name, [])
def accessed(repo, name):
if _trackaccessedbookmarks(repo.ui):
nodes = namemap(repo, name)
if nodes:
rnode = hex(nodes[0])
remote, rname = splitremotename(name)
updateaccessedbookmarks(repo, remote, {rname: rnode})
return namespace(
templatename="remotebookmarks",
logname="bookmark",
@ -84,7 +75,6 @@ def remotebookmarks(repo):
namemap=namemap,
nodemap=lambda repo, node: repo._remotenames.node2marks().get(node, []),
builtin=True,
accessed=accessed,
)
@ -95,13 +85,6 @@ def hoistednames(repo):
if hoist:
namemap = lambda repo, name: repo._remotenames.hoist2nodes(hoist).get(name, [])
def accessed(repo, name):
if _trackaccessedbookmarks(repo.ui):
nodes = namemap(repo, name)
if nodes:
rnode = hex(nodes[0])
updateaccessedbookmarks(repo, hoist, {name: rnode})
return namespace(
templatename="hoistednames",
logname="hoistedname",
@ -112,7 +95,6 @@ def hoistednames(repo):
node, []
),
builtin=True,
accessed=accessed,
)
else:
return None
@ -182,7 +164,6 @@ class namespaces(object):
continue
n = v.namemap(repo, name)
if n:
v.accessed(repo, name)
# return max revision number
if len(n) > 1:
cl = repo.changelog
@ -218,9 +199,6 @@ class namespace(object):
'deprecated': set of names to be masked for ordinary use
'builtin': bool indicating if this namespace is supported by core
Mercurial.
'accessed': function, that is used to log if the name from the namespace
was accessed. The method helps to build metrics around name
"access" event.
"""
def __init__(
@ -234,7 +212,6 @@ class namespace(object):
nodemap=None,
deprecated=None,
builtin=False,
accessed=None,
):
"""create a namespace
@ -250,8 +227,6 @@ class namespace(object):
nodemap: function that inputs a node, output name(s)
deprecated: set of names to be masked for ordinary use
builtin: whether namespace is implemented by core Mercurial
accessed: function, that is used to log if the name from the namespace
was accessed
"""
self.templatename = templatename
@ -262,11 +237,6 @@ class namespace(object):
self.namemap = namemap
self.nodemap = nodemap
if accessed is not None:
self.accessed = accessed
else:
self.accessed = lambda repo, name: None
# if logname is not specified, use the template name as backup
if self.logname is None:
self.logname = self.templatename

View File

@ -161,21 +161,10 @@ Pull in this repo
$ hg pull
pulling from ssh://user@dummy/server
no changes found
$ showgraph
o draft1: draft remote/scratch/draft1
o public3: draft
@ public1: public remote/master
o base: public
BUG! our subscriptions have been lost
Work around this by pulling them by name
$ hg pull -B created -B other
pulling from ssh://user@dummy/server
no changes found
adding changesets
adding manifests
adding file changes
added 0 changesets with 1 changes to 1 files
$ showgraph
o draft1: draft remote/scratch/draft1
@ -187,7 +176,6 @@ Work around this by pulling them by name
o base: public
Sync in the third repo
$ cd $TESTTMP/client3
$ hg cloud sync -q

View File

@ -25,7 +25,6 @@ Set remotebookmarkssync True initially for the first repo and False for the seco
$ cd client1
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepulldefault=master,base
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig commitcloud.remotebookmarkssync=True
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg cloud join
@ -41,7 +40,6 @@ Set remotebookmarkssync True initially for the first repo and False for the seco
$ cd client2
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepulldefault=master,base
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig commitcloud.remotebookmarkssync=False
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg cloud join

View File

@ -29,6 +29,7 @@ Setup remote repo
$ hg up $ROOT -q
$ mkcommit b1 serv
$ hg book stable
$ hg book main
$ hg up $ROOT -q
$ mkcommit a1 serv
@ -40,18 +41,17 @@ Setup remote repo
o a1: draft
o b1: draft stable
o b1: draft main stable
o c1: draft warm
o root: draft
Setup first client repo
Setup first client repo and subscribe to the bookmarks "stable" and "warm".
$ cd ..
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepulldefault=master
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig commitcloud.remotebookmarkssync=True
$ hg clone -q ssh://user@dummy/remoterepo client1
@ -59,11 +59,7 @@ Setup first client repo
$ hg pull -B stable -B warm -q
$ hg up 'desc(a2)' -q
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg cloud join
commitcloud: this repository is now connected to the 'user/test/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ hg cloud join -q
$ showgraph
@ a2: public default/master
@ -75,16 +71,24 @@ Setup first client repo
o root: public
Setup second client repo
Setup the second client repo with enable remote bookmarks sync
The repo should be subscribed the "stable" and "warm" bookmark because the client1 was.
$ cd ..
$ hg clone -q ssh://user@dummy/remoterepo client2
$ cd client2
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg cloud join
commitcloud: this repository is now connected to the 'user/test/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ hg cloud join -q
$ showgraph
@ a2: public default/master
o a1: public
o b1: public default/stable
o c1: public default/warm
o root: public
Setup third client repo but do not enable remote bookmarks sync
$ cd ..
@ -93,8 +97,15 @@ Setup third client repo but do not enable remote bookmarks sync
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ setconfig commitcloud.remotebookmarkssync=False
$ hg cloud join -q
$ showgraph
@ a2: public default/master
o a1: public
o root: public
Common case of unsynchronized remote bookmarks
Common case of unsynchronized remote bookmarks ("master")
$ cd ../remoterepo
$ mkcommit a3 serv
$ cd ../client2
@ -111,6 +122,10 @@ Common case of unsynchronized remote bookmarks
o a1: public
o b1: public default/stable
o c1: public default/warm
o root: public
@ -126,12 +141,16 @@ default/master should point to the new commit
o a1: public
o b1: public default/stable
o c1: public default/warm
o root: public
Subscribe to a new remote bookmark
Subscribe to a new remote bookmark "main" that previously has been only known on the server
$ cd ../client1
$ hg pull -q
$ hg pull -B stable -q
$ hg pull -B main -q
$ hg cloud sync -q
$ showgraph
o draft-1: draft
@ -142,18 +161,19 @@ Subscribe to a new remote bookmark
o a1: public
o b1: public default/stable
o b1: public default/main default/stable
o c1: public default/warm
o root: public
$ hg book --list-subscriptions
default/main b2bfab231667
default/master 1b6e90080435
default/stable b2bfab231667
default/warm b8063fc7de93
the other client should be subscribed to this bookmark as well
the other client should be subscribed to this bookmark ("main") as well
$ cd ../client2
$ hg cloud sync -q
$ showgraph
@ -165,13 +185,14 @@ the other client should be subscribed to this bookmark as well
o a1: public
o b1: public default/stable
o b1: public default/main default/stable
o c1: public default/warm
o root: public
$ hg book --list-subscriptions
default/main b2bfab231667
default/master 1b6e90080435
default/stable b2bfab231667
default/warm b8063fc7de93
@ -195,7 +216,7 @@ try to create a commit on top of the default/stable
o a1: public
o b1: public default/stable
o b1: public default/main default/stable
o c1: public default/warm
@ -219,7 +240,7 @@ check that copy with disabled remote bookmarks sync doesn't affect the other cop
o a1: public
o b1: public default/stable
o b1: public default/main default/stable
o c1: public default/warm
@ -271,7 +292,7 @@ sync and create a new commit on top of the draft-3
o a1: public
o b1: public default/stable
o b1: public default/main default/stable
o c1: public default/warm

View File

@ -86,8 +86,9 @@ Stack of non-conflicting commits should be accepted
sending batch command
searching for changes
local heads: 1; remote heads: 1 (explicit: 0); initial common: 0
sampling undecided commits (2 of 2)
query 2; still undecided: 2, sample size is: 2
sampling from both directions (1 of 1)
sampling undecided commits (1 of 1)
query 2; still undecided: 1, sample size is: 1
sending known command
2 total queries in *s (glob)
preparing listkeys for "bookmarks" with pattern "['main']"

View File

@ -135,10 +135,12 @@ Push to scratch branch
remote: 20759b6926ce scratchcommit
remote: 1de1d7d92f89 new scratch commit
$ hg log -G -T '{desc} {phase} {bookmarks}'
@ new scratch commit draft
o scratchcommit draft
o newcommit public
@ new scratch commit draft
o scratchcommit draft
o initialcommit public
$ scratchnodes
@ -156,10 +158,12 @@ Push scratch bookmark with no new revs
remote: 20759b6926ce scratchcommit
remote: 1de1d7d92f89 new scratch commit
$ hg log -G -T '{desc} {phase} {bookmarks}'
@ new scratch commit draft
o scratchcommit draft
o newcommit public
@ new scratch commit draft
o scratchcommit draft
o initialcommit public
$ scratchbookmarks
@ -361,17 +365,19 @@ Use --force because this push creates new head
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 2 files
remote: added 1 changesets with 1 changes to 1 files
$ hg -R ../repo log -G -T '{desc} {phase} {bookmarks}'
o newcommit draft main
o initialcommit draft
$ hg -R ../client2 log -G -T '{desc} {phase} {bookmarks}'
@ new scratch commit draft
o scratchcommit draft
o newcommit public
@ new scratch commit draft
o scratchcommit draft
o initialcommit public
$ hg book --list-remote scratch/*

View File

@ -135,7 +135,7 @@ Go back to client, make pull and make sure that we pulled remote branches
64d557aa86fdc42384b193f7eab99059da84f1f0 bookmarks default/scratch/serverbook
$ cd ..
Push from another client, make sure that push doesn't override scratch bookmarks
Push from another client, make sure that push updates other remote bookmarks as well (like "serverbook")
$ cd client2
$ hg up scratch/serverbook
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@ -148,7 +148,7 @@ Push from another client, make sure that push doesn't override scratch bookmarks
$ hg book --remote
default/scratch/mybranch 620472ff5c0c
default/scratch/secondbranch 36667a3f76e4
default/scratch/serverbook ac312cb08db5
default/scratch/serverbook 64d557aa86fd
$ hg book
no bookmarks set

View File

@ -165,8 +165,12 @@ creation of a new one (locally unknonw).
rbook2 7c3bad9141dc
$ cd ..
Force client to get data about new bookmarks without getting commits
Force client to get data about new bookmarks without getting commits.
Expect update for the bookmark after the push.
$ cd rnclient
$ hg book --all
no bookmarks set
default/rbook 1f0dee641bb7
$ hg push
pushing to $TESTTMP/repo2/rnserver
searching for changes
@ -174,7 +178,7 @@ Force client to get data about new bookmarks without getting commits
[1]
$ hg book --all
no bookmarks set
default/rbook 1f0dee641bb7
default/rbook 7c3bad9141dc
$ hg update rbook
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

View File

@ -1,278 +0,0 @@
#chg-compatible
$ unset SCM_SAMPLING_FILEPATH
$ LOGDIR=$TESTTMP/logs
$ mkdir $LOGDIR
$ configure dummyssh
$ enable remotenames
$ enable sampling
$ setconfig sampling.filepath=$LOGDIR/samplingpath.txt
$ setconfig sampling.key.accessedremotenames=remotenames
$ hg init remoterepo
$ hg clone -q ssh://user@dummy/remoterepo localrepo
$ mkcommit() {
> echo $1 > $1
> hg add $1
> hg ci -m "commit $1"
> }
script to verify sampling
$ cat > verifylast.py << EOF
> import json, re
> with open("$LOGDIR/samplingpath.txt") as f:
> data = f.read().strip("\0").split("\0")
> if data:
> entry = json.loads(data[-1])
> if entry["category"] == "remotenames":
> if entry["data"]["metrics_type"] == "accessedremotenames":
> metrics = "accessedremotenames_totalnum"
> print("%s : %s" % (metrics, entry["data"][metrics]))
> EOF
$ checkaccessedbookmarks() {
> local file=.hg/selectivepullaccessedbookmarks
> if [ -f $file ]; then
> sort -k 3 $file ; python $TESTTMP/verifylast.py
> else
> echo "No contents!"
> fi
> }
Setup remote repos
$ cd remoterepo
$ mkcommit BASE
$ BASE=$(hg log -r . -T{node})
$ mkcommit master
$ hg book master
$ cd ..
$ hg clone -q ssh://user@dummy/remoterepo secondremoterepo
$ cd secondremoterepo
$ hg up -q 206754acf7d8
$ mkcommit new_master
$ hg book master --force
$ hg up '.^' -q
$ mkcommit D
$ hg book D_bookmark
$ cd ../remoterepo
$ hg up $BASE -q
$ mkcommit A
$ hg book A_bookmark
$ hg up $BASE -q
$ mkcommit B
$ hg book B_bookmark
$ hg up $BASE -q
$ mkcommit C
$ hg book C_bookmark
Check used remote bookmarks tracking
$ cd ../localrepo
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ hg pull -q
$ hg book --list-subscriptions
default/A_bookmark 01c036b602a8
default/B_bookmark 5b252c992f6d
default/C_bookmark d91e2f962bff
default/master 206754acf7d8
('master' is accessed by changelog to de-fragment the "main branch")
$ checkaccessedbookmarks
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
accessedremotenames_totalnum : 1
$ hg pull -B master
pulling from ssh://user@dummy/remoterepo
no changes found
$ checkaccessedbookmarks
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
accessedremotenames_totalnum : 1
$ hg pull -B A_bookmark
pulling from ssh://user@dummy/remoterepo
no changes found
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
accessedremotenames_totalnum : 2
Check pulling unknown bookmark
$ hg pull -B unknown_book
pulling from ssh://user@dummy/remoterepo
abort: remote bookmark unknown_book not found!
[255]
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
accessedremotenames_totalnum : 2
Add second remote to the paths and update to the first master
$ cd ../localrepo
$ setglobalconfig paths.secondremote=ssh://user@dummy/secondremoterepo
$ hg pull secondremote -q
$ hg book --list-subscriptions
default/A_bookmark 01c036b602a8
default/B_bookmark 5b252c992f6d
default/C_bookmark d91e2f962bff
default/master 206754acf7d8
secondremote/D_bookmark a1b1b44a131d
secondremote/master a6b4ed81a38e
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
accessedremotenames_totalnum : 2
$ hg pull -B master secondremote
pulling from ssh://user@dummy/secondremoterepo
no changes found
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 3
Check pulling bookmark as a revset
$ hg pull -r C_bookmark
pulling from ssh://user@dummy/remoterepo
no changes found
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
d91e2f962bffb715a380162e945e6df13bf7aa3c bookmarks default/C_bookmark
206754acf7d8d6a9d471f64406dc10c55a13db13 bookmarks default/master
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 4
Check updating to the remote bookmark
$ rm .hg/selectivepullaccessedbookmarks
$ hg up default/A_bookmark
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
accessedremotenames_totalnum : 1
$ hg up secondremote/master
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 2
update to the hoisted name
$ hg up B_bookmark
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
5b252c992f6da5179f90eda723431f54e5a9a3f5 bookmarks default/B_bookmark
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 3
change hoist and update again
$ setconfig remotenames.hoist=secondremote
$ hg up A_bookmark
abort: unknown revision 'A_bookmark'!
[255]
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
5b252c992f6da5179f90eda723431f54e5a9a3f5 bookmarks default/B_bookmark
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 3
$ hg up master
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ checkaccessedbookmarks
01c036b602a86df67ef1a00e4b0266d23c8fafee bookmarks default/A_bookmark
5b252c992f6da5179f90eda723431f54e5a9a3f5 bookmarks default/B_bookmark
a6b4ed81a38e7d63d6b8ed66264a1fecd0ae90ef bookmarks secondremote/master
accessedremotenames_totalnum : 3
Check selective pull setup using accessed bookmarks
$ cd ../remoterepo
$ mkcommit new_C
$ hg log -G -T "'{desc}' {bookmarks} {remotenames}"
@ 'commit new_C' C_bookmark
o 'commit C'
o 'commit B' B_bookmark
o 'commit A' A_bookmark
o 'commit master' master
o 'commit BASE'
$ cd ../secondremoterepo
$ hg log -G -T "'{desc}' {bookmarks} {remotenames}"
@ 'commit D' D_bookmark
o 'commit new_master' master
o 'commit master' default/master
o 'commit BASE'
$ cd ../localrepo
$ setconfig remotenames.hoist=default
$ rm .hg/selectivepullaccessedbookmarks
$ hg up C_bookmark
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ checkaccessedbookmarks
d91e2f962bffb715a380162e945e6df13bf7aa3c bookmarks default/C_bookmark
accessedremotenames_totalnum : 1
$ hg book --list-subs
default/A_bookmark 01c036b602a8
default/B_bookmark 5b252c992f6d
default/C_bookmark d91e2f962bff
default/master 206754acf7d8
secondremote/D_bookmark a1b1b44a131d
secondremote/master a6b4ed81a38e
$ setconfig remotenames.selectivepull=True remotenames.selectivepulldefault=master
$ hg pull
pulling from ssh://user@dummy/remoterepo
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
$ hg book --list-subs
default/C_bookmark d65ac0c5f8c9
default/master 206754acf7d8
secondremote/D_bookmark a1b1b44a131d
secondremote/master a6b4ed81a38e
$ sort .hg/selectivepullenabled
default
pulling from the secondremote
$ hg pull secondremote
pulling from ssh://user@dummy/secondremoterepo
no changes found
$ hg book --list-subs
default/C_bookmark d65ac0c5f8c9
default/master 206754acf7d8
secondremote/master a6b4ed81a38e
$ sort .hg/selectivepullenabled
default
secondremote

View File

@ -8,7 +8,11 @@ Set up repos
$ cd remoterepo
$ setconfig treemanifest.server=True
$ cd ..
$ hg clone -q ssh://user@dummy/remoterepo localrepo
$ hg clone --config remotenames.selectivepull=True --config remotenames.selectivepulldefault=master -q ssh://user@dummy/remoterepo localrepo
$ cd localrepo
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepulldefault=master
$ cd ..
Pull master bookmark
@ -20,7 +24,6 @@ Pull master bookmark
$ cd ../localrepo
$ hg pull
pulling from ssh://user@dummy/remoterepo
requesting all changes
adding changesets
adding manifests
adding file changes
@ -28,11 +31,6 @@ Pull master bookmark
$ hg bookmarks --list-subscriptions
default/master 1449e7934ec1
Set up selective pull
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig remotenames.selectivepulldefault=master
Create another bookmark on the remote repo
$ cd ../remoterepo
$ hg up null
@ -189,31 +187,31 @@ Make another clone with selectivepull disabled
default/master 0238718db2b1
default/thirdbook 1449e7934ec1
Enable selectivepull and make a pull. Make sure only master bookmark is left
Enable selectivepull and make a pull. All the bookmarks remain.
This is expected. Enabling selectivepull for the existing repo
won't reduce the number of subscribed bookmarks.
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig remotenames.selectivepulldefault=master
$ hg pull -q
$ hg book --list-subscriptions
default/master 0238718db2b1
Temporarily disable selectivepull, pull, enable it again and pull again.
Make sure only master bookmark is present
$ hg pull --config remotenames.selectivepull=False -q
$ hg book --list-subscriptions
default/book-with-dashes 1449e7934ec1
default/master 0238718db2b1
default/thirdbook 1449e7934ec1
$ hg pull -q
Clean the repo and make a fresh clone with right configuration.
$ cd ..
$ rm -rf localrepo2
$ hg clone --config remotenames.selectivepull=True --config remotenames.selectivepulldefault=master -q ssh://user@dummy/remoterepo localrepo2
$ cd localrepo2
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepulldefault=master
$ hg pull
pulling from ssh://user@dummy/remoterepo
no changes found
$ hg book --list-subscriptions
default/master 0238718db2b1
Check that log shows the hint about selective pull
$ hg log -r thirdbook
abort: unknown revision 'thirdbook'!
[255]
By using "default/" the commit gets automatically pulled
$ hg log -r default/thirdbook
pulling 'thirdbook' from 'ssh://user@dummy/remoterepo'
@ -291,7 +289,6 @@ Clone remote repo with the selectivepull enabled
$ cd new_localrepo
$ setconfig remotenames.selectivepull=True
$ setconfig remotenames.selectivepullaccessedbookmarks=True
$ setconfig remotenames.selectivepulldefault=master
$ hg book --list-subscriptions

View File

@ -164,7 +164,6 @@ configure() {
enable remotenames
setconfig remotenames.selectivepull=True
setconfig remotenames.selectivepulldefault=master
setconfig remotenames.selectivepullaccessedbookmarks=True
;;
modern)
enable amend