2014-11-08 03:27:47 +03:00
|
|
|
# pushrebase.py - server-side rebasing of pushed commits
|
|
|
|
#
|
|
|
|
# Copyright 2014 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.
|
|
|
|
|
2015-10-18 04:59:46 +03:00
|
|
|
import errno, os, tempfile, sys, operator, resource, collections, time
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
try:
|
|
|
|
import json
|
|
|
|
except ImportError:
|
|
|
|
import simplejson as json
|
|
|
|
|
|
|
|
from mercurial import bundle2, cmdutil, hg, scmutil, exchange, commands
|
|
|
|
from mercurial import util, error, discovery, changegroup, context, revset
|
2015-06-26 21:05:46 +03:00
|
|
|
from mercurial import obsolete, pushkey, phases, extensions
|
2015-09-29 04:42:18 +03:00
|
|
|
from mercurial import bookmarks, lock as lockmod
|
2015-09-30 07:32:02 +03:00
|
|
|
from mercurial.extensions import wrapcommand, wrapfunction
|
2014-11-08 03:27:47 +03:00
|
|
|
from mercurial.bundlerepo import bundlerepository
|
2014-11-19 03:36:46 +03:00
|
|
|
from mercurial.node import nullid, hex, bin
|
2014-11-08 03:27:47 +03:00
|
|
|
from mercurial.i18n import _
|
|
|
|
|
2015-06-13 02:36:51 +03:00
|
|
|
testedwith = '3.4'
|
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
cmdtable = {}
|
|
|
|
command = cmdutil.command(cmdtable)
|
|
|
|
|
|
|
|
rebaseparttype = 'b2x:rebase'
|
2014-12-05 22:40:14 +03:00
|
|
|
commonheadsparttype = 'b2x:commonheads'
|
2014-11-19 03:36:46 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
experimental = 'experimental'
|
|
|
|
configonto = 'server-rebase-onto'
|
|
|
|
|
2015-07-07 03:01:25 +03:00
|
|
|
def uisetup(ui):
|
2015-06-26 21:05:46 +03:00
|
|
|
# remotenames circumvents the default push implementation entirely, so make
|
2015-07-07 03:01:25 +03:00
|
|
|
# sure we load after it so that we wrap it.
|
2015-09-30 07:32:02 +03:00
|
|
|
order = extensions._order
|
|
|
|
order.remove('pushrebase')
|
|
|
|
order.append('pushrebase')
|
|
|
|
extensions._order = order
|
2015-07-07 03:01:25 +03:00
|
|
|
|
|
|
|
def extsetup(ui):
|
|
|
|
entry = wrapcommand(commands.table, 'push', _push)
|
|
|
|
try:
|
|
|
|
# Don't add the 'to' arg if it already exists
|
|
|
|
extensions.find('remotenames')
|
|
|
|
except KeyError:
|
|
|
|
entry[1].append(('', 'to', '', _('server revision to rebase onto')))
|
2014-11-08 03:27:47 +03:00
|
|
|
|
2014-12-09 03:39:20 +03:00
|
|
|
partorder = exchange.b2partsgenorder
|
|
|
|
partorder.insert(partorder.index('changeset'),
|
|
|
|
partorder.pop(partorder.index(rebaseparttype)))
|
|
|
|
|
|
|
|
partorder.insert(0, partorder.pop(partorder.index(commonheadsparttype)))
|
2014-12-05 22:40:14 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
wrapfunction(discovery, 'checkheads', _checkheads)
|
2015-09-28 01:45:31 +03:00
|
|
|
# we want to disable the heads check because in pushrebase repos, we
|
|
|
|
# expect the heads to change during the push and we should not abort.
|
|
|
|
|
|
|
|
# The check heads functions are used to verify that the heads haven't
|
|
|
|
# changed since the client did the initial discovery. Pushrebase is meant
|
|
|
|
# to allow concurrent pushes, so the heads may have very well changed.
|
|
|
|
# So let's not do this check.
|
2015-09-08 04:26:53 +03:00
|
|
|
wrapfunction(exchange, 'check_heads', _exchangecheckheads)
|
2015-10-01 21:15:37 +03:00
|
|
|
wrapfunction(exchange, '_pushb2ctxcheckheads', _skipcheckheads)
|
2014-11-08 03:27:47 +03:00
|
|
|
|
2015-04-17 23:49:35 +03:00
|
|
|
origpushkeyhandler = bundle2.parthandlermapping['pushkey']
|
2014-11-08 03:27:47 +03:00
|
|
|
newpushkeyhandler = lambda *args, **kwargs: \
|
|
|
|
bundle2pushkey(origpushkeyhandler, *args, **kwargs)
|
|
|
|
newpushkeyhandler.params = origpushkeyhandler.params
|
2015-04-17 23:49:35 +03:00
|
|
|
bundle2.parthandlermapping['pushkey'] = newpushkeyhandler
|
2014-11-08 03:27:47 +03:00
|
|
|
bundle2.parthandlermapping['b2x:pushkey'] = newpushkeyhandler
|
|
|
|
|
2015-09-28 21:31:24 +03:00
|
|
|
wrapfunction(exchange, 'unbundle', unbundle)
|
|
|
|
|
2015-10-06 04:56:46 +03:00
|
|
|
wrapfunction(hg, '_peerorrepo', _peerorrepo)
|
|
|
|
|
|
|
|
def _peerorrepo(orig, ui, path, create=False):
|
|
|
|
# Force hooks to use a bundle repo
|
|
|
|
bundlepath = os.environ.get("HG_HOOK_BUNDLEPATH")
|
|
|
|
if bundlepath:
|
|
|
|
return orig(ui, bundlepath, create=create)
|
|
|
|
return orig(ui, path, create)
|
|
|
|
|
2015-09-28 21:31:24 +03:00
|
|
|
def unbundle(orig, repo, cg, heads, source, url):
|
|
|
|
# Preload the manifests that the client says we'll need. This happens
|
|
|
|
# outside the lock, thus cutting down on our lock time and increasing commit
|
|
|
|
# throughput.
|
|
|
|
if util.safehasattr(cg, 'params'):
|
|
|
|
preloadmfs = cg.params.get('preloadmanifests')
|
|
|
|
if preloadmfs:
|
|
|
|
for mfnode in preloadmfs.split(','):
|
|
|
|
repo.manifest.read(bin(mfnode))
|
|
|
|
|
|
|
|
return orig(repo, cg, heads, source, url)
|
|
|
|
|
2014-12-05 22:02:01 +03:00
|
|
|
def validaterevset(repo, revset):
|
|
|
|
"Abort if this is a rebasable revset, return None otherwise"
|
2014-11-08 03:27:47 +03:00
|
|
|
if not repo.revs(revset):
|
|
|
|
raise util.Abort(_('nothing to rebase'))
|
|
|
|
|
pushrebase: cleanup phase handling
Summary:
It turns out that bundlerepo uses the underlying phase boundaries, so the
added changesets show up with the same phase as their nearest ancestor that's
already in the repository. This behavior is confusing and inconsistent with
what happens when the bundle is actually applied: retracting the draft boundary
over the new commits.
This makes a copy of the phase cache so that changes in the bundlerepo don't
affect the real one and then retracts the draft boundary like would happen
when the bundle is applied normally.
If this general solution looks OK, I'll submit an upstream patch that makes
bundlerepo behave this way always, which will make it match the behavior that
would be seen when using ##hg unbundle##.
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1733166
Signature: t1:1733166:1420502423:f57e2fff8fe47293ecab1ac4f6efdd0507c9c7b5
2015-01-06 02:50:59 +03:00
|
|
|
if repo.revs('%r and public()', revset):
|
|
|
|
raise util.Abort(_('cannot rebase public changesets'))
|
|
|
|
|
pushrebase: disallow pushing obsolete commits
Summary:
@durin42 suggested that the extension might want to prevent processing of
obsolete commits. Given the current state of dealing with conflicting
obsolescence markers, this seems like a good idea.
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1740886
Signature: t1:1740886:1418686275:d505ff1de8fbce39eb4fbe3a2e6d368b4b14edb8
2014-12-16 02:06:57 +03:00
|
|
|
if repo.revs('%r and obsolete()', revset):
|
|
|
|
raise util.Abort(_('cannot rebase obsolete changesets'))
|
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
heads = repo.revs('heads(%r)', revset)
|
|
|
|
if len(heads) > 1:
|
|
|
|
raise util.Abort(_('cannot rebase divergent changesets'))
|
|
|
|
|
2015-07-29 23:32:51 +03:00
|
|
|
repo.ui.note(_('validated revset for rebase\n'))
|
2014-12-05 22:02:01 +03:00
|
|
|
|
2015-10-29 04:19:12 +03:00
|
|
|
def getrebasepart(repo, peer, outgoing, onto, newhead, force):
|
2014-11-08 03:27:47 +03:00
|
|
|
if not outgoing.missing:
|
|
|
|
raise util.Abort(_('no commits to rebase'))
|
2015-04-03 21:38:55 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
if rebaseparttype not in bundle2.bundle2caps(peer):
|
|
|
|
raise util.Abort(_('no server support for %r') % rebaseparttype)
|
|
|
|
|
2014-12-05 22:02:01 +03:00
|
|
|
validaterevset(repo, revset.formatspec('%ln', outgoing.missing))
|
2014-11-08 03:27:47 +03:00
|
|
|
|
2014-12-09 03:39:20 +03:00
|
|
|
cg = changegroup.getlocalchangegroupraw(repo, 'push', outgoing)
|
|
|
|
|
|
|
|
# .upper() marks this as a mandatory part: server will abort if there's no
|
|
|
|
# handler
|
2015-10-29 04:19:12 +03:00
|
|
|
return bundle2.bundlepart(
|
|
|
|
rebaseparttype.upper(),
|
|
|
|
mandatoryparams={
|
|
|
|
'onto': onto,
|
|
|
|
'newhead': repr(newhead),
|
|
|
|
'force': 'True' if force else 'False',
|
|
|
|
}.items(),
|
|
|
|
data = cg)
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
def _checkheads(orig, repo, remote, *args, **kwargs):
|
|
|
|
onto = repo.ui.config(experimental, configonto)
|
|
|
|
if onto: # This is a rebasing push
|
|
|
|
# The rest of the checks are performed during bundle2 part processing;
|
|
|
|
# we need to bypass the regular push checks because it will look like
|
|
|
|
# we're pushing a new head, which isn't normally allowed
|
|
|
|
if not repo.ui.configbool('experimental', 'bundle2-exp', False):
|
|
|
|
raise util.Abort(_('bundle2 needs to be enabled on client'))
|
|
|
|
if not remote.capable('bundle2-exp'):
|
|
|
|
raise util.Abort(_('bundle2 needs to be enabled on server'))
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
return orig(repo, remote, *args, **kwargs)
|
2015-04-03 21:38:55 +03:00
|
|
|
|
2015-09-08 04:26:53 +03:00
|
|
|
def _exchangecheckheads(orig, repo, *args, **kwargs):
|
|
|
|
onto = repo.ui.config(experimental, configonto)
|
|
|
|
if not onto:
|
|
|
|
# Only do this work if it's not a rebasing push
|
|
|
|
return orig(repo, *args, **kwargs)
|
|
|
|
|
2015-10-01 21:15:37 +03:00
|
|
|
def _skipcheckheads(orig, pushop, bundler):
|
|
|
|
if not pushop.ui.config(experimental, configonto): # no check if we rebase
|
|
|
|
return orig(pushop, bundler)
|
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
def _push(orig, ui, repo, *args, **opts):
|
2014-11-19 03:36:46 +03:00
|
|
|
oldonto = ui.backupconfig(experimental, configonto)
|
2015-06-26 21:05:46 +03:00
|
|
|
oldremotenames = ui.backupconfig('remotenames', 'allownonfastforward')
|
pushrebase: (easy) fix traditional push
Summary: Been working with js too long; python vars aren't None by default
Test Plan: ##run-tests.py##, and doing a traditional push w/ the extension enabled
Reviewers: durham, sid0, pyd
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1743710
2014-12-17 01:27:21 +03:00
|
|
|
oldphasemove = None
|
|
|
|
|
|
|
|
try:
|
2015-06-26 21:05:46 +03:00
|
|
|
ui.setconfig(experimental, configonto, opts.get('to'), '--to')
|
pushrebase: (easy) fix traditional push
Summary: Been working with js too long; python vars aren't None by default
Test Plan: ##run-tests.py##, and doing a traditional push w/ the extension enabled
Reviewers: durham, sid0, pyd
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1743710
2014-12-17 01:27:21 +03:00
|
|
|
if ui.config(experimental, configonto):
|
|
|
|
ui.setconfig(experimental, 'bundle2.pushback', True)
|
|
|
|
oldphasemove = wrapfunction(exchange, '_localphasemove', _phasemove)
|
2015-06-26 21:05:46 +03:00
|
|
|
ui.setconfig('remotenames', 'allownonfastforward', True)
|
pushrebase: (easy) fix traditional push
Summary: Been working with js too long; python vars aren't None by default
Test Plan: ##run-tests.py##, and doing a traditional push w/ the extension enabled
Reviewers: durham, sid0, pyd
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1743710
2014-12-17 01:27:21 +03:00
|
|
|
result = orig(ui, repo, *args, **opts)
|
|
|
|
finally:
|
|
|
|
ui.restoreconfig(oldonto)
|
2015-06-26 21:05:46 +03:00
|
|
|
ui.restoreconfig(oldremotenames)
|
pushrebase: (easy) fix traditional push
Summary: Been working with js too long; python vars aren't None by default
Test Plan: ##run-tests.py##, and doing a traditional push w/ the extension enabled
Reviewers: durham, sid0, pyd
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1743710
2014-12-17 01:27:21 +03:00
|
|
|
if oldphasemove:
|
|
|
|
exchange._localphasemove = oldphasemove
|
2014-11-19 03:36:46 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
return result
|
|
|
|
|
2014-11-19 03:36:46 +03:00
|
|
|
def _phasemove(orig, pushop, nodes, phase=phases.public):
|
|
|
|
"""prevent commits from being marked public
|
|
|
|
|
|
|
|
Since these are going to be mutated on the server, they aren't really being
|
|
|
|
published, their successors are. If we mark these as public now, hg evolve
|
|
|
|
will refuse to fix them for us later."""
|
2015-04-03 21:38:55 +03:00
|
|
|
|
2014-11-19 03:36:46 +03:00
|
|
|
if phase != phases.public:
|
|
|
|
orig(pushop, nodes, phase)
|
|
|
|
|
2014-12-05 22:40:14 +03:00
|
|
|
@exchange.b2partsgenerator(commonheadsparttype)
|
|
|
|
def commonheadspartgen(pushop, bundler):
|
|
|
|
bundler.newpart(commonheadsparttype,
|
|
|
|
data=''.join(pushop.outgoing.commonheads))
|
|
|
|
|
|
|
|
@bundle2.parthandler(commonheadsparttype)
|
|
|
|
def commonheadshandler(op, inpart):
|
|
|
|
nodeid = inpart.read(20)
|
|
|
|
while len(nodeid) == 20:
|
|
|
|
op.records.add(commonheadsparttype, nodeid)
|
|
|
|
nodeid = inpart.read(20)
|
|
|
|
assert not nodeid # data should split evenly into blocks of 20 bytes
|
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
@exchange.b2partsgenerator(rebaseparttype)
|
|
|
|
def partgen(pushop, bundler):
|
|
|
|
onto = pushop.ui.config(experimental, configonto)
|
2015-10-29 04:19:12 +03:00
|
|
|
if 'changesets' in pushop.stepsdone or not onto:
|
2014-11-08 03:27:47 +03:00
|
|
|
return
|
|
|
|
|
|
|
|
pushop.stepsdone.add('changesets')
|
2014-11-19 03:36:46 +03:00
|
|
|
if not pushop.outgoing.missing:
|
2015-07-14 08:01:02 +03:00
|
|
|
# It's important that this text match the text found in upstream
|
|
|
|
# Mercurial, since some tools rely on this string to know if a push
|
|
|
|
# succeeded despite not pushing commits.
|
|
|
|
pushop.ui.status(_('no changes found\n'))
|
2014-11-19 03:36:46 +03:00
|
|
|
pushop.cgresult = 0
|
|
|
|
return
|
2015-04-03 21:38:55 +03:00
|
|
|
|
2014-12-09 03:39:20 +03:00
|
|
|
rebasepart = getrebasepart(pushop.repo,
|
|
|
|
pushop.remote,
|
|
|
|
pushop.outgoing,
|
|
|
|
onto,
|
2015-10-29 04:19:12 +03:00
|
|
|
pushop.newbranch,
|
|
|
|
pushop.force)
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
bundler.addpart(rebasepart)
|
|
|
|
|
2015-09-28 21:31:24 +03:00
|
|
|
# Tell the server which manifests to load before taking the lock.
|
|
|
|
# This helps shorten the duration of the lock, which increases our potential
|
|
|
|
# commit rate.
|
|
|
|
missing = pushop.outgoing.missing
|
|
|
|
roots = pushop.repo.set('parents(%ln) - %ln', missing, missing)
|
|
|
|
preloadnodes = [hex(r.manifestnode()) for r in roots]
|
|
|
|
bundler.addparam("preloadmanifests", ','.join(preloadnodes))
|
|
|
|
|
2014-11-19 03:36:46 +03:00
|
|
|
def handlereply(op):
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
# server either succeeds or aborts; no code to read
|
2014-11-19 03:36:46 +03:00
|
|
|
pushop.cgresult = 1
|
|
|
|
|
|
|
|
return handlereply
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
bundle2.capabilities[rebaseparttype] = ()
|
|
|
|
|
extract temporary bundle file creation into its own function
Summary:
Transferring the part data into a bundle file on disk for bundlerepo to read
is a self-contained operation
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726767
Signature: t1:1726767:1418241560:8afac123afc847e61e6f46b6216d15b003024504
2014-12-09 04:10:24 +03:00
|
|
|
def _makebundlefile(part):
|
|
|
|
"""constructs a temporary bundle file
|
|
|
|
|
|
|
|
part.data should be an uncompressed v1 changegroup"""
|
2015-04-03 21:38:55 +03:00
|
|
|
|
extract temporary bundle file creation into its own function
Summary:
Transferring the part data into a bundle file on disk for bundlerepo to read
is a self-contained operation
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726767
Signature: t1:1726767:1418241560:8afac123afc847e61e6f46b6216d15b003024504
2014-12-09 04:10:24 +03:00
|
|
|
fp = None
|
|
|
|
fd, bundlefile = tempfile.mkstemp()
|
|
|
|
try: # guards bundlefile
|
|
|
|
try: # guards fp
|
|
|
|
fp = os.fdopen(fd, 'wb')
|
|
|
|
magic = 'HG10UN'
|
|
|
|
fp.write(magic)
|
|
|
|
data = part.read(resource.getpagesize() - len(magic))
|
|
|
|
while data:
|
|
|
|
fp.write(data)
|
|
|
|
data = part.read(resource.getpagesize())
|
|
|
|
finally:
|
|
|
|
fp.close()
|
|
|
|
except:
|
|
|
|
try:
|
|
|
|
os.unlink(bundlefile)
|
|
|
|
except:
|
|
|
|
# we would rather see the original exception
|
|
|
|
pass
|
|
|
|
raise
|
|
|
|
|
|
|
|
return bundlefile
|
|
|
|
|
pushrebase: extract revlist creation and validation into its own function
Summary: None of these temporary variables should be needed later
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726850
Signature: t1:1726850:1418242127:64da1168b9f11897f6018082292e7f6285141bfd
2014-12-09 04:30:26 +03:00
|
|
|
def _getrevs(bundle, onto):
|
|
|
|
'extracts and validates the revs to be imported'
|
|
|
|
validaterevset(bundle, 'bundle()')
|
|
|
|
revs = [bundle[r] for r in bundle.revs('sort(bundle())')]
|
|
|
|
onto = bundle[onto.hex()]
|
2015-07-25 01:23:16 +03:00
|
|
|
# Fast forward update, no rebase needed
|
|
|
|
if list(bundle.set('bundle() & %d::', onto.rev())):
|
|
|
|
return revs, onto
|
pushrebase: extract revlist creation and validation into its own function
Summary: None of these temporary variables should be needed later
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726850
Signature: t1:1726850:1418242127:64da1168b9f11897f6018082292e7f6285141bfd
2014-12-09 04:30:26 +03:00
|
|
|
|
|
|
|
if revs:
|
2015-06-26 04:49:48 +03:00
|
|
|
# We want to rebase the highest bundle root that is an ancestor of
|
|
|
|
# `onto`.
|
2015-07-14 08:01:02 +03:00
|
|
|
oldonto = list(bundle.set('max(parents(bundle()) - bundle() & ::%d)',
|
|
|
|
onto.rev()))
|
2015-06-26 04:49:48 +03:00
|
|
|
if not oldonto:
|
2015-07-14 08:01:02 +03:00
|
|
|
# If there's no shared history, only allow the rebase if the
|
|
|
|
# incoming changes are completely distinct.
|
|
|
|
sharedparents = list(bundle.set('parents(bundle()) - bundle()'))
|
|
|
|
if not sharedparents:
|
|
|
|
return revs, bundle[nullid]
|
2015-06-26 04:49:48 +03:00
|
|
|
raise util.Abort(_('pushed commits do not branch from an ancestor '
|
|
|
|
'of the desired destination %s' % onto.hex()))
|
|
|
|
oldonto = oldonto[0]
|
|
|
|
|
|
|
|
# Computes a list of all files that are in the changegroup, and diffs it
|
|
|
|
# against all the files that changed between the old onto (ex: our old
|
|
|
|
# bookmark location) and the new onto (ex: the server's actual bookmark
|
|
|
|
# location). Since oldonto->onto is the distance of the rebase, this
|
|
|
|
# should catch any conflicting changes.
|
pushrebase: extract revlist creation and validation into its own function
Summary: None of these temporary variables should be needed later
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726850
Signature: t1:1726850:1418242127:64da1168b9f11897f6018082292e7f6285141bfd
2014-12-09 04:30:26 +03:00
|
|
|
files = reduce(operator.or_, [set(rev.files()) for rev in revs], set())
|
2015-06-26 04:49:48 +03:00
|
|
|
filematcher = scmutil.matchfiles(bundle, files)
|
|
|
|
commonmanifest = oldonto.manifest().matches(filematcher)
|
2015-04-17 23:49:35 +03:00
|
|
|
ontomanifest = onto.manifest().matches(filematcher)
|
pushrebase: extract revlist creation and validation into its own function
Summary: None of these temporary variables should be needed later
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726850
Signature: t1:1726850:1418242127:64da1168b9f11897f6018082292e7f6285141bfd
2014-12-09 04:30:26 +03:00
|
|
|
conflicts = ontomanifest.diff(commonmanifest).keys()
|
|
|
|
if conflicts:
|
|
|
|
raise util.Abort(_('conflicting changes in %r') % conflicts)
|
|
|
|
|
2015-06-26 04:49:48 +03:00
|
|
|
return revs, oldonto
|
|
|
|
|
|
|
|
def _graft(repo, rev, mapping):
|
|
|
|
'''duplicate changeset "rev" with parents from "mapping"'''
|
|
|
|
oldp1 = rev.p1().node()
|
|
|
|
oldp2 = rev.p2().node()
|
|
|
|
newp1 = mapping.get(oldp1, oldp1)
|
|
|
|
newp2 = mapping.get(oldp2, oldp2)
|
2015-07-24 00:11:58 +03:00
|
|
|
m = rev.manifest()
|
|
|
|
def getfilectx(repo, memctx, path):
|
|
|
|
if path in m:
|
2015-07-24 19:38:01 +03:00
|
|
|
fctx = rev[path]
|
|
|
|
flags = fctx.flags()
|
|
|
|
copied = fctx.renamed()
|
|
|
|
if copied:
|
|
|
|
copied = copied[0]
|
|
|
|
return context.memfilectx(repo, fctx.path(), fctx.data(),
|
|
|
|
islink='l' in flags,
|
|
|
|
isexec='x' in flags,
|
|
|
|
copied=copied)
|
2015-07-24 00:11:58 +03:00
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
pushrebase: extract revlist creation and validation into its own function
Summary: None of these temporary variables should be needed later
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726850
Signature: t1:1726850:1418242127:64da1168b9f11897f6018082292e7f6285141bfd
2014-12-09 04:30:26 +03:00
|
|
|
|
2015-07-14 08:01:02 +03:00
|
|
|
# If the incoming commit has no parents, but requested a rebase,
|
|
|
|
# allow it only for the first commit. The null/null commit will always
|
|
|
|
# be the first commit since we only allow a nullid->nonnullid mapping if the
|
|
|
|
# incoming commits are a completely distinct history (see `sharedparents` in
|
|
|
|
# getrevs()), so there's no risk of commits with a single null parent
|
|
|
|
# accidentally getting translated first.
|
|
|
|
if oldp1 == nullid and oldp2 == nullid:
|
|
|
|
if newp1 != nullid:
|
|
|
|
newp2 = nullid
|
|
|
|
del mapping[nullid]
|
|
|
|
|
2015-08-11 08:15:03 +03:00
|
|
|
if oldp1 != nullid and oldp2 != nullid:
|
|
|
|
# If it's a merge commit, Mercurial's rev.files() only returns the files
|
|
|
|
# that are different from both p1 and p2, so it would not capture all of
|
|
|
|
# the incoming changes from p2 (for instance, new files in p2). The fix
|
|
|
|
# is to manually diff the rev manifest and it's p1 to get the list of
|
|
|
|
# files that have changed. We only need to diff against p1, and not p2,
|
|
|
|
# because Mercurial constructs new commits by applying our specified
|
|
|
|
# files on top of a copy of the p1 manifest, so we only need the diff
|
|
|
|
# against p1.
|
|
|
|
files = rev.manifest().diff(repo[oldp1].manifest()).keys()
|
|
|
|
else:
|
|
|
|
files = rev.files()
|
|
|
|
|
2015-10-18 04:59:46 +03:00
|
|
|
|
|
|
|
date = rev.date()
|
|
|
|
if repo.ui.configbool('pushrebase', 'rewritedates'):
|
|
|
|
date = (time.time(), date[1])
|
pushrebase: extract commit grafting into its own function
Summary: Breaking up the part handler into smaller pieces
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726701
Signature: t1:1726701:1418241313:52edc229bc635d7e703bcc2b5ee5673ece6373fa
2014-12-09 03:54:14 +03:00
|
|
|
return context.memctx(repo,
|
2015-06-26 04:49:48 +03:00
|
|
|
[newp1, newp2],
|
pushrebase: extract commit grafting into its own function
Summary: Breaking up the part handler into smaller pieces
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726701
Signature: t1:1726701:1418241313:52edc229bc635d7e703bcc2b5ee5673ece6373fa
2014-12-09 03:54:14 +03:00
|
|
|
rev.description(),
|
2015-08-11 08:15:03 +03:00
|
|
|
files,
|
2015-07-24 00:11:58 +03:00
|
|
|
getfilectx,
|
pushrebase: extract commit grafting into its own function
Summary: Breaking up the part handler into smaller pieces
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726701
Signature: t1:1726701:1418241313:52edc229bc635d7e703bcc2b5ee5673ece6373fa
2014-12-09 03:54:14 +03:00
|
|
|
rev.user(),
|
2015-10-18 04:59:46 +03:00
|
|
|
date,
|
pushrebase: extract commit grafting into its own function
Summary: Breaking up the part handler into smaller pieces
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726701
Signature: t1:1726701:1418241313:52edc229bc635d7e703bcc2b5ee5673ece6373fa
2014-12-09 03:54:14 +03:00
|
|
|
rev.extra(),
|
|
|
|
).commit()
|
|
|
|
|
pushrebase: extract obsolete marker generation into a function
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726944
Signature: t1:1726944:1418242222:a91974f41b5883eb659dd69135176adf066b8b47
2014-12-09 04:49:48 +03:00
|
|
|
def _buildobsolete(replacements, oldrepo, newrepo):
|
|
|
|
'adds obsolete markers in replacements if enabled in newrepo'
|
|
|
|
if obsolete.isenabled(newrepo, obsolete.createmarkersopt):
|
|
|
|
markers = [(oldrepo[oldrev], (newrepo[newrev],))
|
|
|
|
for oldrev, newrev in replacements.items()
|
|
|
|
if newrev != oldrev]
|
|
|
|
|
|
|
|
obsolete.createmarkers(newrepo, markers)
|
|
|
|
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
def _addpushbackchangegroup(repo, reply, outgoing):
|
|
|
|
'''adds changegroup part to reply containing revs from outgoing.missing'''
|
2015-04-17 23:49:35 +03:00
|
|
|
cgversions = set(reply.capabilities.get('changegroup'))
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
if not cgversions:
|
|
|
|
cgversions.add('01')
|
|
|
|
version = max(cgversions & set(changegroup.packermap.keys()))
|
2015-04-03 21:38:55 +03:00
|
|
|
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
cg = changegroup.getlocalchangegroupraw(repo,
|
|
|
|
'rebase:reply',
|
|
|
|
outgoing,
|
|
|
|
version = version)
|
|
|
|
|
2015-04-17 23:49:35 +03:00
|
|
|
cgpart = reply.newpart('CHANGEGROUP', data = cg)
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
if version != '01':
|
|
|
|
cgpart.addparam('version', version)
|
|
|
|
|
|
|
|
def _addpushbackobsolete(repo, reply, newrevs):
|
|
|
|
'''adds obsoletion markers to reply that are relevant to newrevs
|
|
|
|
(if enabled)'''
|
|
|
|
if (obsolete.isenabled(repo, obsolete.exchangeopt) and repo.obsstore):
|
|
|
|
try:
|
|
|
|
markers = repo.obsstore.relevantmarkers(newrevs)
|
|
|
|
exchange.buildobsmarkerspart(reply, markers)
|
|
|
|
except ValueError, exc:
|
|
|
|
repo.ui.status(_("can't send obsolete markers: %s") % exc.message)
|
|
|
|
|
|
|
|
def _addpushbackparts(op, replacements):
|
|
|
|
'''adds pushback to reply if supported by the client'''
|
|
|
|
if (op.records[commonheadsparttype]
|
|
|
|
and op.reply
|
2015-04-17 23:49:35 +03:00
|
|
|
and 'pushback' in op.reply.capabilities):
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
outgoing = discovery.outgoing(op.repo.changelog,
|
|
|
|
op.records[commonheadsparttype],
|
|
|
|
[new for old, new in replacements.items()
|
|
|
|
if old != new])
|
|
|
|
|
|
|
|
if outgoing.missing:
|
|
|
|
_addpushbackchangegroup(op.repo, op.reply, outgoing)
|
|
|
|
_addpushbackobsolete(op.repo, op.reply, replacements.values())
|
|
|
|
|
2015-10-29 04:19:12 +03:00
|
|
|
@bundle2.parthandler(rebaseparttype, ('onto', 'newhead', 'force'))
|
2014-11-08 03:27:47 +03:00
|
|
|
def bundle2rebase(op, part):
|
|
|
|
'''unbundle a bundle2 containing a changegroup to rebase'''
|
|
|
|
|
|
|
|
params = part.params
|
|
|
|
|
|
|
|
bundlefile = None
|
|
|
|
|
|
|
|
try: # guards bundlefile
|
extract temporary bundle file creation into its own function
Summary:
Transferring the part data into a bundle file on disk for bundlerepo to read
is a self-contained operation
Test Plan: ##run_tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726767
Signature: t1:1726767:1418241560:8afac123afc847e61e6f46b6216d15b003024504
2014-12-09 04:10:24 +03:00
|
|
|
bundlefile = _makebundlefile(part)
|
2014-11-08 03:27:47 +03:00
|
|
|
bundle = bundlerepository(op.repo.ui, op.repo.root, bundlefile)
|
2015-09-28 21:30:31 +03:00
|
|
|
|
2015-10-06 04:56:46 +03:00
|
|
|
# Allow running hooks on the new commits before we take the lock
|
|
|
|
prelockrebaseargs = dict()
|
|
|
|
prelockrebaseargs['source'] = 'push'
|
|
|
|
prelockrebaseargs['bundle2'] = '1'
|
|
|
|
prelockrebaseargs['node'] = scmutil.revsingle(bundle, 'min(bundle())').hex()
|
|
|
|
prelockrebaseargs['hook_bundlepath'] = bundlefile
|
|
|
|
op.repo.hook("prepushrebase", throw=True, **prelockrebaseargs)
|
|
|
|
|
|
|
|
tr = op.gettransaction()
|
|
|
|
hookargs = dict(tr.hookargs)
|
|
|
|
|
2015-09-28 21:30:31 +03:00
|
|
|
# Preload the caches with data we already have. We need to make copies
|
|
|
|
# here so that original repo caches don't get tainted with bundle
|
|
|
|
# specific data.
|
|
|
|
newmancache = bundle.manifest._mancache
|
|
|
|
oldmancache = op.repo.manifest._mancache
|
|
|
|
newmancache._cache = oldmancache._cache.copy()
|
|
|
|
newmancache._order = collections.deque(oldmancache._order)
|
|
|
|
bundle.manifest._cache = op.repo.manifest._cache
|
|
|
|
|
2015-10-06 04:56:46 +03:00
|
|
|
try:
|
2015-10-29 04:19:12 +03:00
|
|
|
# onto == None means don't do rebasing
|
2015-10-06 04:56:46 +03:00
|
|
|
onto = None
|
2015-10-29 04:19:12 +03:00
|
|
|
if params['force'] != 'True':
|
|
|
|
onto = scmutil.revsingle(op.repo, params['onto'])
|
|
|
|
except error.RepoLookupError:
|
|
|
|
# Probably a new bookmark. Don't do rebasing
|
|
|
|
pass
|
2015-10-06 04:56:46 +03:00
|
|
|
|
|
|
|
if not params['newhead']:
|
|
|
|
if not op.repo.revs('%r and head()', params['onto']):
|
|
|
|
raise util.Abort(_('rebase would produce a new head on server'))
|
|
|
|
|
2015-07-14 08:01:02 +03:00
|
|
|
if onto == None:
|
|
|
|
maxcommonanc = list(bundle.set('max(parents(bundle()) - bundle())'))
|
|
|
|
if not maxcommonanc:
|
|
|
|
onto = op.repo[nullid]
|
|
|
|
else:
|
|
|
|
onto = maxcommonanc[0]
|
|
|
|
|
2015-06-26 04:49:48 +03:00
|
|
|
revs, oldonto = _getrevs(bundle, onto)
|
2014-11-08 03:27:47 +03:00
|
|
|
|
2014-12-09 02:43:58 +03:00
|
|
|
op.repo.hook("prechangegroup", **hookargs)
|
|
|
|
|
2015-06-26 04:49:48 +03:00
|
|
|
mapping = {}
|
|
|
|
|
|
|
|
# Seed the mapping with oldonto->onto
|
|
|
|
mapping[oldonto.node()] = onto.node()
|
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
replacements = {}
|
2014-12-09 02:43:58 +03:00
|
|
|
added = []
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
for rev in revs:
|
2015-06-26 04:49:48 +03:00
|
|
|
newrev = _graft(op.repo, rev, mapping)
|
|
|
|
|
|
|
|
new = op.repo[newrev]
|
|
|
|
oldnode = rev.node()
|
|
|
|
newnode = new.node()
|
|
|
|
replacements[oldnode] = newnode
|
|
|
|
mapping[oldnode] = newnode
|
|
|
|
added.append(newnode)
|
|
|
|
|
2015-09-23 20:25:24 +03:00
|
|
|
if 'node' not in tr.hookargs:
|
|
|
|
tr.hookargs['node'] = hex(newnode)
|
|
|
|
hookargs['node'] = hex(newnode)
|
|
|
|
|
pushrebase: extract obsolete marker generation into a function
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1726944
Signature: t1:1726944:1418242222:a91974f41b5883eb659dd69135176adf066b8b47
2014-12-09 04:49:48 +03:00
|
|
|
_buildobsolete(replacements, bundle, op.repo)
|
2014-11-08 03:27:47 +03:00
|
|
|
finally:
|
|
|
|
try:
|
|
|
|
if bundlefile:
|
|
|
|
os.unlink(bundlefile)
|
|
|
|
except OSError, e:
|
|
|
|
if e.errno != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
|
2014-12-19 03:22:19 +03:00
|
|
|
publishing = op.repo.ui.configbool('phases', 'publish', True)
|
|
|
|
if publishing:
|
|
|
|
phases.advanceboundary(op.repo, tr, phases.public, [added[-1]])
|
|
|
|
|
2014-12-09 02:43:58 +03:00
|
|
|
p = lambda: tr.writepending() and op.repo.root or ""
|
|
|
|
op.repo.hook("pretxnchangegroup", throw=True, pending=p, **hookargs)
|
|
|
|
|
|
|
|
def runhooks():
|
pushrebase: add node argument to changegroup hook
Summary: This is expected by the remotefilelog hook, and possibly others
Test Plan: ##run-tests.py##
Reviewers: durham, pyd, sid0
Reviewed By: sid0
Subscribers: calvinb, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1743261
Signature: t1:1743261:1418762431:4fbbc1ed800023ddc51dbf53703e58294fbc2a4c
2014-12-16 23:38:48 +03:00
|
|
|
args = hookargs.copy()
|
|
|
|
args['node'] = hex(added[0])
|
|
|
|
op.repo.hook("changegroup", **args)
|
2014-12-09 02:43:58 +03:00
|
|
|
for n in added:
|
|
|
|
args = hookargs.copy()
|
|
|
|
args['node'] = hex(n)
|
|
|
|
op.repo.hook("incoming", **args)
|
|
|
|
|
|
|
|
tr.addpostclose('serverrebase-cg-hooks',
|
|
|
|
lambda tr: op.repo._afterlock(runhooks))
|
|
|
|
|
pushrebase: extract pushback into its own function
Summary: Also, remove some spurious TODOs
Test Plan: ##run-tests.py##
Reviewers: pyd, durham
Reviewed By: durham
Subscribers: calvinb, mitrandir, rmcelroy, daviser, mpm, davidsp, sid0, akushner, pyd, durham
Differential Revision: https://phabricator.fb.com/D1732036
Signature: t1:1732036:1418250584:6922035a05df012445b0092f8646eb982602f07d
2014-12-11 01:22:34 +03:00
|
|
|
_addpushbackparts(op, replacements)
|
2014-11-19 03:36:46 +03:00
|
|
|
|
|
|
|
for k in replacements.keys():
|
|
|
|
replacements[hex(k)] = hex(replacements[k])
|
2014-11-21 21:55:46 +03:00
|
|
|
op.records.add(rebaseparttype, replacements)
|
2014-11-19 03:36:46 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
return 1
|
|
|
|
|
|
|
|
def bundle2pushkey(orig, op, part):
|
2014-11-21 21:55:46 +03:00
|
|
|
replacements = dict(sum([record.items()
|
|
|
|
for record
|
|
|
|
in op.records[rebaseparttype]],
|
|
|
|
[]))
|
2015-04-03 21:38:55 +03:00
|
|
|
|
2014-11-08 03:27:47 +03:00
|
|
|
namespace = pushkey.decode(part.params['namespace'])
|
|
|
|
if namespace == 'phases':
|
|
|
|
key = pushkey.decode(part.params['key'])
|
|
|
|
part.params['key'] = pushkey.encode(replacements.get(key, key))
|
|
|
|
if namespace == 'bookmarks':
|
|
|
|
new = pushkey.decode(part.params['new'])
|
|
|
|
part.params['new'] = pushkey.encode(replacements.get(new, new))
|
2015-10-02 10:46:37 +03:00
|
|
|
serverbin = op.repo._bookmarks.get(part.params['key'])
|
|
|
|
clienthex = pushkey.decode(part.params['old'])
|
|
|
|
|
|
|
|
if serverbin and clienthex:
|
|
|
|
cl = op.repo.changelog
|
|
|
|
revserver = cl.rev(serverbin)
|
|
|
|
revclient = cl.rev(bin(clienthex))
|
|
|
|
if revclient in cl.ancestors([revserver]):
|
|
|
|
# if the client's bookmark origin is an lagging behind the
|
|
|
|
# server's location for that bookmark (usual for pushrebase)
|
|
|
|
# then update the old location to match the real location
|
|
|
|
#
|
|
|
|
# TODO: We would prefer to only do this for pushrebase pushes
|
|
|
|
# but that isn't straightforward so we just do it always here.
|
|
|
|
# This forbids moving bookmarks backwards from clients.
|
|
|
|
part.params['old'] = pushkey.encode(hex(serverbin))
|
2014-11-08 03:27:47 +03:00
|
|
|
|
|
|
|
return orig(op, part)
|