diff options
author | Christian Hammond <chipx86@chipx86.com> | 2010-01-12 01:34:17 -0800 |
---|---|---|
committer | Christian Hammond <chipx86@chipx86.com> | 2010-01-12 01:34:17 -0800 |
commit | 595d137d564bd553c00d25f2be39ceaa262f4f1d (patch) | |
tree | 63912f8cf1e9c81691ac2ecf04eb26ad7d3ac283 | |
parent | e271ad61336f7cf3fde21a0e728ef0a8fc3c9e8f (diff) |
Provide --guess-description and --guess-summary for Mercurial revision ranges.
This implements support for --guess-description and --guess-summary with
revision ranges in Mercurial. The commit messages are concatenated to form
the description, and the first line of the first commit message forms the
summary.
Patch by Stefan Ring
Reviewed at http://reviews.reviewboard.org/r/1333/
-rw-r--r-- | AUTHORS | 1 | ||||
-rwxr-xr-x | rbtools/postreview.py | 38 |
2 files changed, 30 insertions, 9 deletions
@@ -22,4 +22,5 @@ Contributors: * Ravi Kondamuru * Ryan Oblak * Stacey Sheldon + * Stefan Ring * Steven Russell diff --git a/rbtools/postreview.py b/rbtools/postreview.py index 4c38333..9b422c4 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -1900,6 +1900,26 @@ class MercurialClient(SCMClient): return RepositoryInfo(path=path, base_path='', supports_parent_diffs=True) + def extract_summary(self, revision): + """ + Extracts the first line from the description of the given changeset. + """ + return execute(['hg', 'log', '-r%s' % revision, '--template', + r'{desc|firstline}\n']) + + def extract_description(self, rev1, rev2): + """ + Extracts all descriptions in the given revision range and concatenates + them, most recent ones going first. + """ + numrevs = len(execute(['hg', 'log', '-r%s:%s' % (rev2, rev1), + '--follow', '--template', + r'{rev}\n']).strip().split('\n')) + return execute(['hg', 'log', '-r%s:%s' % (rev2, rev1), + '--follow', '--template', + r'{desc}\n\n', '--limit', + str(numrevs - 1)]).strip() + def diff(self, files): """ Performs a diff across all modified files in a Mercurial repository. @@ -1914,17 +1934,10 @@ class MercurialClient(SCMClient): parent = options.parent_branch if options.guess_summary and not options.summary: - options.summary = execute(['hg', 'log', '-r.', '--template', - r'{desc|firstline}\n']) + options.summary = self.extract_summary(".") if options.guess_description and not options.description: - numrevs = len(execute(['hg', 'log', '-r.:%s' % parent, - '--follow', '--template', - r'{rev}\n']).strip().split('\n')) - options.description = execute(['hg', 'log', '-r.:%s' % parent, - '--follow', '--template', - r'{desc}\n\n', '--limit', - str(numrevs-1)]).strip() + options.description = self.extract_description(parent, ".") return (execute(["hg", "diff", "--svn", '-r%s:.' % parent]), None) @@ -1938,6 +1951,13 @@ class MercurialClient(SCMClient): raise NotImplementedError r1, r2 = revision_range.split(':') + + if options.guess_summary and not options.summary: + options.summary = self.extract_summary(r2) + + if options.guess_description and not options.description: + options.description = self.extract_description(r1, r2) + return execute(["hg", "diff", "-r", r1, "-r", r2]) |