sapling/phrevset.py

241 lines
7.4 KiB
Python
Raw Normal View History

[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
# phrevset.py - support for Phabricator revsets
#
# Copyright 2013 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""provides support for Phabricator revsets
Allows for queries such as `hg log -r D1234567` to find the commit which
corresponds to a specific Differential revision.
Automatically handles commits already in subversion, or whose hash has
changed since submitting to Differential (due to amends or rebasing).
Requires arcanist to be installed and properly configured.
Repositories should include a callsign in their hgrc.
Example for www:
[phrevset]
callsign = E
"""
from mercurial import hg
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
from mercurial import extensions
from mercurial import revset
from mercurial import error
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
from mercurial import util as hgutil
from hgsubversion import util as svnutil
import os
import signal
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
import json
import re
import subprocess
DIFFERENTIAL_REGEX = re.compile(
'Differential Revision: http.+?/' # Line start, URL
'D(?P<id>[0-9]+)', # Differential ID, just numeric part
flags = re.LOCALE
)
DESCRIPTION_REGEX = re.compile(
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
'Commit r' # Prefix
'(?P<callsign>[A-Z]{1,})' # Callsign
'(?P<id>[a-f0-9]+)', # rev
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
flags = re.LOCALE
)
def getdiff(repo, diffid):
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
"""Perform a Conduit API call by shelling out to `arc`
Returns a subprocess.Popen instance"""
try:
proc = subprocess.Popen(['arc', 'call-conduit', 'differential.getdiff'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, preexec_fn=os.setsid)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
input = json.dumps({'revision_id': diffid})
repo.ui.debug("[diffrev] echo '%s' | arc call-conduit differential.getdiff\n" %
input)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
proc.stdin.write(input)
proc.stdin.close()
return proc
except Exception, e:
raise error.Abort('Could not not call "arc call-conduit": %s' % e)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
def finddiff(repo, diffid, proc=None):
"""Scans the changelog for commit lines mentioning the Differential ID
If the optional proc paramater is provided, it must be a subprocess.Popen
instance. It will be polled during the iteration and if it indicates that
the process has returned, the function will raise StopIteration"""
repo.ui.debug('[diffrev] Traversing log for %s\n' % diffid)
# traverse the changelog backwards
for rev in repo.changelog.revs(start=len(repo.changelog), stop=0):
if rev % 100 == 0 and proc and proc.poll() is not None:
raise StopIteration("Parallel proc call completed")
changectx = repo[rev]
desc = changectx.description()
match = DIFFERENTIAL_REGEX.search(desc)
if match and match.group('id') == diffid:
return changectx.rev()
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
return None
def forksearch(repo, diffid):
"""Perform a log traversal and Conduit call in parallel
Returns a (revision, arc_response) tuple, where one of the items will be
None, depending on which process terminated first"""
repo.ui.debug('[diffrev] Starting Conduit call\n')
proc = getdiff(repo, diffid)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
try:
repo.ui.debug('[diffrev] Starting log walk\n')
rev = finddiff(repo, diffid, proc)
repo.ui.debug('[diffrev] Parallel log walk completed with %s\n' % rev)
os.killpg(proc.pid, signal.SIGTERM)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
if rev is None:
# walked the entire repo and couldn't find the diff
return ([], None)
return ([rev], None)
except StopIteration:
# search terminated because arc returned
# if returncode == 0, return arc's output
repo.ui.debug('[diffrev] Conduit call returned %i\n' % proc.returncode)
if proc.returncode != 0:
raise error.Abort('arc call returned status %i' % proc.returncode)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
resp = proc.stdout.read()
return (None, resp)
def parsedesc(repo, resp):
desc = resp['description']
match = DESCRIPTION_REGEX.match(desc)
if not match:
raise error.Abort("Cannot parse Conduit description '%s'"
% desc)
callsign = match.group('callsign')
repo_callsign = repo.ui.config('phrevset', 'callsign')
if callsign != repo_callsign:
raise error.Abort("Diff callsign '%s' is different from repo"
" callsign '%s'" % (callsign, repo_callsign))
return match.group('id')
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
def revsetdiff(repo, subset, diffid):
"""Return a set of revisions corresponding to a given Differential ID """
rev, resp = forksearch(repo, diffid)
if rev is not None:
# The log walk found the diff, nothing more to do
return rev
jsresp = json.loads(resp)
if not jsresp:
raise error.Abort('Could not decode Conduit response')
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
resp = jsresp.get('response')
if not resp:
error = jsresp.get('errorMessage', 'unknown error')
raise error.Abort('Counduit error: %s' % error)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
vcs = resp.get('sourceControlSystem')
repo.ui.debug('[diffrev] VCS is %s\n' % vcs)
if vcs == 'svn':
# commit has landed in svn, parse the description to get the SVN
# revision and delegate to hgsubversion for the rest
svnrev = parsedesc(repo, resp)
repo.ui.debug("[diffrev] SVN rev is r%s\n" % svnrev)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
args = ('string', svnrev)
return svnutil.revset_svnrev(repo, subset, args)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
elif vcs == 'git':
gitrev = parsedesc(repo, resp)
repo.ui.debug("[diffrev] GIT rev is %s\n" % gitrev)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
peerpath = repo.ui.expandpath('default')
remoterepo = hg.peer(repo, {}, peerpath)
remoterev = remoterepo.lookup('_gitlookup_git_%s' % gitrev)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
repo.ui.debug("[diffrev] HG rev is %s\n" % remoterev.encode('hex'))
if not remoterev:
repo.ui.debug('[diffrev] Falling back to linear search\n')
return finddiff(repo, diffid)
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
return [repo[remoterev].rev()]
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
elif vcs == 'hg':
# commit is still in hg, get its hash
props = resp['properties']
commits = props['local:commits']
# the JSON parser returns Unicode strings, convert to `str` in UTF-8
revs = [c['commit'].encode('utf-8') for c in commits.values()]
# verify all revisions exist in the current repo; if not, try to
# find their counterpart by parsing the log
for idx, rev in enumerate(revs):
if rev not in repo:
parsed_rev = finddiff(repo, diffid)
if not parsed_rev:
raise error.Abort('Could not find diff '
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
'D%s in changelog' % diffid)
revs[idx] = parsed_rev
return set(revs)
else:
if not vcs:
msg = "D%s does not have an associated version control system\n" \
"You can view the diff at http://phabricator.fb.com/D%s\n\n"
repo.ui.warn(msg % (diffid, diffid))
return []
else:
raise error.Abort('Conduit returned unknown '
[hg] Add support for Differential revsets Summary: Add the ability to issue commands like hg log -r D12345 Supports already shipped commits (by parsing the SVN rev number and delegating to hgsubversion), as well as mercurial commits in various states Test Plan: Easier to show than tell: [delyank@dev1436 ~/www] arc feature test_diff_revset [delyank@dev1436 ~/www] echo "Don't commit me" > dontcommit.test [delyank@dev1436 ~/www] hg add dontcommit.test [delyank@dev1436 ~/www] hg commit -m "[test] Test commit" [delyank@dev1436 ~/www] arc diff [...] Created a new Differential revision: Revision URI: https://phabricator.fb.com/D1055569 [...] [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg changeset: 587735:82d4de66e17bb3b92fe15df4eda8b8420b7ed074 bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] echo "No, really, don't" >> dontcommit.test [delyank@dev1436 ~/www] hg amend # change local hash [delyank@dev1436 ~/www] hg log --debug -r D1055569 [diffrev] Getting diff from Conduit..done [diffrev] VCS is hg [diffrev] Traversing log for 1055569 changeset: 587735:48565d21a43f730aa3b9cebccbb47fa406df557b bookmark: test_diff_revset tag: tip phase: draft [...] description: [test] Playing with conduit, don't commit [...] Differential Revision: https://phabricator.fb.com/D1055569 [delyank@dev1436 ~/www] hg log --debug -r D1053132 # a diff that's already been shipped [diffrev] Getting diff from Conduit..done [diffrev] VCS is svn changeset: 586857:61a4036e89bafefaba4de2ebe1190db999a8915d [...] description: [hashtagbot] Add the #filetask hashtag to Task Creeper [...] Differential Revision: https://phabricator.fb.com/D1053132 Reviewers: sid0, davidsp Reviewed By: davidsp CC: jhunt, davidsp Differential Revision: https://phabricator.fb.com/D1055637 Task ID: 3159944
2013-11-16 02:55:42 +04:00
'sourceControlSystem "%s"' % vcs)
def revsetstringset(orig, repo, subset, revstr):
"""Wrapper that recognizes revisions starting with 'D'"""
if revstr.startswith('D') and revstr[1:].isdigit():
return revsetdiff(repo, subset, revstr[1:])
return orig(repo, subset, revstr)
def extsetup(ui):
extensions.wrapfunction(revset, 'stringset', revsetstringset)
revset.symbols['stringset'] = revset.stringset
revset.methods['string'] = revset.stringset
revset.methods['symbol'] = revset.stringset