aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Williams <pwil3058@gmail.com>2010-05-24 14:37:00 -0700
committerRuss Cox <rsc@golang.org>2010-05-24 14:37:00 -0700
commit1d6eb7469791f1b112a0e36721ef1a59878d82cb (patch)
tree7faacc792ea3fcddbb98c8b01b7666a57d03c9d5
parente30bf71b6c87435ab720865dea3ae04526091bcb (diff)
downloadgo-1d6eb7469791f1b112a0e36721ef1a59878d82cb.tar.gz
go-1d6eb7469791f1b112a0e36721ef1a59878d82cb.zip
codereview: work better with mq
R=rsc CC=golang-dev https://golang.org/cl/1140043
-rw-r--r--lib/codereview/codereview.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index 9af28cfdaa..4b1797a7f0 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -533,11 +533,18 @@ _change_prolog = """# Change list.
#######################################################################
# Mercurial helper functions
+# Get effective change nodes taking into account applied MQ patches
+def effective_revpair(repo):
+ try:
+ return cmdutil.revpair(repo, ['qparent'])
+ except:
+ return cmdutil.revpair(repo, None)
+
# Return list of changed files in repository that match pats.
def ChangedFiles(ui, repo, pats, opts):
# Find list of files being operated on.
matcher = cmdutil.match(repo, pats, opts)
- node1, node2 = cmdutil.revpair(repo, None)
+ node1, node2 = effective_revpair(repo)
modified, added, removed = repo.status(node1, node2, matcher)[:3]
l = modified + added + removed
l.sort()
@@ -546,7 +553,7 @@ def ChangedFiles(ui, repo, pats, opts):
# Return list of changed files in repository that match pats and still exist.
def ChangedExistingFiles(ui, repo, pats, opts):
matcher = cmdutil.match(repo, pats, opts)
- node1, node2 = cmdutil.revpair(repo, None)
+ node1, node2 = effective_revpair(repo)
modified, added, _ = repo.status(node1, node2, matcher)[:3]
l = modified + added
l.sort()
@@ -2828,8 +2835,11 @@ class MercurialVCS(VersionControlSystem):
if self.options.revision:
self.base_rev = self.options.revision
else:
- self.base_rev = RunShell(["hg", "parent", "-q"]).split(':')[1].strip()
-
+ mqparent, err = RunShellWithReturnCode(['hg', 'log', '--rev', 'qparent', '--template={node}'])
+ if not err:
+ self.base_rev = mqparent
+ else:
+ self.base_rev = RunShell(["hg", "parent", "-q"]).split(':')[1].strip()
def _GetRelPath(self, filename):
"""Get relative path of a file according to the current directory,
given its logical path in the repo."""