示例#1
0
    def test_ExtractSettingsNoNote(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.Popen(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                             stdin=subprocess.PIPE)
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text
''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            #popen = subprocess.Popen(shlex.split("git rev-parse refs/remotes/p4/master"), stdout=subprocess.PIPE)
            #val = popen.communicate()[0]
            #if popen.returncode:
            #    die('Extracting revision failed')
            #rev = val.strip()

            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertFalse(settings.has_key("depot-paths"))
        finally:
            shutil.rmtree(tempdir, True)
示例#2
0
    def test_ExtractSettingsNoNote(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.Popen(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                         stdin=subprocess.PIPE);
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text
''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            #popen = subprocess.Popen(shlex.split("git rev-parse refs/remotes/p4/master"), stdout=subprocess.PIPE)
            #val = popen.communicate()[0]
            #if popen.returncode:
            #    die('Extracting revision failed')
            #rev = val.strip()
            
            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertFalse(settings.has_key("depot-paths"))
        finally:
            shutil.rmtree(tempdir,  True)
示例#3
0
    def test_ExtractSettingsFromNoteWithExtraNote(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.Popen(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                             stdin=subprocess.PIPE)
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text

commit refs/notes/git-p4
mark :2
committer <*****@*****.**> 1289238991 +0100
data 21
Note added by git-p4
N inline :1
data <<EOT
[depot-paths = "//depot/": change = 33255]
EOT

commit refs/notes/commits
mark :3
committer <*****@*****.**> 1289238991 +0100
data 11
Manual note
N inline :1
data <<EOT
This is a manually added note
EOT
''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            popen = subprocess.Popen(
                shlex.split("git rev-parse refs/remotes/p4/master"),
                stdout=subprocess.PIPE)
            val = popen.communicate()[0]
            if popen.returncode:
                die('Extracting revision failed')
            rev = val.strip()

            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertEqual(['//depot/'], settings['depot-paths'])
            self.assertEqual(33255, int(settings['change']))
        finally:
            shutil.rmtree(tempdir, True)
示例#4
0
    def test_ExtractSettingsFromNoteWithExtraNote(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.Popen(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                         stdin=subprocess.PIPE);
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text

commit refs/notes/git-p4
mark :2
committer <*****@*****.**> 1289238991 +0100
data 21
Note added by git-p4
N inline :1
data <<EOT
[depot-paths = "//depot/": change = 33255]
EOT

commit refs/notes/commits
mark :3
committer <*****@*****.**> 1289238991 +0100
data 11
Manual note
N inline :1
data <<EOT
This is a manually added note
EOT
''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            popen = subprocess.Popen(shlex.split("git rev-parse refs/remotes/p4/master"), stdout=subprocess.PIPE)
            val = popen.communicate()[0]
            if popen.returncode:
                die('Extracting revision failed')
            rev = val.strip()
            
            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertEqual(['//depot/'], settings['depot-paths'])
            self.assertEqual(33255, int(settings['change']))
        finally:
            shutil.rmtree(tempdir,  True)
示例#5
0
    def test_SyncWithExistingRepo(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.call(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                             stdin=subprocess.PIPE)
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text

commit refs/notes/git-p4
mark :2
committer <*****@*****.**> 1289238991 +0100
data 21
Note added by git-p4
N inline :1
data <<EOT
[depot-paths = "//depot/": change = 33255]
EOT

''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            details = {
                'status': 'submitted',
                'code': 'stat',
                'depotFile0': '//depot/file2.py',
                'action0': 'add',
                'fileSize0': '110958',
                'options': '',
                'client': 'someclient',
                'user': '******',
                'time': '1289238991',
                'rev0': '10',
                'desc': 'Test\n',
                'type0': 'text',
                'change': '33256',
                'digest0': 'BDA001AC8DE4B3B0484FE8252FEE73E8'
            }
            users = [{
                'code': 'stat',
                'Update': '1179412893',
                'Access': '1179413508',
                'User': '******',
                'FullName': 'Firstname Lastname',
                'Email': '*****@*****.**'
            }]

            files = [{
                'action': 'add',
                'path': '//depot/file2.py',
                'rev': '1',
                'type': 'text'
            }]
            branch = 'refs/remotes/p4/master'
            branchPrefixes = ['//depot/']
            sync = P4Sync()
            sync.p4 = P4HelperDouble(['33256'], {
                'describe 33256': details,
                'users': users
            })
            sync.p4FileReader = P4FileReaderDouble

            # Execute method
            sync.run([])

            # verify results
            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertEqual(['//depot/'], settings['depot-paths'])
            self.assertEqual(33256, int(settings['change']))

        finally:
            shutil.rmtree(tempdir, True)
示例#6
0
    def test_SyncWithExistingRepo(self):
        tempdir = tempfile.mkdtemp()
        os.chdir(tempdir)

        try:
            # fast-import git repo
            subprocess.call(["git", "init", "--quiet"])
            importProcess = subprocess.Popen(["git", "fast-import", "--quiet"],
                                         stdin=subprocess.PIPE);
            importProcess.stdin.write('''commit refs/remotes/p4/master
mark :1
committer <*****@*****.**> 1289238991 +0100
data <<EOT
Test

EOT

M 644 inline file.py
data 9
some text

commit refs/notes/git-p4
mark :2
committer <*****@*****.**> 1289238991 +0100
data 21
Note added by git-p4
N inline :1
data <<EOT
[depot-paths = "//depot/": change = 33255]
EOT

''')
            importProcess.stdin.close()
            if importProcess.wait() != 0:
                die("fast-import failed")

            details = {'status': 'submitted', 
                'code': 'stat', 
                'depotFile0': '//depot/file2.py', 
                'action0': 'add', 
                'fileSize0': '110958', 
                'options': '', 
                'client': 'someclient', 
                'user': '******', 
                'time': '1289238991', 
                'rev0': '10', 
                'desc': 'Test\n', 
                'type0': 'text', 
                'change': '33256', 
                'digest0': 'BDA001AC8DE4B3B0484FE8252FEE73E8'}
            users = [{'code': 'stat', 'Update': '1179412893', 'Access': '1179413508', 
                     'User': '******', 'FullName': 'Firstname Lastname', 'Email': '*****@*****.**'}]

            files = [{'action': 'add', 'path': '//depot/file2.py', 'rev': '1', 'type': 'text'}]
            branch = 'refs/remotes/p4/master'
            branchPrefixes = ['//depot/']
            sync = P4Sync()
            sync.p4 = P4HelperDouble(['33256'], {'describe 33256': details, 'users': users })
            sync.p4FileReader = P4FileReaderDouble
            
            # Execute method
            sync.run([])
            
            # verify results
            settings = extractSettingsFromNotes('refs/remotes/p4/master')
            self.assertEqual(['//depot/'], settings['depot-paths'])
            self.assertEqual(33256, int(settings['change']))

        finally:
            shutil.rmtree(tempdir,  True)