You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PullCommand.java 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. * Copyright (C) 2010, Christian Halstrick <christian.halstrick@sap.com>
  3. * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
  4. * Copyright (C) 2016, Laurent Delaigue <laurent.delaigue@obeo.fr>
  5. * and other copyright owners as documented in the project's IP log.
  6. *
  7. * This program and the accompanying materials are made available
  8. * under the terms of the Eclipse Distribution License v1.0 which
  9. * accompanies this distribution, is reproduced below, and is
  10. * available at http://www.eclipse.org/org/documents/edl-v10.php
  11. *
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or
  15. * without modification, are permitted provided that the following
  16. * conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. *
  21. * - Redistributions in binary form must reproduce the above
  22. * copyright notice, this list of conditions and the following
  23. * disclaimer in the documentation and/or other materials provided
  24. * with the distribution.
  25. *
  26. * - Neither the name of the Eclipse Foundation, Inc. nor the
  27. * names of its contributors may be used to endorse or promote
  28. * products derived from this software without specific prior
  29. * written permission.
  30. *
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  32. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  33. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  34. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  36. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  37. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  38. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  39. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  40. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  41. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  42. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  43. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. */
  45. package org.eclipse.jgit.api;
  46. import java.io.IOException;
  47. import java.text.MessageFormat;
  48. import org.eclipse.jgit.annotations.Nullable;
  49. import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
  50. import org.eclipse.jgit.api.MergeCommand.FastForwardMode.Merge;
  51. import org.eclipse.jgit.api.RebaseCommand.Operation;
  52. import org.eclipse.jgit.api.errors.CanceledException;
  53. import org.eclipse.jgit.api.errors.GitAPIException;
  54. import org.eclipse.jgit.api.errors.InvalidConfigurationException;
  55. import org.eclipse.jgit.api.errors.InvalidRemoteException;
  56. import org.eclipse.jgit.api.errors.JGitInternalException;
  57. import org.eclipse.jgit.api.errors.NoHeadException;
  58. import org.eclipse.jgit.api.errors.RefNotAdvertisedException;
  59. import org.eclipse.jgit.api.errors.RefNotFoundException;
  60. import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
  61. import org.eclipse.jgit.dircache.DirCacheCheckout;
  62. import org.eclipse.jgit.internal.JGitText;
  63. import org.eclipse.jgit.lib.AnyObjectId;
  64. import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode;
  65. import org.eclipse.jgit.lib.Config;
  66. import org.eclipse.jgit.lib.ConfigConstants;
  67. import org.eclipse.jgit.lib.Constants;
  68. import org.eclipse.jgit.lib.NullProgressMonitor;
  69. import org.eclipse.jgit.lib.ObjectId;
  70. import org.eclipse.jgit.lib.ProgressMonitor;
  71. import org.eclipse.jgit.lib.Ref;
  72. import org.eclipse.jgit.lib.RefUpdate;
  73. import org.eclipse.jgit.lib.RefUpdate.Result;
  74. import org.eclipse.jgit.lib.Repository;
  75. import org.eclipse.jgit.lib.RepositoryState;
  76. import org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode;
  77. import org.eclipse.jgit.merge.MergeStrategy;
  78. import org.eclipse.jgit.revwalk.RevCommit;
  79. import org.eclipse.jgit.revwalk.RevWalk;
  80. import org.eclipse.jgit.transport.FetchResult;
  81. import org.eclipse.jgit.transport.TagOpt;
  82. /**
  83. * The Pull command
  84. *
  85. * @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html"
  86. * >Git documentation about Pull</a>
  87. */
  88. public class PullCommand extends TransportCommand<PullCommand, PullResult> {
  89. private final static String DOT = "."; //$NON-NLS-1$
  90. private ProgressMonitor monitor = NullProgressMonitor.INSTANCE;
  91. private BranchRebaseMode pullRebaseMode = null;
  92. private String remote;
  93. private String remoteBranchName;
  94. private MergeStrategy strategy = MergeStrategy.RECURSIVE;
  95. private TagOpt tagOption;
  96. private FastForwardMode fastForwardMode;
  97. private FetchRecurseSubmodulesMode submoduleRecurseMode = null;
  98. /**
  99. * Constructor for PullCommand.
  100. *
  101. * @param repo
  102. * the {@link org.eclipse.jgit.lib.Repository}
  103. */
  104. protected PullCommand(Repository repo) {
  105. super(repo);
  106. }
  107. /**
  108. * Set progress monitor
  109. *
  110. * @param monitor
  111. * a progress monitor
  112. * @return this instance
  113. */
  114. public PullCommand setProgressMonitor(ProgressMonitor monitor) {
  115. if (monitor == null) {
  116. monitor = NullProgressMonitor.INSTANCE;
  117. }
  118. this.monitor = monitor;
  119. return this;
  120. }
  121. /**
  122. * Set if rebase should be used after fetching. If set to true, rebase is
  123. * used instead of merge. This is equivalent to --rebase on the command
  124. * line.
  125. * <p>
  126. * If set to false, merge is used after fetching, overriding the
  127. * configuration file. This is equivalent to --no-rebase on the command
  128. * line.
  129. * <p>
  130. * This setting overrides the settings in the configuration file. By
  131. * default, the setting in the repository configuration file is used.
  132. * <p>
  133. * A branch can be configured to use rebase by default. See
  134. * branch.[name].rebase and branch.autosetuprebase.
  135. *
  136. * @param useRebase
  137. * whether to use rebase after fetching
  138. * @return {@code this}
  139. */
  140. public PullCommand setRebase(boolean useRebase) {
  141. checkCallable();
  142. pullRebaseMode = useRebase ? BranchRebaseMode.REBASE
  143. : BranchRebaseMode.NONE;
  144. return this;
  145. }
  146. /**
  147. * Sets the {@link org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode} to
  148. * use after fetching.
  149. *
  150. * <dl>
  151. * <dt>BranchRebaseMode.REBASE</dt>
  152. * <dd>Equivalent to {@code --rebase} on the command line: use rebase
  153. * instead of merge after fetching.</dd>
  154. * <dt>BranchRebaseMode.PRESERVE</dt>
  155. * <dd>Equivalent to {@code --preserve-merges} on the command line: rebase
  156. * preserving local merge commits.</dd>
  157. * <dt>BranchRebaseMode.INTERACTIVE</dt>
  158. * <dd>Equivalent to {@code --interactive} on the command line: use
  159. * interactive rebase.</dd>
  160. * <dt>BranchRebaseMode.NONE</dt>
  161. * <dd>Equivalent to {@code --no-rebase}: merge instead of rebasing.
  162. * <dt>{@code null}</dt>
  163. * <dd>Use the setting defined in the git configuration, either {@code
  164. * branch.[name].rebase} or, if not set, {@code pull.rebase}</dd>
  165. * </dl>
  166. *
  167. * This setting overrides the settings in the configuration file. By
  168. * default, the setting in the repository configuration file is used.
  169. * <p>
  170. * A branch can be configured to use rebase by default. See
  171. * {@code branch.[name].rebase}, {@code branch.autosetuprebase}, and
  172. * {@code pull.rebase}.
  173. *
  174. * @param rebaseMode
  175. * the {@link org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode}
  176. * to use
  177. * @return {@code this}
  178. * @since 4.5
  179. */
  180. public PullCommand setRebase(BranchRebaseMode rebaseMode) {
  181. checkCallable();
  182. pullRebaseMode = rebaseMode;
  183. return this;
  184. }
  185. /**
  186. * {@inheritDoc}
  187. * <p>
  188. * Execute the {@code Pull} command with all the options and parameters
  189. * collected by the setter methods (e.g.
  190. * {@link #setProgressMonitor(ProgressMonitor)}) of this class. Each
  191. * instance of this class should only be used for one invocation of the
  192. * command. Don't call this method twice on an instance.
  193. */
  194. @Override
  195. public PullResult call() throws GitAPIException,
  196. WrongRepositoryStateException, InvalidConfigurationException,
  197. InvalidRemoteException, CanceledException,
  198. RefNotFoundException, RefNotAdvertisedException, NoHeadException,
  199. org.eclipse.jgit.api.errors.TransportException {
  200. checkCallable();
  201. monitor.beginTask(JGitText.get().pullTaskName, 2);
  202. Config repoConfig = repo.getConfig();
  203. String branchName = null;
  204. try {
  205. String fullBranch = repo.getFullBranch();
  206. if (fullBranch != null
  207. && fullBranch.startsWith(Constants.R_HEADS)) {
  208. branchName = fullBranch.substring(Constants.R_HEADS.length());
  209. }
  210. } catch (IOException e) {
  211. throw new JGitInternalException(
  212. JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
  213. e);
  214. }
  215. if (remoteBranchName == null && branchName != null) {
  216. // get the name of the branch in the remote repository
  217. // stored in configuration key branch.<branch name>.merge
  218. remoteBranchName = repoConfig.getString(
  219. ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
  220. ConfigConstants.CONFIG_KEY_MERGE);
  221. }
  222. if (remoteBranchName == null) {
  223. remoteBranchName = branchName;
  224. }
  225. if (remoteBranchName == null) {
  226. throw new NoHeadException(
  227. JGitText.get().cannotCheckoutFromUnbornBranch);
  228. }
  229. if (!repo.getRepositoryState().equals(RepositoryState.SAFE))
  230. throw new WrongRepositoryStateException(MessageFormat.format(
  231. JGitText.get().cannotPullOnARepoWithState, repo
  232. .getRepositoryState().name()));
  233. if (remote == null && branchName != null) {
  234. // get the configured remote for the currently checked out branch
  235. // stored in configuration key branch.<branch name>.remote
  236. remote = repoConfig.getString(
  237. ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
  238. ConfigConstants.CONFIG_KEY_REMOTE);
  239. }
  240. if (remote == null) {
  241. // fall back to default remote
  242. remote = Constants.DEFAULT_REMOTE_NAME;
  243. }
  244. // determines whether rebase should be used after fetching
  245. if (pullRebaseMode == null && branchName != null) {
  246. pullRebaseMode = getRebaseMode(branchName, repoConfig);
  247. }
  248. final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
  249. String remoteUri;
  250. FetchResult fetchRes;
  251. if (isRemote) {
  252. remoteUri = repoConfig.getString(
  253. ConfigConstants.CONFIG_REMOTE_SECTION, remote,
  254. ConfigConstants.CONFIG_KEY_URL);
  255. if (remoteUri == null) {
  256. String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + DOT
  257. + remote + DOT + ConfigConstants.CONFIG_KEY_URL;
  258. throw new InvalidConfigurationException(MessageFormat.format(
  259. JGitText.get().missingConfigurationForKey, missingKey));
  260. }
  261. if (monitor.isCancelled())
  262. throw new CanceledException(MessageFormat.format(
  263. JGitText.get().operationCanceled,
  264. JGitText.get().pullTaskName));
  265. FetchCommand fetch = new FetchCommand(repo).setRemote(remote)
  266. .setProgressMonitor(monitor).setTagOpt(tagOption)
  267. .setRecurseSubmodules(submoduleRecurseMode);
  268. configure(fetch);
  269. fetchRes = fetch.call();
  270. } else {
  271. // we can skip the fetch altogether
  272. remoteUri = JGitText.get().localRepository;
  273. fetchRes = null;
  274. }
  275. monitor.update(1);
  276. if (monitor.isCancelled())
  277. throw new CanceledException(MessageFormat.format(
  278. JGitText.get().operationCanceled,
  279. JGitText.get().pullTaskName));
  280. // we check the updates to see which of the updated branches
  281. // corresponds
  282. // to the remote branch name
  283. AnyObjectId commitToMerge;
  284. if (isRemote) {
  285. Ref r = null;
  286. if (fetchRes != null) {
  287. r = fetchRes.getAdvertisedRef(remoteBranchName);
  288. if (r == null) {
  289. r = fetchRes.getAdvertisedRef(Constants.R_HEADS
  290. + remoteBranchName);
  291. }
  292. }
  293. if (r == null) {
  294. throw new RefNotAdvertisedException(MessageFormat.format(
  295. JGitText.get().couldNotGetAdvertisedRef, remote,
  296. remoteBranchName));
  297. }
  298. commitToMerge = r.getObjectId();
  299. } else {
  300. try {
  301. commitToMerge = repo.resolve(remoteBranchName);
  302. if (commitToMerge == null) {
  303. throw new RefNotFoundException(MessageFormat.format(
  304. JGitText.get().refNotResolved, remoteBranchName));
  305. }
  306. } catch (IOException e) {
  307. throw new JGitInternalException(
  308. JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
  309. e);
  310. }
  311. }
  312. String upstreamName = MessageFormat.format(
  313. JGitText.get().upstreamBranchName,
  314. Repository.shortenRefName(remoteBranchName), remoteUri);
  315. PullResult result;
  316. if (pullRebaseMode != BranchRebaseMode.NONE) {
  317. try {
  318. Ref head = repo.exactRef(Constants.HEAD);
  319. if (head == null) {
  320. throw new NoHeadException(JGitText
  321. .get().commitOnRepoWithoutHEADCurrentlyNotSupported);
  322. }
  323. ObjectId headId = head.getObjectId();
  324. if (headId == null) {
  325. // Pull on an unborn branch: checkout
  326. try (RevWalk revWalk = new RevWalk(repo)) {
  327. RevCommit srcCommit = revWalk
  328. .parseCommit(commitToMerge);
  329. DirCacheCheckout dco = new DirCacheCheckout(repo,
  330. repo.lockDirCache(), srcCommit.getTree());
  331. dco.setFailOnConflict(true);
  332. dco.setProgressMonitor(monitor);
  333. dco.checkout();
  334. RefUpdate refUpdate = repo
  335. .updateRef(head.getTarget().getName());
  336. refUpdate.setNewObjectId(commitToMerge);
  337. refUpdate.setExpectedOldObjectId(null);
  338. refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
  339. if (refUpdate.update() != Result.NEW) {
  340. throw new NoHeadException(JGitText
  341. .get().commitOnRepoWithoutHEADCurrentlyNotSupported);
  342. }
  343. monitor.endTask();
  344. return new PullResult(fetchRes, remote,
  345. RebaseResult.result(
  346. RebaseResult.Status.FAST_FORWARD,
  347. srcCommit));
  348. }
  349. }
  350. } catch (NoHeadException e) {
  351. throw e;
  352. } catch (IOException e) {
  353. throw new JGitInternalException(JGitText
  354. .get().exceptionCaughtDuringExecutionOfPullCommand, e);
  355. }
  356. RebaseCommand rebase = new RebaseCommand(repo);
  357. RebaseResult rebaseRes = rebase.setUpstream(commitToMerge)
  358. .setUpstreamName(upstreamName).setProgressMonitor(monitor)
  359. .setOperation(Operation.BEGIN).setStrategy(strategy)
  360. .setPreserveMerges(
  361. pullRebaseMode == BranchRebaseMode.PRESERVE)
  362. .call();
  363. result = new PullResult(fetchRes, remote, rebaseRes);
  364. } else {
  365. MergeCommand merge = new MergeCommand(repo);
  366. MergeResult mergeRes = merge.include(upstreamName, commitToMerge)
  367. .setStrategy(strategy).setProgressMonitor(monitor)
  368. .setFastForward(getFastForwardMode()).call();
  369. monitor.update(1);
  370. result = new PullResult(fetchRes, remote, mergeRes);
  371. }
  372. monitor.endTask();
  373. return result;
  374. }
  375. /**
  376. * The remote (uri or name) to be used for the pull operation. If no remote
  377. * is set, the branch's configuration will be used. If the branch
  378. * configuration is missing the default value of
  379. * <code>Constants.DEFAULT_REMOTE_NAME</code> will be used.
  380. *
  381. * @see Constants#DEFAULT_REMOTE_NAME
  382. * @param remote
  383. * name of the remote to pull from
  384. * @return {@code this}
  385. * @since 3.3
  386. */
  387. public PullCommand setRemote(String remote) {
  388. checkCallable();
  389. this.remote = remote;
  390. return this;
  391. }
  392. /**
  393. * The remote branch name to be used for the pull operation. If no
  394. * remoteBranchName is set, the branch's configuration will be used. If the
  395. * branch configuration is missing the remote branch with the same name as
  396. * the current branch is used.
  397. *
  398. * @param remoteBranchName
  399. * remote branch name to be used for pull operation
  400. * @return {@code this}
  401. * @since 3.3
  402. */
  403. public PullCommand setRemoteBranchName(String remoteBranchName) {
  404. checkCallable();
  405. this.remoteBranchName = remoteBranchName;
  406. return this;
  407. }
  408. /**
  409. * Get the remote name used for pull operation
  410. *
  411. * @return the remote used for the pull operation if it was set explicitly
  412. * @since 3.3
  413. */
  414. public String getRemote() {
  415. return remote;
  416. }
  417. /**
  418. * Get the remote branch name for the pull operation
  419. *
  420. * @return the remote branch name used for the pull operation if it was set
  421. * explicitly
  422. * @since 3.3
  423. */
  424. public String getRemoteBranchName() {
  425. return remoteBranchName;
  426. }
  427. /**
  428. * Set the @{code MergeStrategy}
  429. *
  430. * @param strategy
  431. * The merge strategy to use during this pull operation.
  432. * @return {@code this}
  433. * @since 3.4
  434. */
  435. public PullCommand setStrategy(MergeStrategy strategy) {
  436. this.strategy = strategy;
  437. return this;
  438. }
  439. /**
  440. * Set the specification of annotated tag behavior during fetch
  441. *
  442. * @param tagOpt
  443. * the {@link org.eclipse.jgit.transport.TagOpt}
  444. * @return {@code this}
  445. * @since 4.7
  446. */
  447. public PullCommand setTagOpt(TagOpt tagOpt) {
  448. checkCallable();
  449. this.tagOption = tagOpt;
  450. return this;
  451. }
  452. /**
  453. * Set the fast forward mode. It is used if pull is configured to do a merge
  454. * as opposed to rebase. If non-{@code null} takes precedence over the
  455. * fast-forward mode configured in git config.
  456. *
  457. * @param fastForwardMode
  458. * corresponds to the --ff/--no-ff/--ff-only options. If
  459. * {@code null} use the value of {@code pull.ff} configured in
  460. * git config. If {@code pull.ff} is not configured fall back to
  461. * the value of {@code merge.ff}. If {@code merge.ff} is not
  462. * configured --ff is the built-in default.
  463. * @return {@code this}
  464. * @since 4.9
  465. */
  466. public PullCommand setFastForward(
  467. @Nullable FastForwardMode fastForwardMode) {
  468. checkCallable();
  469. this.fastForwardMode = fastForwardMode;
  470. return this;
  471. }
  472. /**
  473. * Set the mode to be used for recursing into submodules.
  474. *
  475. * @param recurse
  476. * the
  477. * {@link org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode}
  478. * to be used for recursing into submodules
  479. * @return {@code this}
  480. * @since 4.7
  481. * @see FetchCommand#setRecurseSubmodules(FetchRecurseSubmodulesMode)
  482. */
  483. public PullCommand setRecurseSubmodules(
  484. @Nullable FetchRecurseSubmodulesMode recurse) {
  485. this.submoduleRecurseMode = recurse;
  486. return this;
  487. }
  488. /**
  489. * Reads the rebase mode to use for a pull command from the repository
  490. * configuration. This is the value defined for the configurations
  491. * {@code branch.[branchName].rebase}, or,if not set, {@code pull.rebase}.
  492. * If neither is set, yields
  493. * {@link org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode#NONE}.
  494. *
  495. * @param branchName
  496. * name of the local branch
  497. * @param config
  498. * the {@link org.eclipse.jgit.lib.Config} to read the value from
  499. * @return the {@link org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode}
  500. * @since 4.5
  501. */
  502. public static BranchRebaseMode getRebaseMode(String branchName,
  503. Config config) {
  504. BranchRebaseMode mode = config.getEnum(BranchRebaseMode.values(),
  505. ConfigConstants.CONFIG_BRANCH_SECTION,
  506. branchName, ConfigConstants.CONFIG_KEY_REBASE, null);
  507. if (mode == null) {
  508. mode = config.getEnum(BranchRebaseMode.values(),
  509. ConfigConstants.CONFIG_PULL_SECTION, null,
  510. ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
  511. }
  512. return mode;
  513. }
  514. private FastForwardMode getFastForwardMode() {
  515. if (fastForwardMode != null) {
  516. return fastForwardMode;
  517. }
  518. Config config = repo.getConfig();
  519. Merge ffMode = config.getEnum(Merge.values(),
  520. ConfigConstants.CONFIG_PULL_SECTION, null,
  521. ConfigConstants.CONFIG_KEY_FF, null);
  522. return ffMode != null ? FastForwardMode.valueOf(ffMode) : null;
  523. }
  524. }