You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Gerald Richter <ri...@ecos.de> on 2003/04/17 04:38:59 UTC

[PATCH] progress output in svn up

Hi,

I have made a little patch that outputs some progress informations during
svn up. It will print n/m where n is number of bytes transfered so far and m
is the number to transfer, if known. This is extremly usfull when you update
large files over slow links.

The patch directly writes to stdout which is of course not correct, but
maybe somebody is able to integrate it into subversion the right way.

I have talked to Ben at the APacheCon and he ask me to send the patch. I did
that, but didn't got any feedback, so maybe he never have got it and I send
it again to the list.

The patch is against 0.21.0

Gerald


--- subversion/libsvn_ra_dav/fetch.c.orig Wed Apr 16 21:28:45 2003
+++ subversion/libsvn_ra_dav/fetch.c Wed Apr 16 21:31:17 2003
@@ -666,6 +666,14 @@
     }
 }

+static void fetch_file_progress(void *userdata, off_t progress, off_t
total)
+{
+    printf ("%d/%d\r", progress, total) ;
+    fflush(stdout) ;
+}
+
 static svn_error_t *simple_fetch_file(ne_session *sess,
                                       const char *url,
                                       const char *relpath,
@@ -699,6 +707,10 @@

   frc.pool = pool;

+  ne_set_progress (sess, fetch_file_progress, NULL) ;
+
   SVN_ERR( custom_get_request(sess, url, relpath,
                               fetch_file_reader, &frc,
                               get_wc_prop, cb_baton,
@@ -706,6 +718,10 @@

   /* close the handler, since the file reading completed successfully. */
   SVN_ERR( (*frc.handler)(NULL, frc.handler_baton) );
+
+  ne_set_progress (sess, NULL, NULL) ;

   return SVN_NO_ERROR;
 }





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] progress output in svn up

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>
> This indeed may be a very nice feature, but there are some problems
> with the implementation.
>
> > --- subversion/libsvn_ra_dav/fetch.c.orig Wed Apr 16 21:28:45 2003
> > +++ subversion/libsvn_ra_dav/fetch.c Wed Apr 16 21:31:17 2003
> > @@ -666,6 +666,14 @@
> >      }
> >  }
> >
> > +static void fetch_file_progress(void *userdata, off_t progress, off_t
> > total)
> > +{
> > +    printf ("%d/%d\r", progress, total) ;
> > +    fflush(stdout) ;
> > +}
>
> For example: printf() is strictly verboten in all libraries.

That's excatly what I wrote in my mail. I know that this is the very wrong
place for a printf, but I don't know how to use the svn feedback system and
I am currently have no time to find it out (also I would be very much
happier when I had time and would be able to submit the right patch). I just
needed this quick hack for making one of my scripts happy (which will
otherwise think svn has timedout)

>
> The other problem here is UI -- I'm not so sure it's a good idea to
> print download percentages on a series of new lines.

I don't do that. I the printf is terminated with a \r, which only sets the
cursor to the start of the line, so you see the count growing in the same
line during the download and the count will be overwritten by the filename
when the download is ready. This is the best UI for a commandline
application I can think of. You don't need curses for that. This works at
least on Unix and Windows, I am not sure about the MacOS.

So I submitted the patch, because I though it maybe a starting point for
somebodyelse who is more familiar with the svn inernal and can implement it
the right way. If not it is at least a reminder in the issue database to do
it one time and if nobody takes it I will be hopefully able sometime to do
it on my own.

Gerald

--------------------------------------------------------------
Gerald Richter     ecos electronic communication services gmbh
IT-Securitylösungen * dynamische Webapplikationen * Consulting

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
--------------------------------------------------------------
|
|   ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
|
+-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] progress output in svn up

Posted by Jani Monoses <ja...@iv.ro>.
One place where percentage would be useful is for large commits
where files are added one per line and then several screenfulls of dots
start marching without indication of when it'll end :)

> Hi Gerald, good to hear from you again.
> 
> This indeed may be a very nice feature, but there are some problems
> with the implementation.
> 
> > --- subversion/libsvn_ra_dav/fetch.c.orig Wed Apr 16 21:28:45 2003
> > +++ subversion/libsvn_ra_dav/fetch.c Wed Apr 16 21:31:17 2003
> > @@ -666,6 +666,14 @@
> >      }
> >  }
> > 
> > +static void fetch_file_progress(void *userdata, off_t progress,
> > off_t total)
> > +{
> > +    printf ("%d/%d\r", progress, total) ;
> > +    fflush(stdout) ;
> > +}
> 
> For example: printf() is strictly verboten in all libraries.  Only
> applications can do that.  So for a feature like this, you'll need to
> make use of our feedback system, and then add a proper callback within
> clients/cmdline/main.c.
> 
> The other problem here is UI -- I'm not so sure it's a good idea to
> print download percentages on a series of new lines.  The output of
> 'svn co/up' is very specific and very parseable -- one file per line.
> I think the least invasive thing to do is have main.c's callback use
> something like the curses library.  It can repeatedly print progress
> information on the same line.  I'm not sure how portable curses is,
> though.  :-(
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] progress output in svn up

