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:
Darragh Bailey
2015-12-18 21:10:44 +00:00
parent c13695d82b
commit 126feca10d
5 changed files with 42 additions and 42 deletions

View File

@@ -114,7 +114,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
self.log.notice("Merging import to requested branch '%s'", args.branch)
if import_upstream.finish():
self.log.notice(
"""\
"""
Successfully finished import:
target branch: '%s'
upstream branch: '%s'
@@ -156,7 +156,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
additional_commits = [prev_import_merge.parents[i]
for i in idxs]
if additional_commits and len(args.branches) == 0:
self.log.warning("""\
self.log.warning("""
**************** WARNING ****************
Previous import merged additional branches but none
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] +
(c.summary[60:] and "...")
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
rebased
@@ -189,7 +189,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
if not args.merge:
self.log.notice(
"""\
"""
Import complete, not merging to target branch '%s' as
requested.
""", args.branch)

View File

@@ -103,7 +103,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
if str(self.repo.active_branch) == branch:
self.log.info(
"""\
"""
Resetting branch '%s' to specified commit '%s'
git reset --hard %s
""", branch, commit, commit)
@@ -115,14 +115,14 @@ class ImportUpstream(LogDedentMixin, GitMixin):
checkout_opt = '-b'
self.log.info(
"""\
"""
Checking out branch '%s' using specified commit '%s'
git checkout %s %s %s
""", branch, commit, checkout_opt, branch, commit)
self.git.checkout(checkout_opt, branch, commit)
else:
self.log.info(
"""\
"""
Creating branch '%s' from specified commit '%s'
git branch --force %s %s
""", branch, commit, branch, commit)
@@ -166,7 +166,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
self.log.warning("No tag describes the upstream branch")
describe_commit = self.git.describe(commit, always=True, tags=True)
self.log.info("""\
self.log.info("""
Using '%s' to describe:
%s
""", describe_commit, commit)
@@ -184,7 +184,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
"created from '%s' (%s)", base, self.upstream, commit)
self.log.info(
"""\
"""
Checking if import branch '%s' already exists:
git branch --list %s
""", base, base)
@@ -198,7 +198,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
if self.extra_branches:
self.log.info(
"""\
"""
Merging additional branch(es) '%s' into import branch '%s'
git checkout %s
git merge %s
@@ -243,7 +243,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
self._set_branch(branch, tip, force=True)
try:
self.log.debug(
"""\
"""
git rebase -p --onto=%s \\
%s %s
""", previous, root, branch)
@@ -264,7 +264,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
return False
self.log.debug(
"""\
"""
Should apply the following list of commits
%s
""", "\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.log.info(
"""\
"""
Creating import branch '%s' from specified commit '%s' in prep to
linearize the local changes before transposing to the new upstream:
git branch --force %s %s
@@ -293,7 +293,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
# provided they don't mind that 'git rebase --abort' will result
# in a virtually useless local import branch
self.log.warning(
"""\
"""
Exception occurred during linearisation of local changes on to
previous import to simplify behaviour should user need to abort
@@ -312,7 +312,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
first = commit_list[0]
self.log.info(
"""\
"""
Rebase changes, dropping merges through editor:
git rebase --onto %s \\
%s %s
@@ -361,24 +361,24 @@ class ImportUpstream(LogDedentMixin, GitMixin):
try:
self.log.info(
"""\
"""
Merging by inverting the 'ours' strategy discard all changes
and replace existing branch contents with the new import.
""")
self.log.info(
"""\
"""
Merging import branch to HEAD and ignoring changes:
git merge -s ours --no-commit %s
""", self.import_branch)
self.git.merge('-s', 'ours', self.import_branch, no_commit=True)
self.log.info(
"""\
"""
Replacing tree contents with those from the import branch:
git read-tree -u --reset %s
""", self.import_branch)
self.git.read_tree(self.import_branch, u=True, reset=True)
self.log.info(
"""\
"""
Committing merge commit:
git commit --no-edit
""")
@@ -391,7 +391,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
"Resulting tree does not match import")
except (GitCommandError, ImportUpstreamError):
self.log.error(
"""\
"""
Failed to finish import by merging branch:
'%s'
into and replacing the contents of:

View File

@@ -28,7 +28,7 @@ REBASE_EDITOR_SCRIPT = "rebase-editor"
# enable syntax highlighting
REBASE_EDITOR_TODO = "git-upstream/git-rebase-todo"
TODO_EPILOGUE = """\
TODO_EPILOGUE = """
# Rebase %(shortrevisions)s onto %(shortonto)s
#

View File

@@ -83,7 +83,7 @@ class Searcher(GitMixin):
mergebase = self.git.merge_base(parent, self.commit,
with_exceptions=False)
self.log.debug(
"""\
"""
previous upstream: %s
merge-base: %s
parent: %s
@@ -93,7 +93,7 @@ class Searcher(GitMixin):
# branch with unrelated history that can be ignored
if not mergebase:
self.log.info(
"""\
"""
Found merge of additional branch:
%s
""", mergecommit)
@@ -139,7 +139,7 @@ class Searcher(GitMixin):
# the discarded parents as part of the set of changes to ignore in the
# final list.
self.log.debug(
"""\
"""
Searching for previous merges that exclude one side of the history
since the last import.
git rev-list --ancestry-path --merges %s
@@ -159,7 +159,7 @@ class Searcher(GitMixin):
if ignores:
self.log.debug(
"""\
"""
Adding following to ignore list:
%s
""", "\n ".join(ignores))
@@ -167,7 +167,7 @@ class Searcher(GitMixin):
if previous_import:
self.log.info(
"""\
"""
Found the previous import merge:
%s
""", mergecommit)
@@ -189,7 +189,7 @@ class Searcher(GitMixin):
# commit found by find() and head of the branch to provide a list of
# commits to the caller
self.log.info(
"""\
"""
Walking the changes between found commit and target, excluding
those behind the previous import or merged as an additional branch
during the previous import
@@ -208,7 +208,7 @@ class Searcher(GitMixin):
commits = list(commit_list)
self.log.debug(
"""\
"""
commits found:
%s
""", ("\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(
*self._references, format="%(refname:short)").splitlines()
self.log.info(
"""\
"""
Upstream refs:
%s
""", "\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
# search
self.log.info(
"""\
"""
Construct list of upstream revs to search:
git rev-list --min-parents=1 --no-walk \\
%s
@@ -343,7 +343,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
rev_list_args.append("--not")
rev_list_args.extend(prune_list)
self.log.info(
"""\
"""
Retrieve minimal list of revs to check with merge-base by excluding
revisions that are in the reachable from others in the list:
git rev-list \\
@@ -356,7 +356,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
# portion of the tree for each call. If the constructed graph was
# retained betweens we could likely remove much of the code above.
self.log.info(
"""\
"""
Running merge-base against each found upstream revision and target
git merge-base %s ${upstream_rev}
""", self.branch)
@@ -373,7 +373,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
"is no common ancestor for the involved branches")
else:
self.log.info(
"""\
"""
Order the possible merge-base commits in descendent order, to
find the most recent one used irrespective of date:
git rev-list --topo-order --max-count=1 --no-walk \\
@@ -521,7 +521,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
def filter(self, commit_iter):
self.log.info(
"""\
"""
Filtering out all commits marked with a Superseded-by Change-Id
which is present in '%s'
""", self.search_ref)
@@ -564,7 +564,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
# present in upstream
if superseding_change_ids:
self.log.debug(
"""\
"""
Including commit '%s %s'
because the following superseding change-ids have not been
found:
@@ -575,7 +575,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
continue
self.log.debug(
"""\
"""
Filtering out commit '%s %s'
because it has been marked as superseded by the following
note:
@@ -696,7 +696,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
def filter(self, commit_iter):
self.log.info(
"""\
"""
Filtering out all commits that have a Change-Id that matches one
found in the given search ref: %s
""", 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 not change_id:
self.log.debug(
"""\
"""
Including change missing 'Change-Id'
Commit: %s %s
Message: %s
@@ -731,7 +731,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
if duplicate_change_id and duplicate_change_id == change_id:
self.log.debug(
"""\
"""
Skipping duplicate Change-Id in search ref
%s
Commit: %s %s
@@ -741,7 +741,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
# no match in the search ref, so include commit
self.log.debug(
"""\
"""
Including unmatched change
%s
Commit: %s %s

View File

@@ -126,13 +126,13 @@ class DedentLoggerMeta(type):
def _dedent_log(self, level, msg, *args, **kwargs):
dedent = kwargs.pop('dedent', True)
if dedent:
msg = textwrap.dedent(msg)
msg = textwrap.dedent(msg.lstrip('\n'))
func(self, level, msg, *args, **kwargs)
else:
def _dedent_log(self, msg, *args, **kwargs):
dedent = kwargs.pop('dedent', True)
if dedent:
msg = textwrap.dedent(msg)
msg = textwrap.dedent(msg.lstrip('\n'))
func(self, msg, *args, **kwargs)
return wraps(func)(_dedent_log)
return dedentlog