How do I apply a patch or clean up a repository?

25 views
Skip to first unread message

Stan Schymanski

unread,
Sep 1, 2009, 6:03:55 AM9/1/09
to sage-devel
Dear all,

Sorry if you see this twice, but my original message does not show up
for me, so I am posting it again under a new subject.

I tried different ways of applying a patch with the only success that
I probably made a bit of a
mess in my repository. Is there a way to revert it back to a clean
4.1.1
install? I keep getting a message about an uncommitted merge...

Here is what I did in OSX 10.4:

----------------------------------------------------------------------
| Sage Version 4.1.1, Release Date: 2009-08-14 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: hg_sage.revert('--all')

WARNING:
Make sure to create a ~/.hgrc file:
----------------------------------------------------------------------
[ui]
username = William Stein <wst...@gmail.com>
----------------------------------------------------------------------

cd "/Users/sschym/Programs/sage/devel/sage" && hg revert --all
abort: uncommitted merge - please provide a specific revision

Thanks for your help!

Stan

David Joyner

unread,
Sep 1, 2009, 6:30:17 AM9/1/09
to sage-...@googlegroups.com
On Tue, Sep 1, 2009 at 6:03 AM, Stan Schymanski<schy...@gmail.com> wrote:
>
> Dear all,
>
...
>
> I tried different ways of applying a patch with the only success that
> I probably made a bit of a
> mess in my repository. Is there a way to revert it back to a clean
> 4.1.1
> install?

I'm not sure what you did to create the new repo.Can you provide details?

For example, if you started with a new install of Sage, then did
sage -clone myclone
and then applied patched in myclone, you can
"clean it up" and start afresh by typing
sage -b main
sage -clone myclone2

Is that what you want?

Stan Schymanski

unread,
Sep 1, 2009, 8:03:32 AM9/1/09
to sage-...@googlegroups.com
Hi David,

Thanks for your help. Yes, I did sage -clone myclone, which returned an
error message, so I changed back to main (sage -b main), started sage,
tried to apply the same patch in main without success and then I thought
I should revert to the original by typing hg_sage.revert('--all')
- without success, as described before.

Here is an attempt to reconstruct in more detail what I did:

Following the instructions at
http://www.sagemath.org/doc/developer/producing_patches.html, I did:
hg_sage.patch('trac-5448-matplotlib-axes-gridlines.patch')

However, this launched me straight into editing the patch, which I was
not really up to. Exiting the editors led to the following message:

RuntimeError?: Refusing to do operation since you still have unrecorded
changes. You must check in all changes in your working repository first.


I then tried out instrutions by Jason:

$ sage -sh
$ cd $SAGE_ROOT/devel/sage/sage/
$ hg qimport
http://trac.sagemath.org/sage_trac/raw-attachment/ticket/5448/trac-5448-matplotlib-axes-gridlines.patch

hg: unknown command 'qimport'


Doing hg revert --all and hg_sage.patch(...) from within sage took me a
few steps further until:

patching file sage/plot/matrix_plot.py Hunk #1 FAILED at 155 1 out of 1
hunks FAILED -- saving rejects to file sage/plot/matrix_plot.py.rej
patching file sage/plot/plot.py Hunk #6 FAILED at 1222 Hunk #10 FAILED
at 1770 Hunk #11 FAILED at 1812 3 out of 14 hunks FAILED -- saving
rejects to file sage/plot/plot.py.rej abort: patch failed to apply

Since then, I have been trying to do hg_sage.revert('--all') from within
sage using the main branch and running into the message "abort:
uncommitted merge - please provide a specific revision".

By the way, I can reproduce the error message caused by sage -clone myclone:
...
___gmpz_tdiv_r_2exp referenced from libmpfr expected to be defined in
/Users/sschym/Programs/sage-4.0.2/local/lib/libgmp.3.dylib
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
sage: There was an error installing modified sage library code.


real 0m44.194s
user 0m33.997s
sys 0m4.820s
Error building Sage
*** WARNING ***
If you are cloning a previous revision or have uncommitted changes to
cython files do
sage -ba
Otherwise Sage might build using the wrong .c files !!

I only now noticed that sage was looking for something in my sage-4.0.2
folder, which does not exist any more. Does this imply that my previous
sage -upgrade did not work?

Maybe I should recompile from scratch (?). Or just do sage -ba as
suggested in the error message? Sorry about the mess.

Cheers,
Stan

David Joyner

unread,
Sep 1, 2009, 8:14:09 AM9/1/09
to sage-...@googlegroups.com
On Tue, Sep 1, 2009 at 8:03 AM, Stan Schymanski<schy...@gmail.com> wrote:
>
> Hi David,
>
> Thanks for your help. Yes, I did sage -clone myclone, which returned an
> error message, so I changed back to main (sage -b main), started sage,
> tried to apply the same patch in main without success and then I thought
> I should revert to the original by typing  hg_sage.revert('--all')
> - without success, as described before.
>

