comparison hgext/rebase.py @ 44239:830eae18b2f3

rebase: abort if the user tries to rebase the working copy I think it's more correct to treat `hg rebase -r 'wdir()' -d foo` as `hg co -m foo`, but I'm instead making it error out. That's partly because it's probably what the user wanted (in the case I heard from a user, they had done `hg rebase -s f` where `f` resolved to `wdir()`) and partly because I don't want to think about more complicated cases where the user specifies the working copy together with other commits. Differential Revision: https://phab.mercurial-scm.org/D8057
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 31 Jan 2020 10:53:50 -0800
parents 3d2de64c49d2
children f546d2170b0f
comparison
equal deleted inserted replaced
44238:6e4ff6a766c2 44239:830eae18b2f3
35 error, 35 error,
36 extensions, 36 extensions,
37 hg, 37 hg,
38 merge as mergemod, 38 merge as mergemod,
39 mergeutil, 39 mergeutil,
40 node as nodemod,
40 obsolete, 41 obsolete,
41 obsutil, 42 obsutil,
42 patch, 43 patch,
43 phases, 44 phases,
44 pycompat, 45 pycompat,
1263 elif srcf: 1264 elif srcf:
1264 src = scmutil.revrange(repo, [srcf]) 1265 src = scmutil.revrange(repo, [srcf])
1265 if not src: 1266 if not src:
1266 ui.status(_(b'empty "source" revision set - nothing to rebase\n')) 1267 ui.status(_(b'empty "source" revision set - nothing to rebase\n'))
1267 return None 1268 return None
1268 rebaseset = repo.revs(b'(%ld)::', src) 1269 rebaseset = repo.revs(b'(%ld)::', src) or src
1269 assert rebaseset
1270 else: 1270 else:
1271 base = scmutil.revrange(repo, [basef or b'.']) 1271 base = scmutil.revrange(repo, [basef or b'.'])
1272 if not base: 1272 if not base:
1273 ui.status( 1273 ui.status(
1274 _(b'empty "base" revision set - ' b"can't compute rebase set\n") 1274 _(b'empty "base" revision set - ' b"can't compute rebase set\n")
1339 _(b'nothing to rebase from %s to %s\n') 1339 _(b'nothing to rebase from %s to %s\n')
1340 % (b'+'.join(bytes(repo[r]) for r in base), dest) 1340 % (b'+'.join(bytes(repo[r]) for r in base), dest)
1341 ) 1341 )
1342 return None 1342 return None
1343 1343
1344 if nodemod.wdirrev in rebaseset:
1345 raise error.Abort(_(b'cannot rebase the working copy'))
1344 rebasingwcp = repo[b'.'].rev() in rebaseset 1346 rebasingwcp = repo[b'.'].rev() in rebaseset
1345 ui.log( 1347 ui.log(
1346 b"rebase", 1348 b"rebase",
1347 b"rebasing working copy parent: %r\n", 1349 b"rebasing working copy parent: %r\n",
1348 rebasingwcp, 1350 rebasingwcp,