mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
remotenames: move a few methods to core
Summary: They will be used in core later. Reviewed By: markbt Differential Revision: D25562093 fbshipit-source-id: 4402a629a09920fd4c6f85cb8e777446bb218a37
This commit is contained in:
parent
2b1ae681ca
commit
35094bad4e
@ -63,6 +63,8 @@ from edenscm.mercurial.bookmarks import (
|
||||
_selectivepullenabledfilelock,
|
||||
_trackaccessedbookmarks,
|
||||
_writesingleremotename,
|
||||
_enableselectivepullforremote,
|
||||
_disableselectivepull,
|
||||
joinremotename,
|
||||
journalremotebookmarktype,
|
||||
readremotenames,
|
||||
@ -172,41 +174,6 @@ def _isselectivepull(ui):
|
||||
return ui.configbool("remotenames", "selectivepull")
|
||||
|
||||
|
||||
def _readisselectivepullenabledfile(repo):
|
||||
try:
|
||||
with repo.sharedvfs(_selectivepullenabledfile, "rb") as f:
|
||||
for line in f:
|
||||
yield pycompat.decodeutf8(line.strip())
|
||||
except EnvironmentError as er:
|
||||
if er.errno != errno.ENOENT:
|
||||
raise
|
||||
return
|
||||
|
||||
|
||||
def _isselectivepullenabledforremote(repo, remote):
|
||||
for enabledremote in _readisselectivepullenabledfile(repo):
|
||||
if enabledremote == remote:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _enableselectivepullforremote(repo, remote):
|
||||
vfs = repo.sharedvfs
|
||||
with lockmod.lock(vfs, _selectivepullenabledfilelock):
|
||||
enabledremotes = set(_readisselectivepullenabledfile(repo))
|
||||
enabledremotes.add(remote)
|
||||
with vfs(_selectivepullenabledfile, "wb", atomictemp=True) as f:
|
||||
for renabled in enabledremotes:
|
||||
f.write(pycompat.encodeutf8("%s\n" % renabled))
|
||||
|
||||
|
||||
def _disableselectivepull(repo):
|
||||
vfs = repo.sharedvfs
|
||||
if vfs.exists(_selectivepullenabledfile):
|
||||
with lockmod.lock(vfs, _selectivepullenabledfilelock):
|
||||
vfs.unlink(_selectivepullenabledfile)
|
||||
|
||||
|
||||
def _listremotebookmarks(remote, bookmarks):
|
||||
remotebookmarks = remote.listkeys("bookmarks")
|
||||
result = {}
|
||||
|
@ -1463,3 +1463,38 @@ def updateaccessedbookmarks(repo, remotepath, bookmarks):
|
||||
|
||||
# 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:
|
||||
for line in f:
|
||||
yield pycompat.decodeutf8(line.strip())
|
||||
except EnvironmentError as er:
|
||||
if er.errno != errno.ENOENT:
|
||||
raise
|
||||
return
|
||||
|
||||
|
||||
def _isselectivepullenabledforremote(repo, remote):
|
||||
for enabledremote in _readisselectivepullenabledfile(repo):
|
||||
if enabledremote == remote:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _enableselectivepullforremote(repo, remote):
|
||||
vfs = repo.sharedvfs
|
||||
with lockmod.lock(vfs, _selectivepullenabledfilelock):
|
||||
enabledremotes = set(_readisselectivepullenabledfile(repo))
|
||||
enabledremotes.add(remote)
|
||||
with vfs(_selectivepullenabledfile, "wb", atomictemp=True) as f:
|
||||
for renabled in enabledremotes:
|
||||
f.write(pycompat.encodeutf8("%s\n" % renabled))
|
||||
|
||||
|
||||
def _disableselectivepull(repo):
|
||||
vfs = repo.sharedvfs
|
||||
if vfs.exists(_selectivepullenabledfile):
|
||||
with lockmod.lock(vfs, _selectivepullenabledfilelock):
|
||||
vfs.unlink(_selectivepullenabledfile)
|
||||
|
Loading…
Reference in New Issue
Block a user