[darcs-users] How to reset a file to an older state?
Thomas Schwinge
tschwinge at gnu.org
Fri Apr 28 23:11:21 UTC 2006
On Fri, Apr 28, 2006 at 08:45:23AM +0200, Juliusz Chroboczek wrote:
> >> > nice to have a libdarcs project and an API that can be used to write
> >> > code that processes darcs repos.
>
> >> Assuming you mean a library callable from C or C++, it will be a cold
> >> day in my office first[1].
>
> > not by me, i don't care for C/C++.
Well, it would definitely be nice to have. But I can imagine that to be
right difficult to do.
> > thanks for the comments (i will try to have a look at vc-darcs.el).
>
> Please do -- I've spent quite a bit of time working out how to script
> Darcs, and it's all in there. At some points it rather hackish, but
> it does work.
Hm. So, I was interested in getting to know how you get a file's
``current revision'', i.e. the last patch applied to it. You parse
``darcs changes --xml FILE'' to get the ``hash'', like I also had it in
mind. But there's a bug in your code, I'd say:
#v+
(defun vc-darcs-find-hash (&optional from-end)
"Find first/last hash in a buffer generated by darcs whatever --xml."
(cond
(from-end
(goto-char (point-max))
(vc-darcs-with-error-reporting
(search-backward "hash='"))
(forward-char 6))
(t
(goto-char 1)
(vc-darcs-with-error-reporting
(search-forward "hash='"))))
(looking-at "\\([0-9a-z-]*\\)")
(match-string 1))
#v-
#v+
$ darcs changes --xml vc-darcs.el
<changelog>
<created_as original_name='./vc-darcs.el'>
<patch author='Juliusz Chroboczek' date='20040627210406' local_date='Sun Jun 27 23:04:06 CEST 2004' inverted='False' hash='20040627210406-73ae5-03a682613e789b316e606585f34fd3593d3184eb.gz'>
<name>Initial import.</name>
</patch>
</created_as>
<patch author='Juliusz Chroboczek <jch at pps.jussieu.fr>' date='20051116215244' local_date='Wed Nov 16 22:52:44 CET 2005' inverted='False' hash='20051116215244-4cc09-4d8edc6c60cacc62a56bb4480ee9cd80be414c18.gz'>
<name>Update version number to 1.6.</name>
</patch>
<patch author='Juliusz Chroboczek <jch at pps.jussieu.fr>' date='20051116215057' local_date='Wed Nov 16 22:50:57 CET 2005' inverted='False' hash='20051116215057-4cc09-88fbf4c6f31a09f1a60f46fb1a322565bfacb718.gz'>
<name>Make vc-darcs.el work with both _darcs/current and _darcs/pristine.</name>
</patch>
[...]
#v-
Searching from the top, `vc-darcs-find-hash' will find the ``created_as''
change's hash first, and not the one of the latest change.
Fixing this, of course makes the parsing even more ugly. :-/
> > and yes, i know it's easy to complain about OS projects being not the
> > answer to everything. i should write the patches instead, but it
> > would cost me more time that i can afford right now.
>
> I didn't mean to imply that -- intelligent critique is appreciated
> even when it comes without patches. I was just trying to indicate to
> would-be contributors a number of projects that I think are worth
> working on.
I'd definitely like to do that, as I think that darcs's current interface
w.r.t. being used non-interactively is really suboptimal. Unfortunately
my Haskell skills are nonexistent. :-|
Regards,
Thomas
More information about the darcs-users
mailing list