...

>
> I only now noticed that sage was looking for something in my sage-4.0.2
> folder, which does not exist any more. Does this imply that my previous
> sage -upgrade did not work?
>
> Maybe I should recompile from scratch (?). Or just do sage -ba as
> suggested in the error message? Sorry about the mess.


Yes, I would create a new version by compiling from source. It seems like
your upgrade got corrupted somehow maybe?

John Cremona

unread,
Sep 1, 2009, 8:21:06 AM9/1/09
to sage-...@googlegroups.com
You may need to recompile from scratch. I would *never* apply a patch
to the mai nbranch, for this reason!

The reason the hg qimport failed is probably because i nyour .hgrc
file you need to alert hg to the fact that you will be using wueues.
Mine looks like this:

[ui]
username = John Cremona <john.c...@gmail.com>
[extensions]
hgext.mq =

By the way, if you find that your system has an older version of hg
which does not support queues then use "sage -hg" instead of hg.

John

2009/9/1 Stan Schymanski <schy...@gmail.com>:

Stan Schymanski

unread,
Sep 1, 2009, 8:27:44 AM9/1/09
to sage-...@googlegroups.com
OK, thanks! It's a mystery to me how people manage to do upgrade after
upgrade without running into problems. So far, I have always ended up
recompiling from source, earlier or later. Maybe the problems are caused
by moving the sage install directory after upgrading. I don't know.
Anyway, thanks for your help!

Stan Schymanski

unread,
Sep 1, 2009, 8:38:27 AM9/1/09
to sage-...@googlegroups.com
Thanks, John!

Is there a simple step-by-step guide to safely applying patches
somewhere? Everyone seems to do it differently. I found the following
thread helpful, but it would be good to summarise it somewhere:
http://groups.google.com/group/sage-devel/browse_thread/thread/6f9b59faccaafc12/300bca141f731323?lnk=gst&q=patch#300bca141f731323

By the way, there was an error in my upgrade because I just went into
the original folder where I did the upgrade and tried a ./sage -clone
myclone yielding the same error messages.

Cheers,
Stan

Jason Grout

unread,
Sep 1, 2009, 9:46:22 AM9/1/09
to sage-...@googlegroups.com
John Cremona wrote:
> You may need to recompile from scratch. I would *never* apply a patch
> to the mai nbranch, for this reason!
>
> The reason the hg qimport failed is probably because i nyour .hgrc
> file you need to alert hg to the fact that you will be using wueues.
> Mine looks like this:
>
> [ui]
> username = John Cremona <john.c...@gmail.com>
> [extensions]
> hgext.mq =
>


My file also has the following, in case it's helpful to others too:


[extensions]
record=
hgext.mq=


The "record=" enables hg record and hg qrecord, which lets me select
parts of a file to include in a commit or patch. It's very handy in the
case that I didn't commit often enough and several changes are mushed
together in my source files.

Jason


--
Jason Grout

Minh Nguyen

unread,
Sep 1, 2009, 9:14:17 PM9/1/09
to sage-...@googlegroups.com
Hi Stan,

On Tue, Sep 1, 2009 at 10:38 PM, Stan Schymanski<schy...@gmail.com> wrote:
>
> Thanks, John!
>
> Is there a simple step-by-step guide to safely applying patches
> somewhere? Everyone seems to do it differently. I found the following
> thread helpful, but it would be good to summarise it somewhere:
> http://groups.google.com/group/sage-devel/browse_thread/thread/6f9b59faccaafc12/300bca141f731323?lnk=gst&q=patch#300bca141f731323

Writing such a tutorial is on my todo list. I'm rather busy with
release management and teaching at the moment, so it would be some
time before there is anything to read. In the meantime, feel free to
open a trac ticket for this issue and CC me on it.

--
Regards
Minh Van Nguyen

Stan Schymanski

unread,
Sep 2, 2009, 9:24:46 AM9/2/09
to sage-...@googlegroups.com
I don't seem to have an .hgrc file. I only have an .hg file in
/sage/devel/sage-myclone. Did I failed to install something crucial?

Cheers,
Stan

Stan Schymanski

unread,
Sep 2, 2009, 9:29:51 AM9/2/09
to sage-...@googlegroups.com
Sorry, please disregard my previous message. I just found the following
plastered all over my terminal window:

WARNING:
Make sure to create a ~/.hgrc file:
----------------------------------------------------------------------
[ui]
username = William Stein <wst...@gmail.com>
----------------------------------------------------------------------

I suppose this answers it. :-)

Cheers,
Stan

Reply all
Reply to author
Forward
0 new messages