Skip to content

Commit

Permalink
subtree: expose the 'subtree.copy-max-file-count' config to users
Browse files Browse the repository at this point in the history
Summary: Expose the 'subtree.copy-max-file-count' config to users, so users can override if needed.

Reviewed By: quark-zju

Differential Revision: D68643111

fbshipit-source-id: b162ce8d6885b53acc15d20f255c5074f23e5c71
  • Loading branch information
zzl0 authored and facebook-github-bot committed Jan 31, 2025
1 parent f6481bf commit b25c625
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
18 changes: 16 additions & 2 deletions eden/scm/sapling/commands/subtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,22 @@ def prefetch(repo, path, fileids):
file_count += len(fileids)
if file_count > limit:
support = ui.config("ui", "supportcontact")
hint = _("contact %s for help") % support if support else ""
raise error.Abort(_("subtree copy includes too many files"), hint=hint)
help_hint = _("contact %s for help") % support if support else None
override_hint = _(
"use '--config subtree.copy-max-file-count=N' cautiously to override"
)
hint = (
_("%s or %s") % (help_hint, override_hint)
if help_hint
else override_hint
)
raise error.Abort(
_(
"subtree copy includes too many files (%d), exceeding configured limit (%d)"
)
% (file_count, limit),
hint=hint,
)
path_to_fileids[path] = fileids

new_files = []
Expand Down
7 changes: 4 additions & 3 deletions eden/scm/tests/test-subtree.t
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ abort when subtree copy too many files
> # drawdag.defaultfiles=false
> EOS
$ hg subtree cp -r $A --from-path foo --to-path bar --config subtree.copy-max-file-count=1
abort: subtree copy includes too many files
abort: subtree copy includes too many files (2), exceeding configured limit (1)
(use '--config subtree.copy-max-file-count=N' cautiously to override)
[255]
$ hg subtree cp -r $A --from-path foo --to-path bar --config subtree.copy-max-file-count=1 --config ui.supportcontact="Sapling Team"
abort: subtree copy includes too many files
(contact Sapling Team for help)
abort: subtree copy includes too many files (2), exceeding configured limit (1)
(contact Sapling Team for help or use '--config subtree.copy-max-file-count=N' cautiously to override)
[255]


Expand Down

0 comments on commit b25c625

Please sign in to comment.