From 8b93139cac64225a56887ae5740cf74b3acecf24 Mon Sep 17 00:00:00 2001 From: trowbrds Date: Mon, 27 Jul 2009 03:40:44 +0000 Subject: A variety of hgsubversion improvements Corrected hgsubversion support for more recent versions of hgsubversion and add support for parent branch, guess summary, and guess description. Patch from Augie Fackler. Testing done: Been using it for over a week, haven't seen any major issues. Reviewed at http://reviews.review-board.org/r/842/ --- rbtools/postreview.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/rbtools/postreview.py b/rbtools/postreview.py index d5cda25..a9c44be 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -1796,10 +1796,29 @@ class MercurialClient(SCMClient): """ Performs a diff across all modified files in a Mercurial repository. """ - # We don't support parent diffs with Mercurial yet, so return None - # for the parent diff. + # We don't support parent diffs with Mercurial yet, so we always + # return None for the parent diff. if self.type == 'svn': - return (execute(["hg", "svn", "diff", ]), None) + parent = execute(['hg', 'parent', '--svn', '--template', + '{node}\n']).strip() + + if options.parent_branch: + parent = options.parent_branch + + if options.guess_summary and not options.summary: + options.summary = execute(['hg', 'log', '-r.', '--template', + r'{desc|firstline}\n']) + + 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() + + return (execute(["hg", "diff", "--svn", '-r%s:.' % parent]), None) return (execute(["hg", "diff"] + files), None) @@ -2295,12 +2314,13 @@ def parse_options(args): parser.add_option("--guess-summary", dest="guess_summary", action="store_true", default=False, - help="guess summary from the latest commit (git only)") + help="guess summary from the latest commit (git/" + "hgsubversion only)") parser.add_option("--guess-description", dest="guess_description", action="store_true", default=False, help="guess description based on commits on this branch " - "(git only)") + "(git/hgsubversion only)") parser.add_option("--testing-done", dest="testing_done", default=None, help="details of testing done ") -- cgit v1.2.3