p4cmd 2.5.0__tar.gz → 2.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {p4cmd-2.5.0 → p4cmd-2.6.0}/PKG-INFO +1 -1
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/__init__.py +1 -1
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/p4cmd.py +115 -2
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd.egg-info/PKG-INFO +1 -1
- {p4cmd-2.5.0 → p4cmd-2.6.0}/LICENSE +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/README.md +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/p4errors.py +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/p4file.py +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/__init__.py +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_DEPOT_ONLY.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_MOVED.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_NEED_SYNC.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_OPEN_FOR_ADD.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_OPEN_FOR_DELETE.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_OPEN_FOR_EDIT.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_UNKNOWN.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_UNTRACKED.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/resources/perforce_UP_TO_DATE.png +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd/utils.py +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd.egg-info/SOURCES.txt +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd.egg-info/dependency_links.txt +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/p4cmd.egg-info/top_level.txt +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/setup.cfg +0 -0
- {p4cmd-2.5.0 → p4cmd-2.6.0}/setup.py +0 -0
|
@@ -51,6 +51,8 @@ class P4Client(object):
|
|
|
51
51
|
self.server = self.get_p4_setting("P4PORT")
|
|
52
52
|
if self.server is None:
|
|
53
53
|
raise p4errors.WorkSpaceError("Could not find P4PORT")
|
|
54
|
+
|
|
55
|
+
self.depot_root = self.get_depot_paths([self.perforce_root])[0]
|
|
54
56
|
|
|
55
57
|
@classmethod
|
|
56
58
|
def from_env(cls, *args, **kwargs):
|
|
@@ -594,6 +596,117 @@ class P4Client(object):
|
|
|
594
596
|
|
|
595
597
|
return files_and_cl
|
|
596
598
|
|
|
599
|
+
@validate_not_empty
|
|
600
|
+
def shelve_files(self, changelist, file_list=None, revert_after_shelve=False, force=False):
|
|
601
|
+
"""
|
|
602
|
+
Shelves files in a changelist. If no files are specified, shelves all files in the changelist.
|
|
603
|
+
|
|
604
|
+
:param changelist: *string* or *int* changelist number or description
|
|
605
|
+
:param file_list: *list* or *None* list of files to shelve. If None, shelves all files in the changelist
|
|
606
|
+
:param revert_after_shelve: *bool* if True, reverts the files after shelving them
|
|
607
|
+
:param force: *bool* if True, forces the shelving operation even if files are already shelved
|
|
608
|
+
:return: *list* of info dictionaries
|
|
609
|
+
"""
|
|
610
|
+
changelist = self.__ensure_changelist(changelist)
|
|
611
|
+
|
|
612
|
+
# if no files specified, get all files in the changelist
|
|
613
|
+
if file_list is None:
|
|
614
|
+
file_list = self.get_files_in_changelist(changelist)
|
|
615
|
+
else:
|
|
616
|
+
file_list = convert_to_list(file_list) if not isinstance(file_list, list) else file_list
|
|
617
|
+
if not self.silent:
|
|
618
|
+
self.__validate_file_list(file_list)
|
|
619
|
+
|
|
620
|
+
# if there are no files to shelve, return empty list
|
|
621
|
+
if not file_list:
|
|
622
|
+
if not self.silent:
|
|
623
|
+
logging.warning(f"No files to shelve in changelist {changelist}")
|
|
624
|
+
return []
|
|
625
|
+
|
|
626
|
+
# iuild args list based on options
|
|
627
|
+
args = ["-c", str(changelist)]
|
|
628
|
+
if force:
|
|
629
|
+
args.append("-f")
|
|
630
|
+
|
|
631
|
+
# run the shelve command
|
|
632
|
+
info_dicts = self.run_cmd("shelve", args=args, file_list=file_list)
|
|
633
|
+
|
|
634
|
+
for info_dict in info_dicts:
|
|
635
|
+
if self.__get_dict_value(info_dict, "code") == "error" and not self.silent:
|
|
636
|
+
logging.error(self.__get_dict_value(info_dict, "data"))
|
|
637
|
+
|
|
638
|
+
# revert files if requested
|
|
639
|
+
if revert_after_shelve and file_list:
|
|
640
|
+
revert_info_dicts = self.revert_files(file_list)
|
|
641
|
+
# add revert info to the return data
|
|
642
|
+
info_dicts.extend(revert_info_dicts)
|
|
643
|
+
|
|
644
|
+
return info_dicts
|
|
645
|
+
|
|
646
|
+
def unshelve_files(self, changelist, file_list=None, target_changelist="default", force=False, delete_shelved_files=False):
|
|
647
|
+
"""
|
|
648
|
+
Unshelves files from a shelved changelist. If no files are specified, unshelves all files.
|
|
649
|
+
|
|
650
|
+
:param changelist: *string* or *int* source changelist number containing shelved files
|
|
651
|
+
:param file_list: *list* or *None* list of files to unshelve. If None, unshelves all files
|
|
652
|
+
:param target_changelist: *string* or *int* target changelist to unshelve files into
|
|
653
|
+
:param force: *bool* if True, forces the unshelve operation even if files are already opened
|
|
654
|
+
:param delete_shelved_files: *bool* if True, deletes the shelved files after unshelving them
|
|
655
|
+
:return: *list* of info dictionaries
|
|
656
|
+
"""
|
|
657
|
+
source_changelist = self.__ensure_changelist(changelist)
|
|
658
|
+
target_changelist = self.__ensure_changelist(target_changelist)
|
|
659
|
+
|
|
660
|
+
# build the arguments list
|
|
661
|
+
args = []
|
|
662
|
+
|
|
663
|
+
# add force flag if requested
|
|
664
|
+
if force:
|
|
665
|
+
args.append("-f")
|
|
666
|
+
|
|
667
|
+
# add source changelist (required)
|
|
668
|
+
args.extend(["-s", str(source_changelist)])
|
|
669
|
+
|
|
670
|
+
# add target changelist if specified and not default
|
|
671
|
+
if target_changelist != "default":
|
|
672
|
+
args.extend(["-c", str(target_changelist)])
|
|
673
|
+
|
|
674
|
+
# prepare file list if provided
|
|
675
|
+
if file_list is not None:
|
|
676
|
+
file_list = convert_to_list(file_list) if not isinstance(file_list, list) else file_list
|
|
677
|
+
if not self.silent:
|
|
678
|
+
self.__validate_file_list(file_list)
|
|
679
|
+
else:
|
|
680
|
+
file_list = []
|
|
681
|
+
|
|
682
|
+
# run the unshelve command
|
|
683
|
+
info_dicts = self.run_cmd("unshelve", args=args, file_list=file_list)
|
|
684
|
+
|
|
685
|
+
# check for errors in the unshelve operation
|
|
686
|
+
has_error = False
|
|
687
|
+
for info_dict in info_dicts:
|
|
688
|
+
if self.__get_dict_value(info_dict, "code") == "error" and not self.silent:
|
|
689
|
+
logging.error(self.__get_dict_value(info_dict, "data"))
|
|
690
|
+
has_error = True
|
|
691
|
+
|
|
692
|
+
# delete shelved files if requested and unshelve was successful
|
|
693
|
+
if delete_shelved_files and not has_error:
|
|
694
|
+
# build the arguments for the shelve -d command
|
|
695
|
+
delete_args = ["-d", "-c", str(source_changelist)]
|
|
696
|
+
|
|
697
|
+
# if file_list provided, use it for the delete operation as well
|
|
698
|
+
delete_info_dicts = self.run_cmd("shelve", args=delete_args, file_list=file_list)
|
|
699
|
+
|
|
700
|
+
# check for errors in the delete operation
|
|
701
|
+
for info_dict in delete_info_dicts:
|
|
702
|
+
if self.__get_dict_value(info_dict, "code") == "error" and not self.silent:
|
|
703
|
+
logging.error(self.__get_dict_value(info_dict, "data"))
|
|
704
|
+
|
|
705
|
+
# add the delete info to the return data
|
|
706
|
+
info_dicts.extend(delete_info_dicts)
|
|
707
|
+
|
|
708
|
+
return info_dicts
|
|
709
|
+
|
|
597
710
|
@validate_not_empty
|
|
598
711
|
def add_or_edit_folders(self, folders, include_subfolders=True, changelist="default"):
|
|
599
712
|
"""
|
|
@@ -1039,6 +1152,6 @@ class P4Client(object):
|
|
|
1039
1152
|
# Easy utility to check that the file is underneath the correct perforce root
|
|
1040
1153
|
# Quicker than waiting for the result of a p4 fstat
|
|
1041
1154
|
for f in file_list:
|
|
1042
|
-
if not f.lower().startswith(self.perforce_root.lower()):
|
|
1043
|
-
raise Exception(f'{f} is not under perforce root: {self.perforce_root}')
|
|
1155
|
+
if not f.lower().startswith(self.perforce_root.lower()) and not f.lower().startswith(self.depot_root.lower()):
|
|
1156
|
+
raise Exception(f'{f} is not under perforce root: {self.perforce_root}, {self.depot_root}')
|
|
1044
1157
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|