From 9f3db2cc482912183f0b1f0b313eea035b6345d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Thu, 23 Jan 2020 09:47:55 +0100 Subject: [PATCH] handling base revision not found using master instead --- scripts/phabtalk/apply_patch2.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/phabtalk/apply_patch2.py b/scripts/phabtalk/apply_patch2.py index e5c20f4..211f596 100755 --- a/scripts/phabtalk/apply_patch2.py +++ b/scripts/phabtalk/apply_patch2.py @@ -21,7 +21,7 @@ import sys from typing import List, Optional, Tuple from phabricator import Phabricator -from git import Repo +from git import Repo, GitCommandError class ApplyPatch: """Apply a diff from Phabricator on local working copy. @@ -76,7 +76,12 @@ class ApplyPatch: try: revision_id, dependencies, base_revision = self._get_dependencies() print('Checking out {}...'.format(base_revision)) - self.repo.git.checkout(base_revision) + try: + self.repo.git.checkout(base_revision) + except GitCommandError: + print('ERROR checking out revision {}. It`s not in the ' + 'repository. Using master instead.'.format(base_revision)) + self.repo.git.checkout('master') print('Revision is {}'.format(self.repo.head.commit.hexsha)) print('git reset, git cleanup...') self.repo.git.reset('--hard')