mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
remotenames: make remotenames pass check-code
Summary: remotenames.py had some issues with the new check-code from core. This patch fixes the issues and will make it easier to move remotenames to core if we want to.
This commit is contained in:
parent
fc550bd9da
commit
573148d9a5
@ -133,7 +133,7 @@ def exclone(orig, ui, *args, **opts):
|
|||||||
try:
|
try:
|
||||||
vfs = shareawarevfs(repo)
|
vfs = shareawarevfs(repo)
|
||||||
vfs.unlink('bookmarks')
|
vfs.unlink('bookmarks')
|
||||||
except OSError, inst:
|
except OSError as inst:
|
||||||
if inst.errno != errno.ENOENT:
|
if inst.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
@ -182,7 +182,7 @@ def updatecmd(orig, ui, repo, node=None, rev=None, **kwargs):
|
|||||||
if book:
|
if book:
|
||||||
del kwargs['bookmark']
|
del kwargs['bookmark']
|
||||||
if book in repo._bookmarks:
|
if book in repo._bookmarks:
|
||||||
raise util.Abort("bookmark '%s' already exists" % book)
|
raise error.Abort("bookmark '%s' already exists" % book)
|
||||||
ret = orig(ui, repo, node=node, rev=rev, **kwargs)
|
ret = orig(ui, repo, node=node, rev=rev, **kwargs)
|
||||||
commands.bookmark(ui, repo, book)
|
commands.bookmark(ui, repo, book)
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ def expushdiscoverybookmarks(pushop):
|
|||||||
|
|
||||||
if pushop.delete:
|
if pushop.delete:
|
||||||
if pushop.delete not in remotemarks:
|
if pushop.delete not in remotemarks:
|
||||||
raise util.Abort(_('remote bookmark %s does not exist') %
|
raise error.Abort(_('remote bookmark %s does not exist') %
|
||||||
pushop.delete)
|
pushop.delete)
|
||||||
pushop.outbookmarks.append([pushop.delete, remotemarks[pushop.delete],
|
pushop.outbookmarks.append([pushop.delete, remotemarks[pushop.delete],
|
||||||
''])
|
''])
|
||||||
@ -646,7 +646,7 @@ def expushdiscoverybookmarks(pushop):
|
|||||||
if anonheads:
|
if anonheads:
|
||||||
msg = _("push would create new anonymous heads (%s)")
|
msg = _("push would create new anonymous heads (%s)")
|
||||||
hint = _("use --allow-anon to override this warning")
|
hint = _("use --allow-anon to override this warning")
|
||||||
raise util.Abort(msg % ', '.join(sorted(anonheads)), hint=hint)
|
raise error.Abort(msg % ', '.join(sorted(anonheads)), hint=hint)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
bookmark = pushop.bookmarks[0]
|
bookmark = pushop.bookmarks[0]
|
||||||
@ -659,7 +659,7 @@ def expushdiscoverybookmarks(pushop):
|
|||||||
elif not pushop.create:
|
elif not pushop.create:
|
||||||
msg = _('not creating new remote bookmark')
|
msg = _('not creating new remote bookmark')
|
||||||
hint = _('use --create to create a new bookmark')
|
hint = _('use --create to create a new bookmark')
|
||||||
raise util.Abort(msg, hint=hint)
|
raise error.Abort(msg, hint=hint)
|
||||||
|
|
||||||
# allow non-fg bookmark move only if --non-forward-move is specified
|
# allow non-fg bookmark move only if --non-forward-move is specified
|
||||||
if not pushop.nonforwardmove and old != '':
|
if not pushop.nonforwardmove and old != '':
|
||||||
@ -668,12 +668,12 @@ def expushdiscoverybookmarks(pushop):
|
|||||||
if old not in repo:
|
if old not in repo:
|
||||||
msg = _('remote bookmark revision is not in local repo')
|
msg = _('remote bookmark revision is not in local repo')
|
||||||
hint = _('pull and merge or rebase or use --non-forward-move')
|
hint = _('pull and merge or rebase or use --non-forward-move')
|
||||||
raise util.Abort(msg, hint=hint)
|
raise error.Abort(msg, hint=hint)
|
||||||
foreground = obsolete.foreground(repo, [repo.lookup(old)])
|
foreground = obsolete.foreground(repo, [repo.lookup(old)])
|
||||||
if repo[rev].node() not in foreground:
|
if repo[rev].node() not in foreground:
|
||||||
msg = _('pushed rev is not in the foreground of remote bookmark')
|
msg = _('pushed rev is not in the foreground of remote bookmark')
|
||||||
hint = _('use --non-forward-move flag to complete arbitrary moves')
|
hint = _('use --non-forward-move flag to complete arbitrary moves')
|
||||||
raise util.Abort(msg, hint=hint)
|
raise error.Abort(msg, hint=hint)
|
||||||
if repo[old] == repo[rev]:
|
if repo[old] == repo[rev]:
|
||||||
repo.ui.status(_('remote bookmark already points at pushed rev\n'))
|
repo.ui.status(_('remote bookmark already points at pushed rev\n'))
|
||||||
return
|
return
|
||||||
@ -696,7 +696,7 @@ def expullcmd(orig, ui, repo, source="default", **opts):
|
|||||||
source = revrenames.get(source, source)
|
source = revrenames.get(source, source)
|
||||||
|
|
||||||
if opts.get('update') and opts.get('rebase'):
|
if opts.get('update') and opts.get('rebase'):
|
||||||
raise util.Abort(_('specify either rebase or update, not both'))
|
raise error.Abort(_('specify either rebase or update, not both'))
|
||||||
|
|
||||||
if not opts.get('rebase'):
|
if not opts.get('rebase'):
|
||||||
return orig(ui, repo, source, **opts)
|
return orig(ui, repo, source, **opts)
|
||||||
@ -752,7 +752,7 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
|
|||||||
if flag:
|
if flag:
|
||||||
msg = _('do not specify --delete and '
|
msg = _('do not specify --delete and '
|
||||||
'--%s at the same time') % flag
|
'--%s at the same time') % flag
|
||||||
raise util.Abort(msg)
|
raise error.Abort(msg)
|
||||||
# we want to skip pushing any changesets while deleting a remote
|
# we want to skip pushing any changesets while deleting a remote
|
||||||
# bookmark, so we send the null revision
|
# bookmark, so we send the null revision
|
||||||
opts['rev'] = ['null']
|
opts['rev'] = ['null']
|
||||||
@ -798,7 +798,7 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
|
|||||||
if ui.configbool('remotenames', 'forceto', False):
|
if ui.configbool('remotenames', 'forceto', False):
|
||||||
msg = _('must specify --to when pushing')
|
msg = _('must specify --to when pushing')
|
||||||
hint = _('see configuration option %s') % 'remotenames.forceto'
|
hint = _('see configuration option %s') % 'remotenames.forceto'
|
||||||
raise util.Abort(msg, hint=hint)
|
raise error.Abort(msg, hint=hint)
|
||||||
|
|
||||||
if not revs:
|
if not revs:
|
||||||
opts['rev'] = _pushrevs(repo, ui, None)
|
opts['rev'] = _pushrevs(repo, ui, None)
|
||||||
@ -807,10 +807,10 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
|
|||||||
|
|
||||||
if opts.get('bookmark'):
|
if opts.get('bookmark'):
|
||||||
msg = _('do not specify --to/-t and --bookmark/-B at the same time')
|
msg = _('do not specify --to/-t and --bookmark/-B at the same time')
|
||||||
raise util.Abort(msg)
|
raise error.Abort(msg)
|
||||||
if opts.get('branch'):
|
if opts.get('branch'):
|
||||||
msg = _('do not specify --to/-t and --branch/-b at the same time')
|
msg = _('do not specify --to/-t and --branch/-b at the same time')
|
||||||
raise util.Abort(msg)
|
raise error.Abort(msg)
|
||||||
|
|
||||||
if revs:
|
if revs:
|
||||||
revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
|
revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
|
||||||
@ -819,7 +819,7 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
|
|||||||
if len(revs) != 1:
|
if len(revs) != 1:
|
||||||
msg = _('--to requires exactly one rev to push')
|
msg = _('--to requires exactly one rev to push')
|
||||||
hint = _('use --rev BOOKMARK or omit --rev for current commit (.)')
|
hint = _('use --rev BOOKMARK or omit --rev for current commit (.)')
|
||||||
raise util.Abort(msg, hint=hint)
|
raise error.Abort(msg, hint=hint)
|
||||||
rev = revs[0]
|
rev = revs[0]
|
||||||
|
|
||||||
# big can o' copypasta from commands.push
|
# big can o' copypasta from commands.push
|
||||||
@ -830,7 +830,7 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
|
|||||||
except error.RepoError:
|
except error.RepoError:
|
||||||
if dest == "default-push":
|
if dest == "default-push":
|
||||||
hint = _('see the "path" section in "hg help config"')
|
hint = _('see the "path" section in "hg help config"')
|
||||||
raise util.Abort(_("default repository not configured!"),
|
raise error.Abort(_("default repository not configured!"),
|
||||||
hint=hint)
|
hint=hint)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -958,19 +958,19 @@ def exbookmarks(orig, ui, repo, *args, **opts):
|
|||||||
for name in args:
|
for name in args:
|
||||||
if name in disallowed:
|
if name in disallowed:
|
||||||
msg = _("bookmark '%s' not allowed by configuration")
|
msg = _("bookmark '%s' not allowed by configuration")
|
||||||
raise util.Abort(msg % name)
|
raise error.Abort(msg % name)
|
||||||
|
|
||||||
if untrack:
|
if untrack:
|
||||||
if track:
|
if track:
|
||||||
msg = _('do not specify --untrack and --track at the same time')
|
msg = _('do not specify --untrack and --track at the same time')
|
||||||
raise util.Abort(msg)
|
raise error.Abort(msg)
|
||||||
_removetracking(repo, args)
|
_removetracking(repo, args)
|
||||||
return
|
return
|
||||||
|
|
||||||
if delete or rename or args or inactive:
|
if delete or rename or args or inactive:
|
||||||
if delete and track:
|
if delete and track:
|
||||||
msg = _('do not specifiy --track and --delete at the same time')
|
msg = _('do not specifiy --track and --delete at the same time')
|
||||||
raise util.Abort(msg)
|
raise error.Abort(msg)
|
||||||
|
|
||||||
ret = orig(ui, repo, *args, **opts)
|
ret = orig(ui, repo, *args, **opts)
|
||||||
|
|
||||||
@ -1268,14 +1268,18 @@ def transition(repo, ui):
|
|||||||
if message:
|
if message:
|
||||||
ui.warn(message + '\n')
|
ui.warn(message + '\n')
|
||||||
|
|
||||||
def saveremotenames(repo, remotepath, branches={}, bookmarks={}):
|
def saveremotenames(repo, remotepath, branches=None, bookmarks=None):
|
||||||
vfs = shareawarevfs(repo)
|
vfs = shareawarevfs(repo)
|
||||||
wlock = repo.wlock()
|
wlock = repo.wlock()
|
||||||
|
if branches is None:
|
||||||
|
branches = {}
|
||||||
|
if bookmarks is None:
|
||||||
|
bookmarks = {}
|
||||||
try:
|
try:
|
||||||
# delete old files
|
# delete old files
|
||||||
try:
|
try:
|
||||||
vfs.unlink('remotedistance')
|
vfs.unlink('remotedistance')
|
||||||
except OSError, inst:
|
except OSError as inst:
|
||||||
if inst.errno != errno.ENOENT:
|
if inst.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -1371,12 +1375,12 @@ def invalidatedistancecache(repo):
|
|||||||
shutil.rmtree(vfs.join('cache/distance'))
|
shutil.rmtree(vfs.join('cache/distance'))
|
||||||
else:
|
else:
|
||||||
vfs.unlink('cache/distance')
|
vfs.unlink('cache/distance')
|
||||||
except (OSError, IOError), inst:
|
except (OSError, IOError) as inst:
|
||||||
if inst.errno != errno.ENOENT:
|
if inst.errno != errno.ENOENT:
|
||||||
error = True
|
error = True
|
||||||
try:
|
try:
|
||||||
vfs.unlink('cache/distance.current')
|
vfs.unlink('cache/distance.current')
|
||||||
except (OSError, IOError), inst:
|
except (OSError, IOError) as inst:
|
||||||
if inst.errno != errno.ENOENT:
|
if inst.errno != errno.ENOENT:
|
||||||
error = True
|
error = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user