Delete local bookmarks that haven't been touched in 7 days

断了今生、忘了曾经 提交于 2019-12-08 05:06:07

问题


How should I clean up all the local bookmarks that hasn't been touched recently (say in the past 7 days)? Using

hg bookmark -d <bookmark name> 

seems unscalable.


回答1:


To my knowledge there is no information as to when a bookmark was updated to last or when it was created; you can only obtain the information of the age of the commits they are attached to easily, e.g.

hg log -r "bookmark() and date('-1000')"
hg log -r "bookmark() and date('<01/30/2015')"

for all bookmarks attached to commits created in the last 1000 days or all bookmarks attached to commits older than January 30th 2015.

EDIT to add: There is the Journal Extension. It allows to actually track when and to which revisions a bookmark was attached to. Thus you might want to enable this extension if you want to solve your problem for the future.




回答2:


hg bookmark -d can take multiple arguments, so combining with the answer above you can do:

hg bookmark -d `hg log -r "bookmark() and date('-1000')" -T '{bookmarks} '`

I use this to remove all public bookmarks, since I only use them locally:

hg bookmark -d `hg log -r "bookmark() and public()" -T '{bookmarks} '`


来源:https://stackoverflow.com/questions/43242014/delete-local-bookmarks-that-havent-been-touched-in-7-days

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!