Skip to main content

graft

graft

copy commits from a different location

Use Sapling's merge logic to copy individual commits from other locations without making merge commits. This is sometimes known as 'backporting' or 'cherry-picking'. By default, graft will also copy user and description from the source commits. If you want to keep the date of the source commits, you can add below config to your configuration file:

[tweakdefaults]
graftkeepdate = True

Source commits will be skipped if they are ancestors of the current commit, have already been grafted, or are merges.

If --log is specified, commit messages will have a comment appended of the form:

(grafted from COMMITHASH)

If --force is specified, commits will be grafted even if they are already ancestors of, or have been grafted to, the destination. This is useful when the commits have since been backed out.

If a graft results in conflicts, the graft process is interrupted so that the current merge can be manually resolved. Once all conflicts are resolved, the graft process can be continued with the -c/--continue option.

The -c/--continue operation does not remember options from the original invocation, except for --force.

Examples:

  • copy a single change to the stable branch and edit its description:
sl goto stable
sl graft --edit ba7e89595
  • graft a range of changesets with one exception, updating dates:
sl graft -D "0e13e529c::224010e02 and not 85c0535a4"
  • continue a graft after resolving conflicts:
sl graft -c
  • abort an interrupted graft:
sl graft --abort
  • show the source of a grafted changeset:
sl log --debug -r .

See sl help revisions for more about specifying revisions.

Returns 0 on success.

arguments

shortnamefullnamedefaultdescription
-r--revrevisions to graft
-c--continuefalseresume interrupted graft
--abortfalseabort an interrupted graft
-e--editfalseinvoke editor on commit messages
--logappend graft info to log message
-f--forcefalseforce graft
-D--currentdatefalserecord the current date as commit date
-U--currentuserfalserecord the current user as committer
-d--daterecord the specified date as commit date
-u--userrecord the specified user as committer
-t--toolspecify merge tool
-n--dry-rundo not perform actions, just print output