perforce clean empty directory

(1)

bing    perforce clean empty directory

(2)

Deleting empty folders

https://forums.perforce.com/index.php?/topic/2016-deleting-empty-folders/

Originally posted to the perforce-user mailing list by: Mahesh Penugonda


Hi,
          May I know how to delete empty folders from perforce repository? Is there a way doing it?

Regards
Mahesh

<PRE><font size="2" face="calibri" color="blue">The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.If you are not the intended recipient of this message please do not read, copy, use or disclose this communication and notify the sender immediately.It should be noted that any review, retransmission, dissemination or other use of, or taking action or reliance upon, this information by persons or entities other than the intended recipient is prohibited.</PRE>

Folders don't really exist in the Perforce repository. A folder exists
only if there are file inside of it. You remove a folder in the
repository by removing all files in that folder.

However, when a folder is removed in the repository, it is not always
removed in the client workspace. The workspace spec has an option
"rmdir/normdir" that defaults to "normdir". If you change it to "rmdir"
it will remove folders from the workspace when all files in them are
removed.
 

(3)

Deleting Empty Directories

https://community.perforce.com/s/article/3416

Perforce Helix p4d deleting empty client workspace directories. The default option normdir will leave empty workspace directories intact. Using p4 delete, or when you p4 sync to deleted or nonexistent revisions (including #0 or #none).

How do I make Perforce delete empty client workspace directories?

 

Set the rmdir option in your workspace specification to indicate that client workspace directories should be deleted after you run a command that leaves them empty. The default option normdir will leave empty workspace directories intact.

Perforce removes files from your client workspace directories when you use p4 delete, or when you p4 sync to deleted or nonexistent revisions (including #0 or #none).

NOTE:  It is by design that you have to have "rmdir" option ON before sync, so when you "unsync" the files the directory(s) also gets removed.

 

Windows Junctions

Warning: The workspace specification option "rmdir" unmaps directory junction maps on Windows!

 

Some Windows users make use of a type of hidden symlinking called Junctions. In the Windows 2000 Server Resource Kit, for example, there is a utility called linkd.exe, and at the SysInternals Website, at http://technet.microsoft.com/en-us/library/hh206089.aspx, there is a utility called junction.exe which can create special NTFS symlinks similar to UNIX-style symlinks. These are not just Windows shortcuts; these are actual symlinks.

Unfortunately, attempting to delete a directory which is junction-mapped will unmount or break the junction. Therefore, using the rmdir option in your workspace specification could suddenly make a whole directory seemingly disappear.

Pre-99.2 releases

On Perforce 99.2 or earlier, if you want to remove unneeded, empty workspace directories, you must do so manually.

  • On UNIX, to remove all empty workspace directories (and only the empty directories) you can run the following command from the root of your workspace:
    find . -type d -depth -print | xargs rmdir
    
  • On Windows, to see if a directory structure is empty, highlight the directory using Explorer and select Files > Properties from the menu. In the MS-DOS shell, you can tell if a directory structure is empty by running:
    dir /s dirname     

(4)

Adding Empty Directories

https://community.perforce.com/s/article/3447

How to add empty directory structures to Perforce, including a technique to allow "empty" structures to be synced.

Solution

Perforce does not store directories - directories are simply components of the filespec which uniquely identify each file. In order to create an empty directory or structure of empty directories, you need to "anchor" those directories using a place-holder file. The place-holder file is added to Perforce, and then deleted, creating a deleted revision that anchors the directory.

Using this technique creates a directory that appears when selecting "Show Deleted Depot Files" in the P4V filters menu.

Note: Using p4 obliterate to remove the place-holder file removes the directory as well. Use p4 delete instead.

The following examples show how to create a directory named "Empty".

If you would like users to be able to sync the directory structure to their workspace, the "place-holder" file should not be deleted. In this case, you might want to make it a "read-me" file noting the files placeholder status, and skip the step deleting that file.

Using P4V

  1. Select a workspace whose view includes the area of the depot in which you wish to create directories.

 

  • Create the new directory by right-clicking (in your system's file tree) on the folder where you want to create the directory, and selecting menu item "New Folder...".  When prompted, enter the directory name: Empty.

 

  • Open a text editor of your choice and create a new file in the Empty directory named ".place-holder". Using a "." in front of the name makes this a hidden file on Linux, Unix, or Mac operating Systems, though it remains visible in Windows workspaces. The file can be empty, it just has to be present.

 

  • In P4V, right-click on the .place-holder file (if it is not visible, right-click on Empty and select the Refresh Empty menu-item) and select "Mark for Add". Right-click on .place-holder again and select "Submit...".  A submit dialog opens, enter something in the description (such as "Create Empty") and click on "Submit".

 

  • Now click on the Depot tab. In the depot, you see the Empty directory and the . place-holder file it contains. Right-click on .place-holder, and select "Mark for Delete". Right-click it again and select "Submit...".  A submit dialog opens, enter something in the description and click on "Submit".

 

  • If you do not see the directory in P4V, confirm that "Show Deleted Files" is selected from the "Filter Depot" menu at the top of the depot tree. 

Using the Command Line

The following commands reproduce the procedure described above. Issue these commands from the directory where you wish to create the new directory.

 

mkdir Empty
cd Empty
vi .place-holder (on Windows, try "notepad .place-holder")
p4 add .place-holder
p4 submit -d "Create Empty"
p4 delete .place-holder

p4 submit -d "Create Empty"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值