darcs

Issue 1790 allow darcs send --context foo with no remote repository

Title allow darcs send --context foo with no remote repository
Priority feature Status given-up
Milestone Resolved in
Superseder Nosy List dmitry.kurochkin, jaredj, kowey, loup-vaillant
Assigned To MaicoLeberle
Topics ProbablyEasy

Created on 2010-03-23.12:53:03 by loup-vaillant, last changed 2017-07-31.01:54:45 by gh.

Messages
msg10450 (view) Author: loup-vaillant Date: 2010-03-23.12:52:59
(version 2.2.0, Ubuntu 9.04)

This bites when my repository doesn't have a ./_darcs/pref/defaultrepo
file. It is so on new repositories and copies of it (with cp -r).

Example of a shell session:

    $ rm -f _darcs/prefs/defaultrepo
    $ darcs send -a -o patch --context=ctx
    
    darcs failed:  Missing argument:  [REPOSITORY]
    Usage: darcs send [OPTION]... [REPOSITORY]
    Send by email a bundle of one or more patches.
    
    See darcs help send for details.
    $ darcs send -a -o patch --context=ctx /dev/null/no-such-repository
    Wrote patch to /home/loup/patch
    $ echo /dev/null/no-such-repository >_darcs/prefs/defaultrepo
    $ darcs send -a -o patch --context=ctx
    Wrote patch to /home/loup/patch
    $

When the --context option is used, I expect `darcs send` to succeed even
when no reference repository is specified (as argument or as default).

Speculation:

It looks like Darcs checks 2 things separately:

  1. The presence of a reference repository name (as default or as argument)
  2. The actual existence of such a reference repository

Of these two things, Darcs checks (1) no matter what, and checks (2)
only when needed. I think (1) just happens too early (before we know of
the context file), and therefore is too prudent. I suspect this error
were possible because (1) and (2) are separated in the source code.
Maybe there is a way to put them back together?
msg10451 (view) Author: kowey Date: 2010-03-23.14:10:31
Thanks for the succinct and informative bug report.

May I encourage you to send us a regression test?
http://wiki.darcs.net/Development/RegressionTests
msg10460 (view) Author: loup-vaillant Date: 2010-03-23.16:46:53
Eric Kow a écrit :
> Eric Kow <kowey@darcs.net> added the comment:
> 
> Thanks for the succinct and informative bug report.
> 
> May I encourage you to send us a regression test?
> http://wiki.darcs.net/Development/RegressionTests

I lack bandwidth right now, I can't download even the head of 
http://darcs.net.  I will do it 6 hours from now, when I am home.

Below is the script I intend to send. It seems to work (well, _fail_) as 
intended. I didn't made it as short as possible. I preferred to convey a 
(probably bogus) use case. Tell me if you'd rather have a concise (and 
faster) regression test.

As a side note, I just noticed that a brutal `cp -r` to copy a 
repository (for instance to distribute it via email) is a bit error 
prone: it leaves the _darcs/pref/author file intact, which is confusing 
when secondary authors start to record patches. I made the mistake, and 
I think other beginners will make it too. So, is there a preferred 
method to distribute initial repositories over e-mail? Is this 
documented somewhere?

Loup.

+++++++++++++++++++++++++++++++
failing-issue1790_darcs-send.sh
+++++++++++++++++++++++++++++++

#! /bin/sh

# create the repo
darcs init --repo A

cd A
   # setting the author mail address (avoids interactivity)
   echo john.doe@example.com > _darcs/prefs/author

   # populate A (optional)
   echo foo > foo.txt
   darcs add foo.txt
   darcs record -a -m "foo"

   # create a context file to represent A's state
   darcs changes --context > ../A.context
cd ..

# copy the repository the hard way.
# normally one would use `darcs get A B` to do that,
# but when no central server is available, this sort of
# hard copy may be perceived as simpler: Just tar xcfz
# the repository and send it via email.
cp -r A B

cd B
   # Make sure there is no _darcs/prefs/defaultrepo file
   # If there is one even on new repositories, that would
   # appear to solve the issue, but I think this is not a
   # good solution: the absence of the defaultrepo file
   # is useful to indicate the absence of interaction with
   # remote repositories.
   #
   # Of course, at the time of this writing, the following
   # line has no effect
   rm -rf _darcs/prefs/defaultrepo

   # make some further modifications (optional)
   echo bar > bar.txt
   darcs add bar.txt
   darcs record -a -m "bar"

   # try to send a patch to the first repository,
   # using its context file
   darcs send -a -o ../bar.patch --context=../A.context
cd ..
msg11893 (view) Author: kowey Date: 2010-07-28.09:56:54
Loup, could I just confirm you're happy for this test to be BSD 
licensed?  Sorry for the delay.  

PS. You asked a question about best practices for distributing 
repositories over email. I think darcs-users would be the right place 
for that.  Sorry I didn't notice the first time.
msg11894 (view) Author: loup-vaillant Date: 2010-07-28.13:27:04
Eric Kow a écrit :
> Eric Kow <kowey@darcs.net> added the comment:
> 
> Loup, could I just confirm you're happy for this test to be BSD 
> licensed?  Sorry for the delay.

I prefer the GPL, but for such a small test, BSD is okay.  So, I hereby 
licence my test for the bug 1790 under the simplified BSD licence (that 
should be compatible with everything else).

Cheers,
Loup.
msg11896 (view) Author: kowey Date: 2010-07-28.17:32:46
I've pushed Loup's test in.  It seems like it would indeed be sensible 
for the requirement to be context file xor remote repository.

Sounds like we just need somebody to send us a patch.  I'm going to 
tentatively mark this ProbablyEasy.  There's a chance that the darcs 
send code assumes it has a remote repo to fetch a bunch of other types 
of information, but as far as I know it should really only need the 
context file (especially considering that darcs send . works)


(NB: from a UI standpoint, it may be a good idea for darcs send on a 
remote repo to tell you it's fetching a context file, just so people 
start to make the connection)
msg11897 (view) Author: kowey Date: 2010-07-28.17:34:37
Note that if it simplifies matters, maybe darcs send --context foo with 
no remote repository could just assume the "remote" repository is "."
History
Date User Action Args
2010-03-23 12:53:03loup-vaillantcreate
2010-03-23 14:10:37koweysetpriority: bug
status: unknown -> needs-reproduction
assignedto: loup-vaillant
messages: + msg10451
nosy: + kowey
2010-03-23 16:46:57loup-vaillantsetmessages: + msg10460
2010-07-28 09:56:57koweysetstatus: needs-reproduction -> waiting-for
messages: + msg11893
2010-07-28 13:27:05loup-vaillantsetmessages: + msg11894
2010-07-28 17:32:48koweysetstatus: waiting-for -> needs-implementation
nosy: + jaredj, - darcs-devel
topic: + ProbablyEasy
messages: + msg11896
assignedto: loup-vaillant -> (no value)
2010-07-28 17:34:38koweysetpriority: bug -> feature
messages: + msg11897
2010-07-28 17:35:10koweysettitle: `darcs send -o patch --context=ctx` need a dummy repository name -> allow darcs send --context foo with no remote repository
2014-03-23 00:03:05ghsetassignedto: alex.aegf
nosy: + alex.aegf
2015-03-27 22:40:58ghsetnosy: + MaicoLeberle, - alex.aegf
assignedto: alex.aegf -> MaicoLeberle
2017-07-31 01:54:45ghsetstatus: needs-implementation -> given-up
nosy: - MaicoLeberle