2014-07-23 20:47:35 +04:00
|
|
|
# tweakdefaults.py
|
|
|
|
#
|
|
|
|
# Copyright 2013 Facebook, Inc.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
2014-09-19 04:22:14 +04:00
|
|
|
from mercurial import util, cmdutil, commands, hg, scmutil
|
2014-07-23 20:47:35 +04:00
|
|
|
from mercurial import bookmarks
|
|
|
|
from mercurial.extensions import wrapcommand
|
|
|
|
from mercurial.i18n import _
|
|
|
|
from hgext import rebase
|
|
|
|
import errno, os
|
|
|
|
|
|
|
|
cmdtable = {}
|
|
|
|
command = cmdutil.command(cmdtable)
|
|
|
|
testedwith = 'internal'
|
|
|
|
|
2014-08-19 22:21:45 +04:00
|
|
|
def update(orig, ui, repo, node=None, rev=None, **kwargs):
|
2014-07-23 20:47:35 +04:00
|
|
|
# 'hg update' should do nothing
|
2014-08-19 22:21:45 +04:00
|
|
|
if not node and not rev:
|
2014-09-08 23:43:38 +04:00
|
|
|
raise util.Abort(
|
|
|
|
'you must specify a destination to update to',
|
|
|
|
hint="if you're trying to move a bookmark forward, try " +
|
|
|
|
"'hg rebase -d <destination>'")
|
2014-07-23 20:47:35 +04:00
|
|
|
|
2014-09-03 19:46:45 +04:00
|
|
|
return orig(ui, repo, node=node, rev=rev, **kwargs)
|
2014-07-23 20:47:35 +04:00
|
|
|
wrapcommand(commands.table, 'update', update)
|
|
|
|
|
|
|
|
def _rebase(orig, ui, repo, **opts):
|
2014-08-19 01:27:37 +04:00
|
|
|
if opts.get('continue') or opts.get('abort'):
|
|
|
|
return orig(ui, repo, **opts)
|
|
|
|
|
2014-07-23 20:47:35 +04:00
|
|
|
# 'hg rebase' w/o args should do nothing
|
|
|
|
if not opts.get('dest'):
|
|
|
|
raise util.Abort("you must specify a destination (-d) for the rebase")
|
|
|
|
|
2014-09-19 04:22:14 +04:00
|
|
|
# 'hg rebase' can fast-forward bookmark
|
|
|
|
prev = repo['.']
|
|
|
|
dest = scmutil.revsingle(repo, opts.get('dest'))
|
2014-07-23 20:47:35 +04:00
|
|
|
|
2014-09-19 04:22:14 +04:00
|
|
|
# Only fast-forward the bookmark if no source nodes were explicitly
|
|
|
|
# specified.
|
|
|
|
if not (opts.get('base') or opts.get('source') or opts.get('rev')):
|
|
|
|
common = dest.ancestor(prev)
|
2014-07-23 20:47:35 +04:00
|
|
|
if prev == common:
|
2014-09-19 04:22:14 +04:00
|
|
|
result = hg.update(repo, dest.node())
|
2014-07-23 20:47:35 +04:00
|
|
|
if repo._bookmarkcurrent:
|
2014-09-19 04:22:14 +04:00
|
|
|
bookmarks.update(repo, [prev.node()], dest.node())
|
2014-07-23 20:47:35 +04:00
|
|
|
return result
|
|
|
|
|
|
|
|
return orig(ui, repo, **opts)
|
|
|
|
wrapcommand(rebase.cmdtable, 'rebase', _rebase)
|
|
|
|
|
|
|
|
logopts = [
|
|
|
|
('', 'all', None, _('shows all commits in the repo')),
|
|
|
|
]
|
|
|
|
|
|
|
|
def log(orig, ui, repo, *pats, **opts):
|
|
|
|
# 'hg log' defaults to -f
|
|
|
|
# All special uses of log (--date, --branch, etc) will also now do follow.
|
|
|
|
if not opts.get('rev') and not opts.get('all'):
|
|
|
|
opts['follow'] = True
|
|
|
|
|
|
|
|
return orig(ui, repo, *pats, **opts)
|
|
|
|
|
|
|
|
entry = wrapcommand(commands.table, 'log', log)
|
|
|
|
for opt in logopts:
|
|
|
|
opt = (opt[0], opt[1], opt[2], opt[3])
|
|
|
|
entry[1].append(opt)
|