Posted by Matt Kraai <kr...@alumni.cmu.edu>.
On Fri, Apr 25, 2003 at 08:52:54AM -0500, Ben Collins-Sussman wrote:
> The other problem here is UI -- I'm not so sure it's a good idea to
> print download percentages on a series of new lines.  The output of
> 'svn co/up' is very specific and very parseable -- one file per line.
> I think the least invasive thing to do is have main.c's callback use
> something like the curses library.  It can repeatedly print progress
> information on the same line.  I'm not sure how portable curses is,
> though.  :-(

You don't need to use curses, just use \r.  e.g.,

  printf ("  0%%");
  fflush (stdout);
  ...
  printf ("\r %2d%%", percentage);
  fflush (stdout);
  ...
  printf ("\r100%%\n");

Matt
-- 
Matt Kraai <kr...@alumni.cmu.edu>
Debian GNU/Linux Peon

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] progress output in svn up

Posted by Ben Collins-Sussman <su...@collab.net>.
"Gerald Richter" <ri...@ecos.de> writes:

> I have made a little patch that outputs some progress informations during
> svn up.

Hi Gerald, good to hear from you again.

This indeed may be a very nice feature, but there are some problems
with the implementation.

> --- subversion/libsvn_ra_dav/fetch.c.orig Wed Apr 16 21:28:45 2003
> +++ subversion/libsvn_ra_dav/fetch.c Wed Apr 16 21:31:17 2003
> @@ -666,6 +666,14 @@
>      }
>  }
> 
> +static void fetch_file_progress(void *userdata, off_t progress, off_t
> total)
> +{
> +    printf ("%d/%d\r", progress, total) ;
> +    fflush(stdout) ;
> +}

For example: printf() is strictly verboten in all libraries.  Only
applications can do that.  So for a feature like this, you'll need to
make use of our feedback system, and then add a proper callback within
clients/cmdline/main.c.

The other problem here is UI -- I'm not so sure it's a good idea to
print download percentages on a series of new lines.  The output of
'svn co/up' is very specific and very parseable -- one file per line.
I think the least invasive thing to do is have main.c's callback use
something like the curses library.  It can repeatedly print progress
information on the same line.  I'm not sure how portable curses is,
though.  :-(


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] progress output in svn up

Posted by Sander Roobol <ph...@wanadoo.nl>.
Filed as issue #1264.

Sander

On Thu, Apr 17, 2003 at 06:38:59AM +0200, Gerald Richter wrote:
> Hi,
> 
> I have made a little patch that outputs some progress informations during
> svn up. It will print n/m where n is number of bytes transfered so far and m
> is the number to transfer, if known. This is extremly usfull when you update
> large files over slow links.
> 
> The patch directly writes to stdout which is of course not correct, but
> maybe somebody is able to integrate it into subversion the right way.
> 
> I have talked to Ben at the APacheCon and he ask me to send the patch. I did
> that, but didn't got any feedback, so maybe he never have got it and I send
> it again to the list.
> 
> The patch is against 0.21.0
> 
> Gerald
> 
> 
> --- subversion/libsvn_ra_dav/fetch.c.orig Wed Apr 16 21:28:45 2003
> +++ subversion/libsvn_ra_dav/fetch.c Wed Apr 16 21:31:17 2003
> @@ -666,6 +666,14 @@
>      }
>  }
> 
> +static void fetch_file_progress(void *userdata, off_t progress, off_t
> total)
> +{
> +    printf ("%d/%d\r", progress, total) ;
> +    fflush(stdout) ;
> +}
> +
>  static svn_error_t *simple_fetch_file(ne_session *sess,
>                                        const char *url,
>                                        const char *relpath,
> @@ -699,6 +707,10 @@
> 
>    frc.pool = pool;
> 
> +  ne_set_progress (sess, fetch_file_progress, NULL) ;
> +
>    SVN_ERR( custom_get_request(sess, url, relpath,
>                                fetch_file_reader, &frc,
>                                get_wc_prop, cb_baton,
> @@ -706,6 +718,10 @@
> 
>    /* close the handler, since the file reading completed successfully. */
>    SVN_ERR( (*frc.handler)(NULL, frc.handler_baton) );
> +
> +  ne_set_progress (sess, NULL, NULL) ;
> 
>    return SVN_NO_ERROR;
>  }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org