@ -2127,12 +2127,16 @@ class TestGitCl(TestCase):
self . calls + = [
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://chromium.googlesource.com/my/repo ' ,
( ( [ ' git ' , ' fetch ' , ' https://chromium.googlesource.com/my/repo ' ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' reset ' , ' --hard ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
' ' ) ,
' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
' https://chromium-review.googlesource.com ' ] , ) , ' ' ) ,
' https://chromium-review.googlesource.com ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' rev-parse ' , ' FETCH_HEAD ' ] , ) , ' deadbeef ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.last-upload-hash ' , ' deadbeef ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritsquashhash ' , ' deadbeef ' ] , ) , ' ' ) ,
]
]
self . assertEqual ( git_cl . main ( [ ' patch ' , ' 123456 ' ] ) , 0 )
self . assertEqual ( git_cl . main ( [ ' patch ' , ' 123456 ' ] ) , 0 )
@ -2142,12 +2146,16 @@ class TestGitCl(TestCase):
self . calls + = [
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://host.googlesource.com/my/repo ' ,
( ( [ ' git ' , ' fetch ' , ' https://host.googlesource.com/my/repo ' ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' reset ' , ' --hard ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
' ' ) ,
' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
' https://host-review.googlesource.com ' ] , ) , ' ' ) ,
' https://host-review.googlesource.com ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' rev-parse ' , ' FETCH_HEAD ' ] , ) , ' deadbeef ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.last-upload-hash ' , ' deadbeef ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritsquashhash ' , ' deadbeef ' ] , ) , ' ' ) ,
]
]
self . assertEqual ( git_cl . main ( [ ' patch ' , ' --gerrit ' , ' 123456 ' ] ) , 0 )
self . assertEqual ( git_cl . main ( [ ' patch ' , ' --gerrit ' , ' 123456 ' ] ) , 0 )
@ -2159,13 +2167,17 @@ class TestGitCl(TestCase):
self . calls + = [
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://else.googlesource.com/my/repo ' ,
( ( [ ' git ' , ' fetch ' , ' https://else.googlesource.com/my/repo ' ,
' refs/changes/56/123456/1 ' ] , ) , ' ' ) ,
' refs/changes/56/123456/1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' reset ' , ' --hard ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' symbolic-ref ' , ' HEAD ' ] , ) , ' master ' ) ,
( ( [ ' git ' , ' symbolic-ref ' , ' HEAD ' ] , ) , ' master ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
' ' ) ,
' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
' https://else-review.googlesource.com ' ] , ) , ' ' ) ,
' https://else-review.googlesource.com ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' rev-parse ' , ' FETCH_HEAD ' ] , ) , ' deadbeef ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.last-upload-hash ' , ' deadbeef ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritsquashhash ' , ' deadbeef ' ] , ) , ' ' ) ,
]
]
self . assertEqual ( git_cl . main (
self . assertEqual ( git_cl . main (
[ ' patch ' , ' https://else-review.googlesource.com/#/c/123456/1 ' ] ) , 0 )
[ ' patch ' , ' https://else-review.googlesource.com/#/c/123456/1 ' ] ) , 0 )
@ -2178,28 +2190,57 @@ class TestGitCl(TestCase):
self . calls + = [
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://else.googlesource.com/my/repo ' ,
( ( [ ' git ' , ' fetch ' , ' https://else.googlesource.com/my/repo ' ,
' refs/changes/56/123456/1 ' ] , ) , ' ' ) ,
' refs/changes/56/123456/1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' reset ' , ' --hard ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' symbolic-ref ' , ' HEAD ' ] , ) , ' master ' ) ,
( ( [ ' git ' , ' symbolic-ref ' , ' HEAD ' ] , ) , ' master ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
' ' ) ,
' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
' https://else-review.googlesource.com ' ] , ) , ' ' ) ,
' https://else-review.googlesource.com ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 1 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' rev-parse ' , ' FETCH_HEAD ' ] , ) , ' deadbeef ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.last-upload-hash ' , ' deadbeef ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritsquashhash ' , ' deadbeef ' ] , ) , ' ' ) ,
]
]
self . assertEqual ( git_cl . main (
self . assertEqual ( git_cl . main (
[ ' patch ' , ' https://else-review.googlesource.com/123456/1 ' ] ) , 0 )
[ ' patch ' , ' https://else-review.googlesource.com/123456/1 ' ] ) , 0 )
def test_patch_gerrit_local_content ( self ) :
self . _patch_common ( default_codereview = ' gerrit ' , detect_gerrit_server = True ,
git_short_host = ' chromium ' )
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://chromium.googlesource.com/my/repo ' ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) ,
CERR1 ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' FETCH_HEAD ' ] , ) ,
CERR1 ) ,
( ( ' ask_for_data ' ,
' It looks like you \' re on a branch with some local commits. \n '
' If you apply this patch on top of your local content, you will not be '
' able to easily upload further changes based on it. \n '
' Would you like to proceed with applying this patch anyway? \n '
' Press Enter to confirm, or Ctrl+C to abort ' ) , ' y ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , ' ' ) ,
]
self . assertEqual ( git_cl . main ( [ ' patch ' , ' 123456 ' ] ) , 0 )
def test_patch_gerrit_conflict ( self ) :
def test_patch_gerrit_conflict ( self ) :
self . _patch_common ( default_codereview = ' gerrit ' , detect_gerrit_server = True ,
self . _patch_common ( default_codereview = ' gerrit ' , detect_gerrit_server = True ,
git_short_host = ' chromium ' )
git_short_host = ' chromium ' )
self . calls + = [
self . calls + = [
( ( [ ' git ' , ' fetch ' , ' https://chromium.googlesource.com/my/repo ' ,
( ( [ ' git ' , ' fetch ' , ' https://chromium.googlesource.com/my/repo ' ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
' refs/changes/56/123456/7 ' ] , ) , ' ' ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritissue ' , ' 123456 ' ] , ) ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' origin/master ' ] , ) ,
' ' ) ,
CERR1 ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritserver ' ,
( ( [ ' git ' , ' merge-base ' , ' --ancestor ' , ' HEAD ' , ' FETCH_HEAD ' ] , ) ,
' https://chromium-review.googlesource.com ' ] , ) , ' ' ) ,
CERR1 ) ,
( ( [ ' git ' , ' config ' , ' branch.master.gerritpatchset ' , ' 7 ' ] , ) , ' ' ) ,
( ( ' ask_for_data ' ,
' It looks like you \' re on a branch with some local commits. \n '
' If you apply this patch on top of your local content, you will not be '
' able to easily upload further changes based on it. \n '
' Would you like to proceed with applying this patch anyway? \n '
' Press Enter to confirm, or Ctrl+C to abort ' ) , ' y ' ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , CERR1 ) ,
( ( [ ' git ' , ' cherry-pick ' , ' FETCH_HEAD ' ] , ) , CERR1 ) ,
( ( [ ' DieWithError ' , ' Command " git cherry-pick FETCH_HEAD " failed. \n ' ] , ) ,
( ( [ ' DieWithError ' , ' Command " git cherry-pick FETCH_HEAD " failed. \n ' ] , ) ,
SystemExitMock ( ) ) ,
SystemExitMock ( ) ) ,