[darcs-users] Getting a full diff for pulled patches
Alexander Staubo
alex at purefiction.net
Tue Jul 31 22:43:44 UTC 2007
On 7/26/07, David Roundy <droundy at darcs.net> wrote:
> On Thu, Jul 26, 2007 at 12:14:27AM +0200, Alexander Staubo wrote:
> > Actually, my question is similar to the FAQ (asked just recently on
> > this list) about how to retrieve a specific version of a file. Given a
> > patch -- specifically, one that can be pulled from a remote repository
> > but has not been applied yet -- I want to obtain the file it can be
> > applied to.
> >
> > From what I can tell, I can accomplish this the following way: (1)
> > Read the current pristine from _darcs/pristine. (2) Run "pull
> > --dry-run --verbose --matches=...". (3) For each patch minus the patch
> > I actually want, take each hunk and apply it to the file. Hunks are
> > simple enough to parse that I can apply them directly without going
> > through Darcs.
>
> This is assuming no conflicts, replace patches, etc.
>
> You could also get the remote patch contents with darcs changes --repo -v.
I'm doing this now, and encountering some interesting challenges.
To start, I realized neither "pull" nor "changes" can provide patch
hashes (well, changes can, but only in XML mode, which does not have
diffs). At the moment I do one "pull --dry-run" to get all the pending
patches so I can list them. When the user wants to inspect a patch, I
run "changes --verbose --to-match=..." to build the file and derive
the most recent diff that comes out of the pull.
But since "pull" does not provide patch hashes, I will risk having
"changes" return the wrong patches if somebody reuses a patch name. I
can run "changes --xml-output" to get the hashes, but that would incur
one additional "changes" call per file (or patch), and I'm trying to
make this fast. Instead of doing this, I currently rely on a
combination of patch name + timestamp:
$ darcs changes --to-match 'date "before <date>" && name "<name>"'
That works and should be precise enough in practice.
However, this lack of having the patch hash comes back to bite me when
it's time to actually pull these patches. When the user picks a couple
of patches to push, I want to invoke "push" with the patch names. For
performance reasons I would like to do this as a single command
invocation. So I end up with a match expression like this:
$ darcs changes --to-match '(date "before <date1>" && name "<name1>")
|| (date "before <date2>" && name "<name2>") || ...'
It seems to work, but it's not ideal. I am worried that I will bump
into some OS-level limit on command-line length. Also, I'm not sure
how Darcs scales with large sets of patch names.
My last remaining concern is dependencies. As I pointed out before,
given a list of patches the only way to determine whether they depend
on any other patches is to do a dry-run pull with the patch list in
--matches. Anything you get as a result that isn't in your original
list are the dependencies. Functionally workable -- but that's another
costly Darcs invocation.
The only workaround I can think of is to run Darcs interactively, but
that complicates things awfully, and I would like to avoid it. My
intent is to warn the user: "You're pulling patch A. This requires
patch B. Do you want to continue?" As I think you pointed out, even if
I used the interactive prompt in conjunction with the "w" command, I
would not know when I had reached the last patch.
Given all of the above, I think two small improvements would be
enormously helpful:
(1) Let "pull", "push", "changes" and possibly others print patch
hashes (in --verbose, perhaps).
(2) Add a flag to "pull" and possibly "changes" that included the
patch context in the output. I believe this would be sufficient to
determine dependencies.
Thoughts?
Lastly: Does Darcs have a way to disable the loading of one's personal
defaults file, akin to CVS' -f ("Do not use the ~/.cvsrc file.") flag?
Alexander.
More information about the darcs-users
mailing list