Skip to content

Commit

Permalink
subtree: extract subtree_path_opts
Browse files Browse the repository at this point in the history
Summary:
extract subtree_path_opts, and use it in subtree commands.

I decided not to use `diffgraftopts` because the description (`re-map`) of `diffgraftopts` may not clear to users.

Reviewed By: sggutier

Differential Revision: D63050337

fbshipit-source-id: f54b7f5b9766c0e805a90d9eb5de8f6b2260b4e7
  • Loading branch information
zzl0 authored and facebook-github-bot committed Sep 20, 2024
1 parent d401ab5 commit cf19968
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
17 changes: 17 additions & 0 deletions eden/scm/sapling/cmdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,23 @@ def _typedflags(flags):
("", "dir", "", _("open directory manifest")),
]

subtree_path_opts = [
(
"",
"from-path",
[],
_("the path of source directory or file"),
_("PATH"),
),
(
"",
"to-path",
[],
_("the path of dest directory or file"),
_("PATH"),
),
]

# special string such that everything below this line will be ingored in the
# editor text
_linebelow = (
Expand Down
27 changes: 10 additions & 17 deletions eden/scm/sapling/commands/subtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

from .. import cmdutil, context, error, hg, merge as mergemod, node, scmutil

from ..cmdutil import commitopts, commitopts2, diffgraftopts, dryrunopts, mergetoolopts
from ..cmdutil import (
commitopts,
commitopts2,
dryrunopts,
mergetoolopts,
subtree_path_opts,
)
from ..i18n import _
from .cmdtable import command

Expand Down Expand Up @@ -51,21 +57,8 @@ def subtree(ui, repo, *pats, **opts) -> None:
_("the commit to copy from"),
_("REV"),
),
(
"",
"from-path",
[],
_("the path of source directory or file"),
_("PATH"),
),
(
"",
"to-path",
[],
_("the path of dest directory or file"),
_("PATH"),
),
]
+ subtree_path_opts
+ commitopts
+ commitopts2,
_("[-r REV] --from-path PATH --to-path PATH ..."),
Expand Down Expand Up @@ -95,7 +88,7 @@ def subtree_copy(ui, repo, *args, **opts):
+ commitopts2
+ mergetoolopts
+ dryrunopts
+ diffgraftopts,
+ subtree_path_opts,
_("[OPTION]... --from-path PATH --to-path PATH ..."),
)
def subtree_graft(ui, repo, **opts):
Expand All @@ -118,7 +111,7 @@ def subtree_graft(ui, repo, **opts):
("r", "rev", "", _("revisions to merge"), _("REV")),
]
+ mergetoolopts
+ diffgraftopts,
+ subtree_path_opts,
_("[OPTION]... --from-path PATH --to-path PATH"),
)
def subtree_merge(ui, repo, **opts):
Expand Down

0 comments on commit cf19968

Please sign in to comment.