filestore icon indicating copy to clipboard operation
filestore copied to clipboard

save method should return IO RevisionId

Open jwiegley opened this issue 11 years ago • 5 comments

It would be handy if save could return the RevisionId it just saved the FilePath at, rather than requiring that you immediately call latest for that same FilePath.

I mention this because I'd like to write a gitlib module for FileStore, and the division of information between save and latest like this is inefficient if you are writing code that persists the RevisionId information elsewhere after each save. The only way to answer such a query in O(1) would require keeping state information in gitlib about the most recent commit, which it does not do.

jwiegley avatar Mar 06 '13 08:03 jwiegley

I would have no problem with the suggested API change. It would require modifying gitSave, darcsSave, etc. so that these functions called gitLatestRevId, darcsLatestRevId, etc. after saving. This would cause a small slowdown, but only on saving, so I don't think it's a big deal. (And presumably there would be no performance hit with your gitlib backend -- which I'm very excited to hear about.)

Because the proposed change just replaces a () return value, I don't think it would have any impact on existing code that uses filestore.

+++ John Wiegley [Mar 06 13 00:52 ]:

It would be handy if save could return the RevisionId it just saved the FilePath at, rather than requiring that you immediately call latest for that same FilePath.

I mention this because I'd like to write a gitlib module for FileStore, and the division of information between save and latest like this is inefficient if you are writing code that persists the RevisionId information elsewhere after each save. The only way to answer such a query in O(1) would require keeping state information in gitlib about the most recent commit, which it does not do.

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y68416pESH0Pc-3Oq9eZeYApmB4Auv6tpk1CCLXJlMtG-Je.gif]

References

  1. https://github.com/jgm/filestore/issues/7

jgm avatar Mar 06 '13 16:03 jgm

I suppose one way to make everyone happy would be to change save to return the RevisionId, and then have save_ which would have the current save signature.

jwiegley avatar Mar 06 '13 17:03 jwiegley

Let's just keep it simple and change save.

+++ John Wiegley [Mar 06 13 09:08 ]:

I suppose one way to make everyone happy would be to change save to return the RevisionId, and then have save_ which would have the current save signature.

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y68416pESH0Pc-3Oq9eZeYApmB4Auv6tpk1CCLXJlMtG-Je.gif]

References

  1. https://github.com/jgm/filestore/issues/7#issuecomment-14512771

jgm avatar Mar 06 '13 17:03 jgm

Since I'm worried about performance, I'm not going to make this change now. But if you come up with a libgit backend, I think I'll be okay with it then.

jgm avatar Mar 20 '13 21:03 jgm

@jgm Sorry for the delay, but release schedules demand that I back-burner creating that backend for a little bit. Good news is that gitlib has come a long way in the past month, though, so I think creating it should be trivial now.

jwiegley avatar Apr 05 '13 19:04 jwiegley