问题
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