Remove '\' from multiline strings
Remove the '\' and have the logger functions automatically strip a leading newline to maintain formatting. Change-Id: I5f6b5fba4cacd27de33dab4e5a44ef4f2f9ac4e6
This commit is contained in:
@@ -114,7 +114,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
self.log.notice("Merging import to requested branch '%s'", args.branch)
|
self.log.notice("Merging import to requested branch '%s'", args.branch)
|
||||||
if import_upstream.finish():
|
if import_upstream.finish():
|
||||||
self.log.notice(
|
self.log.notice(
|
||||||
"""\
|
"""
|
||||||
Successfully finished import:
|
Successfully finished import:
|
||||||
target branch: '%s'
|
target branch: '%s'
|
||||||
upstream branch: '%s'
|
upstream branch: '%s'
|
||||||
@@ -156,7 +156,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
additional_commits = [prev_import_merge.parents[i]
|
additional_commits = [prev_import_merge.parents[i]
|
||||||
for i in idxs]
|
for i in idxs]
|
||||||
if additional_commits and len(args.branches) == 0:
|
if additional_commits and len(args.branches) == 0:
|
||||||
self.log.warning("""\
|
self.log.warning("""
|
||||||
**************** WARNING ****************
|
**************** WARNING ****************
|
||||||
Previous import merged additional branches but none
|
Previous import merged additional branches but none
|
||||||
have been specified on the command line for this
|
have been specified on the command line for this
|
||||||
@@ -166,7 +166,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
commit_list = [c.hexsha[:6] + " - " + c.summary[:60] +
|
commit_list = [c.hexsha[:6] + " - " + c.summary[:60] +
|
||||||
(c.summary[60:] and "...")
|
(c.summary[60:] and "...")
|
||||||
for c in list(strategy.filtered_iter())]
|
for c in list(strategy.filtered_iter())]
|
||||||
self.log.notice("""\
|
self.log.notice("""
|
||||||
Requested a dry-run: printing the list of commit that should be
|
Requested a dry-run: printing the list of commit that should be
|
||||||
rebased
|
rebased
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
|
|
||||||
if not args.merge:
|
if not args.merge:
|
||||||
self.log.notice(
|
self.log.notice(
|
||||||
"""\
|
"""
|
||||||
Import complete, not merging to target branch '%s' as
|
Import complete, not merging to target branch '%s' as
|
||||||
requested.
|
requested.
|
||||||
""", args.branch)
|
""", args.branch)
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
|
|
||||||
if str(self.repo.active_branch) == branch:
|
if str(self.repo.active_branch) == branch:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Resetting branch '%s' to specified commit '%s'
|
Resetting branch '%s' to specified commit '%s'
|
||||||
git reset --hard %s
|
git reset --hard %s
|
||||||
""", branch, commit, commit)
|
""", branch, commit, commit)
|
||||||
@@ -115,14 +115,14 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
checkout_opt = '-b'
|
checkout_opt = '-b'
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Checking out branch '%s' using specified commit '%s'
|
Checking out branch '%s' using specified commit '%s'
|
||||||
git checkout %s %s %s
|
git checkout %s %s %s
|
||||||
""", branch, commit, checkout_opt, branch, commit)
|
""", branch, commit, checkout_opt, branch, commit)
|
||||||
self.git.checkout(checkout_opt, branch, commit)
|
self.git.checkout(checkout_opt, branch, commit)
|
||||||
else:
|
else:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Creating branch '%s' from specified commit '%s'
|
Creating branch '%s' from specified commit '%s'
|
||||||
git branch --force %s %s
|
git branch --force %s %s
|
||||||
""", branch, commit, branch, commit)
|
""", branch, commit, branch, commit)
|
||||||
@@ -166,7 +166,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
self.log.warning("No tag describes the upstream branch")
|
self.log.warning("No tag describes the upstream branch")
|
||||||
describe_commit = self.git.describe(commit, always=True, tags=True)
|
describe_commit = self.git.describe(commit, always=True, tags=True)
|
||||||
|
|
||||||
self.log.info("""\
|
self.log.info("""
|
||||||
Using '%s' to describe:
|
Using '%s' to describe:
|
||||||
%s
|
%s
|
||||||
""", describe_commit, commit)
|
""", describe_commit, commit)
|
||||||
@@ -184,7 +184,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
"created from '%s' (%s)", base, self.upstream, commit)
|
"created from '%s' (%s)", base, self.upstream, commit)
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Checking if import branch '%s' already exists:
|
Checking if import branch '%s' already exists:
|
||||||
git branch --list %s
|
git branch --list %s
|
||||||
""", base, base)
|
""", base, base)
|
||||||
@@ -198,7 +198,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
|
|
||||||
if self.extra_branches:
|
if self.extra_branches:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Merging additional branch(es) '%s' into import branch '%s'
|
Merging additional branch(es) '%s' into import branch '%s'
|
||||||
git checkout %s
|
git checkout %s
|
||||||
git merge %s
|
git merge %s
|
||||||
@@ -243,7 +243,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
self._set_branch(branch, tip, force=True)
|
self._set_branch(branch, tip, force=True)
|
||||||
try:
|
try:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
git rebase -p --onto=%s \\
|
git rebase -p --onto=%s \\
|
||||||
%s %s
|
%s %s
|
||||||
""", previous, root, branch)
|
""", previous, root, branch)
|
||||||
@@ -264,7 +264,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Should apply the following list of commits
|
Should apply the following list of commits
|
||||||
%s
|
%s
|
||||||
""", "\n ".join([c.hexsha for c in commit_list]))
|
""", "\n ".join([c.hexsha for c in commit_list]))
|
||||||
@@ -273,7 +273,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
|
|
||||||
self._set_branch(self.import_branch, self.branch, force=True)
|
self._set_branch(self.import_branch, self.branch, force=True)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Creating import branch '%s' from specified commit '%s' in prep to
|
Creating import branch '%s' from specified commit '%s' in prep to
|
||||||
linearize the local changes before transposing to the new upstream:
|
linearize the local changes before transposing to the new upstream:
|
||||||
git branch --force %s %s
|
git branch --force %s %s
|
||||||
@@ -293,7 +293,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
# provided they don't mind that 'git rebase --abort' will result
|
# provided they don't mind that 'git rebase --abort' will result
|
||||||
# in a virtually useless local import branch
|
# in a virtually useless local import branch
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"""\
|
"""
|
||||||
|
|
||||||
Exception occurred during linearisation of local changes on to
|
Exception occurred during linearisation of local changes on to
|
||||||
previous import to simplify behaviour should user need to abort
|
previous import to simplify behaviour should user need to abort
|
||||||
@@ -312,7 +312,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
first = commit_list[0]
|
first = commit_list[0]
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Rebase changes, dropping merges through editor:
|
Rebase changes, dropping merges through editor:
|
||||||
git rebase --onto %s \\
|
git rebase --onto %s \\
|
||||||
%s %s
|
%s %s
|
||||||
@@ -361,24 +361,24 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Merging by inverting the 'ours' strategy discard all changes
|
Merging by inverting the 'ours' strategy discard all changes
|
||||||
and replace existing branch contents with the new import.
|
and replace existing branch contents with the new import.
|
||||||
""")
|
""")
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Merging import branch to HEAD and ignoring changes:
|
Merging import branch to HEAD and ignoring changes:
|
||||||
git merge -s ours --no-commit %s
|
git merge -s ours --no-commit %s
|
||||||
""", self.import_branch)
|
""", self.import_branch)
|
||||||
self.git.merge('-s', 'ours', self.import_branch, no_commit=True)
|
self.git.merge('-s', 'ours', self.import_branch, no_commit=True)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Replacing tree contents with those from the import branch:
|
Replacing tree contents with those from the import branch:
|
||||||
git read-tree -u --reset %s
|
git read-tree -u --reset %s
|
||||||
""", self.import_branch)
|
""", self.import_branch)
|
||||||
self.git.read_tree(self.import_branch, u=True, reset=True)
|
self.git.read_tree(self.import_branch, u=True, reset=True)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Committing merge commit:
|
Committing merge commit:
|
||||||
git commit --no-edit
|
git commit --no-edit
|
||||||
""")
|
""")
|
||||||
@@ -391,7 +391,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
"Resulting tree does not match import")
|
"Resulting tree does not match import")
|
||||||
except (GitCommandError, ImportUpstreamError):
|
except (GitCommandError, ImportUpstreamError):
|
||||||
self.log.error(
|
self.log.error(
|
||||||
"""\
|
"""
|
||||||
Failed to finish import by merging branch:
|
Failed to finish import by merging branch:
|
||||||
'%s'
|
'%s'
|
||||||
into and replacing the contents of:
|
into and replacing the contents of:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ REBASE_EDITOR_SCRIPT = "rebase-editor"
|
|||||||
# enable syntax highlighting
|
# enable syntax highlighting
|
||||||
REBASE_EDITOR_TODO = "git-upstream/git-rebase-todo"
|
REBASE_EDITOR_TODO = "git-upstream/git-rebase-todo"
|
||||||
|
|
||||||
TODO_EPILOGUE = """\
|
TODO_EPILOGUE = """
|
||||||
|
|
||||||
# Rebase %(shortrevisions)s onto %(shortonto)s
|
# Rebase %(shortrevisions)s onto %(shortonto)s
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Searcher(GitMixin):
|
|||||||
mergebase = self.git.merge_base(parent, self.commit,
|
mergebase = self.git.merge_base(parent, self.commit,
|
||||||
with_exceptions=False)
|
with_exceptions=False)
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
previous upstream: %s
|
previous upstream: %s
|
||||||
merge-base: %s
|
merge-base: %s
|
||||||
parent: %s
|
parent: %s
|
||||||
@@ -93,7 +93,7 @@ class Searcher(GitMixin):
|
|||||||
# branch with unrelated history that can be ignored
|
# branch with unrelated history that can be ignored
|
||||||
if not mergebase:
|
if not mergebase:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Found merge of additional branch:
|
Found merge of additional branch:
|
||||||
%s
|
%s
|
||||||
""", mergecommit)
|
""", mergecommit)
|
||||||
@@ -139,7 +139,7 @@ class Searcher(GitMixin):
|
|||||||
# the discarded parents as part of the set of changes to ignore in the
|
# the discarded parents as part of the set of changes to ignore in the
|
||||||
# final list.
|
# final list.
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Searching for previous merges that exclude one side of the history
|
Searching for previous merges that exclude one side of the history
|
||||||
since the last import.
|
since the last import.
|
||||||
git rev-list --ancestry-path --merges %s
|
git rev-list --ancestry-path --merges %s
|
||||||
@@ -159,7 +159,7 @@ class Searcher(GitMixin):
|
|||||||
|
|
||||||
if ignores:
|
if ignores:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Adding following to ignore list:
|
Adding following to ignore list:
|
||||||
%s
|
%s
|
||||||
""", "\n ".join(ignores))
|
""", "\n ".join(ignores))
|
||||||
@@ -167,7 +167,7 @@ class Searcher(GitMixin):
|
|||||||
|
|
||||||
if previous_import:
|
if previous_import:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Found the previous import merge:
|
Found the previous import merge:
|
||||||
%s
|
%s
|
||||||
""", mergecommit)
|
""", mergecommit)
|
||||||
@@ -189,7 +189,7 @@ class Searcher(GitMixin):
|
|||||||
# commit found by find() and head of the branch to provide a list of
|
# commit found by find() and head of the branch to provide a list of
|
||||||
# commits to the caller
|
# commits to the caller
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Walking the changes between found commit and target, excluding
|
Walking the changes between found commit and target, excluding
|
||||||
those behind the previous import or merged as an additional branch
|
those behind the previous import or merged as an additional branch
|
||||||
during the previous import
|
during the previous import
|
||||||
@@ -208,7 +208,7 @@ class Searcher(GitMixin):
|
|||||||
commits = list(commit_list)
|
commits = list(commit_list)
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
commits found:
|
commits found:
|
||||||
%s
|
%s
|
||||||
""", ("\n" + " " * 4).join([c.hexsha for c in commits]))
|
""", ("\n" + " " * 4).join([c.hexsha for c in commits]))
|
||||||
@@ -303,7 +303,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
|
|||||||
rev_list_args = self.git.for_each_ref(
|
rev_list_args = self.git.for_each_ref(
|
||||||
*self._references, format="%(refname:short)").splitlines()
|
*self._references, format="%(refname:short)").splitlines()
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Upstream refs:
|
Upstream refs:
|
||||||
%s
|
%s
|
||||||
""", "\n ".join(rev_list_args)
|
""", "\n ".join(rev_list_args)
|
||||||
@@ -312,7 +312,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
|
|||||||
# get the sha1 for the tip of each of the upstream refs we are going to
|
# get the sha1 for the tip of each of the upstream refs we are going to
|
||||||
# search
|
# search
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Construct list of upstream revs to search:
|
Construct list of upstream revs to search:
|
||||||
git rev-list --min-parents=1 --no-walk \\
|
git rev-list --min-parents=1 --no-walk \\
|
||||||
%s
|
%s
|
||||||
@@ -343,7 +343,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
|
|||||||
rev_list_args.append("--not")
|
rev_list_args.append("--not")
|
||||||
rev_list_args.extend(prune_list)
|
rev_list_args.extend(prune_list)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Retrieve minimal list of revs to check with merge-base by excluding
|
Retrieve minimal list of revs to check with merge-base by excluding
|
||||||
revisions that are in the reachable from others in the list:
|
revisions that are in the reachable from others in the list:
|
||||||
git rev-list \\
|
git rev-list \\
|
||||||
@@ -356,7 +356,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
|
|||||||
# portion of the tree for each call. If the constructed graph was
|
# portion of the tree for each call. If the constructed graph was
|
||||||
# retained betweens we could likely remove much of the code above.
|
# retained betweens we could likely remove much of the code above.
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Running merge-base against each found upstream revision and target
|
Running merge-base against each found upstream revision and target
|
||||||
git merge-base %s ${upstream_rev}
|
git merge-base %s ${upstream_rev}
|
||||||
""", self.branch)
|
""", self.branch)
|
||||||
@@ -373,7 +373,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
|
|||||||
"is no common ancestor for the involved branches")
|
"is no common ancestor for the involved branches")
|
||||||
else:
|
else:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Order the possible merge-base commits in descendent order, to
|
Order the possible merge-base commits in descendent order, to
|
||||||
find the most recent one used irrespective of date:
|
find the most recent one used irrespective of date:
|
||||||
git rev-list --topo-order --max-count=1 --no-walk \\
|
git rev-list --topo-order --max-count=1 --no-walk \\
|
||||||
@@ -521,7 +521,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
def filter(self, commit_iter):
|
def filter(self, commit_iter):
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Filtering out all commits marked with a Superseded-by Change-Id
|
Filtering out all commits marked with a Superseded-by Change-Id
|
||||||
which is present in '%s'
|
which is present in '%s'
|
||||||
""", self.search_ref)
|
""", self.search_ref)
|
||||||
@@ -564,7 +564,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
# present in upstream
|
# present in upstream
|
||||||
if superseding_change_ids:
|
if superseding_change_ids:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Including commit '%s %s'
|
Including commit '%s %s'
|
||||||
because the following superseding change-ids have not been
|
because the following superseding change-ids have not been
|
||||||
found:
|
found:
|
||||||
@@ -575,7 +575,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Filtering out commit '%s %s'
|
Filtering out commit '%s %s'
|
||||||
because it has been marked as superseded by the following
|
because it has been marked as superseded by the following
|
||||||
note:
|
note:
|
||||||
@@ -696,7 +696,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
def filter(self, commit_iter):
|
def filter(self, commit_iter):
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""
|
||||||
Filtering out all commits that have a Change-Id that matches one
|
Filtering out all commits that have a Change-Id that matches one
|
||||||
found in the given search ref: %s
|
found in the given search ref: %s
|
||||||
""", self.search_ref)
|
""", self.search_ref)
|
||||||
@@ -706,7 +706,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
# if there is no change_id to compare against, return the commit
|
# if there is no change_id to compare against, return the commit
|
||||||
if not change_id:
|
if not change_id:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Including change missing 'Change-Id'
|
Including change missing 'Change-Id'
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
Message: %s
|
Message: %s
|
||||||
@@ -731,7 +731,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
|
|
||||||
if duplicate_change_id and duplicate_change_id == change_id:
|
if duplicate_change_id and duplicate_change_id == change_id:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Skipping duplicate Change-Id in search ref
|
Skipping duplicate Change-Id in search ref
|
||||||
%s
|
%s
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
@@ -741,7 +741,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
|||||||
|
|
||||||
# no match in the search ref, so include commit
|
# no match in the search ref, so include commit
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""\
|
"""
|
||||||
Including unmatched change
|
Including unmatched change
|
||||||
%s
|
%s
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
|
|||||||
@@ -126,13 +126,13 @@ class DedentLoggerMeta(type):
|
|||||||
def _dedent_log(self, level, msg, *args, **kwargs):
|
def _dedent_log(self, level, msg, *args, **kwargs):
|
||||||
dedent = kwargs.pop('dedent', True)
|
dedent = kwargs.pop('dedent', True)
|
||||||
if dedent:
|
if dedent:
|
||||||
msg = textwrap.dedent(msg)
|
msg = textwrap.dedent(msg.lstrip('\n'))
|
||||||
func(self, level, msg, *args, **kwargs)
|
func(self, level, msg, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
def _dedent_log(self, msg, *args, **kwargs):
|
def _dedent_log(self, msg, *args, **kwargs):
|
||||||
dedent = kwargs.pop('dedent', True)
|
dedent = kwargs.pop('dedent', True)
|
||||||
if dedent:
|
if dedent:
|
||||||
msg = textwrap.dedent(msg)
|
msg = textwrap.dedent(msg.lstrip('\n'))
|
||||||
func(self, msg, *args, **kwargs)
|
func(self, msg, *args, **kwargs)
|
||||||
return wraps(func)(_dedent_log)
|
return wraps(func)(_dedent_log)
|
||||||
return dedentlog
|
return dedentlog
|
||||||
|
|||||||
Reference in New Issue
Block a user