import os from P4 import P4, P4Exception class P4ForTest(object): def __init__(self): self._init_p4() def _init_p4(self): self.p4 = P4() def create_client(self, client_name, client_workdir): self.p4client_name = client_name self.client_workdir = client_workdir self.p4.client = client_name self.p4.cwd = client_workdir try: self.p4.connect() client = self.p4.fetch_client(self.p4client_name) client['Root'] = self.client_workdir client['Host'] = '' client['Options'] = client['Options'].replace('normdir', 'rmdir') self.p4.save_client(client) finally: self.p4.disconnect() def destroy_client(self): try: self.p4.connect() self.p4.delete_client('-f', self.p4client_name) finally: self.p4.disconnect() def get_user(self): return self.p4.user def sync(self): orig_dir = os.getcwdu() os.chdir(self.client_workdir) try: self.p4.run_sync() except P4Exception, e: if self.p4.warnings != ['No such file(s).']: raise finally: os.chdir(orig_dir) def add_file(self, file_path, file_contents): orig_dir = os.getcwdu() os.chdir(self.client_workdir) # Adds a file to Perforce. try: f = open(file_path, 'w') f.write(file_contents) f.flush() self.p4.run_add(file_path) finally: f.close() os.chdir(orig_dir) def submit(self, change_description): orig_dir = os.getcwdu() os.chdir(self.client_workdir) try: self.p4.run_submit('-d', change_description, '...') finally: os.chdir(orig_dir)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#11 | 7400 | Matt McClure |
p4-fast-export emits `from` fast-import commands. Flush the output stream before exiting. Fixes a bug I observed where the output stream ended prematurely when called from `bzr fast-export-from-p4`. |
||
#10 | 7356 | Matt McClure | Uses rsh P4PORT so that there's no need to explicitly start and stop a p4d server for the tests. | ||
#9 | 7092 | Matt McClure |
Converts all source files to UNIX line endings. bzr: revno 88.2.25, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sat 2008-12-27 14:36:39 -0500 |
||
#8 | 7043 | Matt McClure |
Merges changes from doc branch. bzr: revno 79, part 2 of 2 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sat 2008-11-15 12:35:42 -0500 |
||
#7 | 7038 | Matt McClure |
Adds a brief user guide. bzr: revno 77.1.1, part 3 of 3 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Fri 2008-11-14 09:58:48 -0500 |
||
#6 | 7027 | Matt McClure |
Generalizes the Perforce user in TestP4FastExport. bzr: revno 69.2.22, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Fri 2008-11-14 01:42:20 -0500 |
||
#5 | 6964 | Matt McClure |
I can run the tests from any working directory now. bzr: revno 64, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sat 2008-08-09 08:59:35 -0400 |
||
#4 | 6952 | Matt McClure |
The teardown works better in cases where the client workspace has pending stuff. bzr: revno 53, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sat 2008-08-02 11:23:35 -0400 |
||
#3 | 6944 | Matt McClure |
Refactors: removes method _get_p4. bzr: revno 45, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sun 2008-07-20 09:45:11 -0400 |
||
#2 | 6943 | Matt McClure |
Mid-refactoring. Moves and renames methods. bzr: revno 44, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sun 2008-07-20 09:24:54 -0400 |
||
#1 | 6942 | Matt McClure |
Mid-refactoring... bzr: revno 43, part 1 of 1 bzr: author Matt McClure <mlm@aya.yale.edu> bzr: committed Sun 2008-07-20 09:10:16 -0400 |