##// END OF EJS Templates
infinitepush: open files in binary mode...
infinitepush: open files in binary mode This fixes the scary looking abort in test-infinitepush-ci.t when unbundling: --- tests/test-infinitepush-ci.t +++ tests/test-infinitepush-ci.t.err @@ -84,15 +84,12 @@ $ hg unbundle .hg/scratchbranches/filebundlestore/a4/c2/a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 adding changesets - adding manifests - adding file changes - added 1 changesets with 1 changes to 1 files - new changesets 6cb0989601f1 - (run 'hg update' to get a working copy) - - $ hg glog - o 1:6cb0989601f1 added a - | public + transaction abort! + rollback completed + abort: stream ended unexpectedly (got 68 bytes, expected 218759168) + [255] + + $ hg glog @ 0:67145f466344 initialcommit public This was found by grepping for '"r', "'r", '"w' and "'w" after manually creating a bundle from the same revision, diffing against the corrupt one, and seeing CRs sprinkled around. Sadly, the missing bookmarks are still a problem in the two remaining test failures.

File last commit:

r36490:d0d5eef5 default
r37810:33d26f7b stable
Show More
narrowmerge.py
77 lines | 2.9 KiB | text/x-python | PythonLexer
# narrowmerge.py - extensions to mercurial merge module to support narrow clones
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
copies,
error,
extensions,
merge,
)
def setup():
def _manifestmerge(orig, repo, wctx, p2, pa, branchmerge, *args, **kwargs):
"""Filter updates to only lay out files that match the narrow spec."""
actions, diverge, renamedelete = orig(
repo, wctx, p2, pa, branchmerge, *args, **kwargs)
narrowmatch = repo.narrowmatch()
if narrowmatch.always():
return actions, diverge, renamedelete
nooptypes = set(['k']) # TODO: handle with nonconflicttypes
nonconflicttypes = set('a am c cm f g r e'.split())
# We mutate the items in the dict during iteration, so iterate
# over a copy.
for f, action in list(actions.items()):
if narrowmatch(f):
pass
elif not branchmerge:
del actions[f] # just updating, ignore changes outside clone
elif action[0] in nooptypes:
del actions[f] # merge does not affect file
elif action[0] in nonconflicttypes:
raise error.Abort(_('merge affects file \'%s\' outside narrow, '
'which is not yet supported') % f,
hint=_('merging in the other direction '
'may work'))
else:
raise error.Abort(_('conflict in file \'%s\' is outside '
'narrow clone') % f)
return actions, diverge, renamedelete
extensions.wrapfunction(merge, 'manifestmerge', _manifestmerge)
def _checkcollision(orig, repo, wmf, actions):
narrowmatch = repo.narrowmatch()
if not narrowmatch.always():
wmf = wmf.matches(narrowmatch)
if actions:
narrowactions = {}
for m, actionsfortype in actions.iteritems():
narrowactions[m] = []
for (f, args, msg) in actionsfortype:
if narrowmatch(f):
narrowactions[m].append((f, args, msg))
actions = narrowactions
return orig(repo, wmf, actions)
extensions.wrapfunction(merge, '_checkcollision', _checkcollision)
def _computenonoverlap(orig, repo, *args, **kwargs):
u1, u2 = orig(repo, *args, **kwargs)
narrowmatch = repo.narrowmatch()
if narrowmatch.always():
return u1, u2
u1 = [f for f in u1 if narrowmatch(f)]
u2 = [f for f in u2 if narrowmatch(f)]
return u1, u2
extensions.wrapfunction(copies, '_computenonoverlap', _computenonoverlap)