How to purge a single checkin of the current branch in fossil?

萝らか妹 提交于 2021-02-08 02:33:29

问题


I am using fossil for some kind of incremential backup database. So far it works very well, except purging old entries. As this is all automated and meant to be simple all checkins/rollbacks work on the trunk.

Now I tried to add the option to purge old checkins, but I am not able to, always running into the error message:

cannot purge the current checkout

Perhaps I am using purge in a wrong way, though i wasn't able to find how to do it correctly. Currently i add a tag to the checkins i want to remove, and try to purge them which doesn't work. Removing the trunk tag from those checkins makes no difference. Running purge while my local repository is closed is not possible as fossil requires the vvar table for this operation.

I did an example to illustrate:

D:\_tmp\repo>fossil init test
project-id: d16c0c72d95305884776f5c6e4d440ec687511a3
server-id:  1de96e7234a3e2b6561a31ad0cb9d55243be0bdb
admin-user: usr (initial password is "9dd6fb")

D:\_tmp\repo>fossil open test
project-name: <unnamed>
repository:   D:/_tmp/repo/test
local-root:   D:/_tmp/repo/
config-db:    C:/Users/usr/AppData/Local/_fossil
project-code: d16c0c72d95305884776f5c6e4d440ec687511a3
checkout:     48edad6b8a3a946ad92b96bc41a2911ee709d6b5 2015-08-20 12:54:17 UTC
leaf:         open
tags:         trunk
comment:      initial empty check-in (user: usr)
check-ins:    1

D:\_tmp\repo>fossil addremove
ADDED  closedpurge.txt
added 1 files, deleted 0 files

D:\_tmp\repo>fossil commit -m auto
./closedpurge.txt contains CR/NL line endings. Use --no-warnings or the "crnl-gl
ob" setting to disable this warning.
Commit anyhow (a=all/c=convert/y/N)? a
New_Version: 3ffebd89c0d7e8ac92a21f3a0085568c39e113ea

D:\_tmp\repo>fossil addremove
DELETED  closedpurge.txt
added 0 files, deleted 1 files

D:\_tmp\repo>fossil commit -m auto
New_Version: be0ac15264616ce86f0fce0b8a2de05c80ea3e0b

D:\_tmp\repo>fossil timeline
=== 2015-08-20 ===
12:55:05 [be0ac15264] *CURRENT* auto (user: usr tags: trunk)
12:54:47 [3ffebd89c0] auto (user: usr tags: trunk)
12:54:17 [48edad6b8a] initial empty check-in (user: usr tags: trunk)
+++ no more data (3) +++

D:\_tmp\repo>fossil tag add topurge 3ffebd89c0

D:\_tmp\repo>fossil timeline
=== 2015-08-20 ===
12:56:37 [98c3a4f991] Edit [3ffebd89c0d7e8ac|3ffebd89c0]: Add tag "topurge".
         (user: usr)
12:55:05 [be0ac15264] *CURRENT* auto (user: usr tags: trunk)
12:54:47 [3ffebd89c0] auto (user: usr tags: trunk, topurge)
12:54:17 [48edad6b8a] initial empty check-in (user: usr tags: trunk)
+++ no more data (4) +++

D:\_tmp\repo>fossil purge topurge
cannot purge the current checkout

D:\_tmp\repo>fossil tag cancel trunk 3ffebd89c0

D:\_tmp\repo>fossil timeline
=== 2015-08-20 ===
12:57:30 [21885761c2] Edit [3ffebd89c0d7e8ac|3ffebd89c0]: Cancel tag "trunk".
         (user: usr)
12:56:37 [98c3a4f991] Edit [3ffebd89c0d7e8ac|3ffebd89c0]: Add tag "topurge".
         (user: usr)
12:55:05 [be0ac15264] *CURRENT* auto (user: usr)
12:54:47 [3ffebd89c0] auto (user: usr tags: topurge)
12:54:17 [48edad6b8a] initial empty check-in (user: usr tags: trunk)
+++ no more data (5) +++

D:\_tmp\repo>fossil purge topurge
cannot purge the current checkout

D:\_tmp\repo>fossil close

D:\_tmp\repo>fossil purge topurge -R test
SQLITE_ERROR: no such table: vvar
fossil: no such table: vvar
SELECT value FROM vvar WHERE name='checkout'

All i did was initializing a new fossil repository; add a single file and commit; rmeove the file and commit again; and try to purge the check in which added the file.

Edit: I tested this using fossil version 1.32 and 1.33


回答1:


The error message appears to say it all, really: you can't purge the current checkout (which is the checkin marked as *CURRENT* in the timeline), or one of its descendants. From the help for the purge command (emphasis mine):

Move the check-ins identified by TAGS and all of their descendants out of the repository (…)

The solution is to update or checkout to a different checkin that doesn't depend on the checkin to purge before doing the purge.



来源:https://stackoverflow.com/questions/32119071/how-to-purge-a-single-checkin-of-the-current-branch-in-fossil

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