Details
Details
- Reviewers
durin42 pulkit - Group Reviewers
hg-reviewers - Commits
- rHG18e6ea9ba81d: narrow: filter set of files to check for case-folding to core
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
durin42 | |
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/narrowmerge.py (17 lines) | |||
M | mercurial/merge.py (17 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | May 17 2018, 6:25 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
# narrowmerge.py - extensions to mercurial merge module to support narrow clones | # narrowmerge.py - extensions to mercurial merge module to support narrow clones | ||||
# | # | ||||
# Copyright 2017 Google, Inc. | # Copyright 2017 Google, Inc. | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from mercurial import ( | from mercurial import ( | ||||
copies, | copies, | ||||
extensions, | extensions, | ||||
merge, | |||||
) | ) | ||||
def setup(): | def setup(): | ||||
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): | def _computenonoverlap(orig, repo, *args, **kwargs): | ||||
u1, u2 = orig(repo, *args, **kwargs) | u1, u2 = orig(repo, *args, **kwargs) | ||||
narrowmatch = repo.narrowmatch() | narrowmatch = repo.narrowmatch() | ||||
if narrowmatch.always(): | if narrowmatch.always(): | ||||
return u1, u2 | return u1, u2 | ||||
u1 = [f for f in u1 if narrowmatch(f)] | u1 = [f for f in u1 if narrowmatch(f)] | ||||
u2 = [f for f in u2 if narrowmatch(f)] | u2 = [f for f in u2 if narrowmatch(f)] | ||||
return u1, u2 | return u1, u2 | ||||
extensions.wrapfunction(copies, '_computenonoverlap', _computenonoverlap) | extensions.wrapfunction(copies, '_computenonoverlap', _computenonoverlap) |
if not branchmerge: | if not branchmerge: | ||||
for f in wctx.removed(): | for f in wctx.removed(): | ||||
if f not in mctx: | if f not in mctx: | ||||
actions[f] = ACTION_FORGET, None, "forget removed" | actions[f] = ACTION_FORGET, None, "forget removed" | ||||
return actions | return actions | ||||
def _checkcollision(repo, wmf, actions): | def _checkcollision(repo, wmf, actions): | ||||
""" | |||||
Check for case-folding collisions. | |||||
""" | |||||
# If the repo is narrowed, filter out files outside the narrowspec. | |||||
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 | |||||
# build provisional merged manifest up | # build provisional merged manifest up | ||||
pmmf = set(wmf) | pmmf = set(wmf) | ||||
if actions: | if actions: | ||||
# KEEP and EXEC are no-op | # KEEP and EXEC are no-op | ||||
for m in (ACTION_ADD, ACTION_ADD_MODIFIED, ACTION_FORGET, ACTION_GET, | for m in (ACTION_ADD, ACTION_ADD_MODIFIED, ACTION_FORGET, ACTION_GET, | ||||
ACTION_CHANGED_DELETED, ACTION_DELETED_CHANGED): | ACTION_CHANGED_DELETED, ACTION_DELETED_CHANGED): | ||||
for f, args, msg in actions[m]: | for f, args, msg in actions[m]: |