Mercurial: Difference between revisions

Jump to navigation Jump to search
184 bytes removed ,  30 May 2015
start updating. Specially drop, usage of the mercurial patch system
(start updating. Specially drop, usage of the mercurial patch system)
Line 1: Line 1:
[[wikipedia:Mercurial|Mercurial]] (sometimes referred to as {{codeline|hg}}) is the version control tool used by Octave.
[[wikipedia:Mercurial|Mercurial]] (sometimes referred to as {{codeline|hg}}) is
This page contains some helpful commands to use when interacting with the GNU Octave mercurial repository.
the version control tool used by Octave. This page contains some helpful
commands to use when interacting with the GNU Octave mercurial repository.


== Introduction to mercurial ==
An introduction to mercurial is completely outside the scope of this document.
There are plenty of available documentation on the topic.  Some recommendations
are:
* [http://hginit.com/ Hg Init]
* [https://mercurial.selenic.com/wiki/Tutorial Mercurial tutorial]
* [https://mercurial.selenic.com/wiki/QuickStart Mercurial Quickstart]


== Getting the development sources ==
== Getting the development sources ==


You can retrieve the source code for Octave by issuing the command
To clone the Octave repository:
 
hg clone http://www.octave.org/hg/octave octave
 
Octave packages like image, signal, control, etc. are not parts of Octave
itself, they belong to the Octave Forge.  Each package has its own
repository, a list of which can be found
[http://sourceforge.net/p/octave/_list/hg?source=navbar here].
You can clone them in a similar way, for example, to clone the signal package
 
hg clone http://hg.code.sf.net/p/octave/signal octave-signal
 
== Mercurial configuration ==


<pre> hg clone http://www.octave.org/hg/octave octave </pre>
You can use the following to start your hgrc


Packages like image, mapping, etc. are not parts of Octave itself, but of the associated Octave Forge. These have their own repositories, a list of which can be found [http://sourceforge.net/p/octave/_list/hg?source=navbar here]. Behind each link you'll be able to browse each package's source code on sourceforge and see the command for cloning the repository, for example
  [ui]
  username = Your Name <your@email>


<pre> hg clone http://hg.code.sf.net/p/octave/mapping octave-mapping </pre>
  [extensions]
  color =
  rebase =
  bookmarks =
  strip =
  histedit =
  hgext.pager =
 
  [pager]
  pager = LESS='FSRX' less
  attend = help, annotate, cat, diff, export, glog, log, qdiff, status, outgoing, incoming
 
  [diff]
  showfunc = true
 
  [color]
  status.modified = magenta bold
  status.added = green bold
  status.removed = red bold
  status.deleted = cyan bold
  status.unknown = gray  bold
  status.ignored = gray bold
 
  [bookmarks]
  track.current = True
 
  [alias]
  log = log --graph


for the mapping package.


== Submitting patches ==
== Submitting patches ==
When you do not have push permissions to the repository (you cannot add your changes using mercurial itself) and you have a modification to the current GNU Octave code,  you have to generate a patch (or changeset) so developers with permissions can include them in the code. The overview of the process is as follows
When you do not have push permissions to the repository (you cannot add your changes using mercurial itself) and you have a modification to the current GNU Octave code,  you have to generate a patch (or changeset) so developers with permissions can include them in the code. The overview of the process is as follows
# Change the code and test that your changes do work (write tests, that's the best!).
# Change the code and test that your changes do work (write tests, that's the best!).
Line 21: Line 71:
# Post your patch in the [https://savannah.gnu.org/patch/?group=octave Patch tracker].
# Post your patch in the [https://savannah.gnu.org/patch/?group=octave Patch tracker].


=== Before starting ===
If you wish, you can use Mercurial's [http://mercurial.selenic.com/wiki/MqExtension MQ extension] to prepare your patches.
In that case, you need to prepare your .hgrc file to use it. If you do not have a .hgrc file, just create one in your home directory.
In Windows, this is something like "C:\Documents and Settings\your_name\Mercurial.ini"


Add the following code to that file:
Patch submissions is done via the [https://savannah.gnu.org/bugs/?group=octave bug]
[ui]
or [https://savannah.gnu.org/patch/?group=octave patch] trackersEither
username = Your Real Name <some@email.com>
way, you can submit via two different methods: pull requests on attaching
a changeset file.
[extensions]
hgext.mq =
hgext.pager =
color =
[pager]
pager = LESS='FSRX' less
attend = help, annotate, cat, diff, export, glog, log, qdiff, status, outgoing, incoming
## Colours I like
[color]
status.modified = magenta bold
status.added = green bold
status.removed = red bold
  status.deleted = cyan bold
status.unknown = gray  bold
status.ignored = gray bold


The only part that is important is the extensions. The rest is to make hg behave in a fancy way (recommended).
=== Pull request ===


=== Creating changesets with hg ===
This is the cleaner way.  You push your clone to public site, and ask on the
bug tracker to pull a specific changeset from it.  It makes special sense if
you plan to send more patches in the future but requires to host the clone
somewhere.  Free mercurial repositories are available on [https://bitbucket.org/ bitbucket]
 
 
=== Creating changesets files with hg ===
==== Simple way ====
==== Simple way ====
* Update to the latest revision.  
* Update to the latest revision.  
Line 60: Line 95:
<pre> hg export -r tip -o mypatch.patch </pre>
<pre> hg export -r tip -o mypatch.patch </pre>
* Save the output to a file and upload it to the patch tracker. If your patch file is larger than the upload limit, you can compress it before uploading. Please use a free format!
* Save the output to a file and upload it to the patch tracker. If your patch file is larger than the upload limit, you can compress it before uploading. Please use a free format!
==== Using the MQ extension ====
In the repository you can start a patch by doing
hg qnew mychangeset
You can further edit your files... if you do, you need your patch to know about these changes. To do that execute
hg qrefresh
Once you think you have all the changes that make your patch complete you can export your patch
hg qdiff > mychangeset.patch
Now you can do (at least) two things
* Apply your patch to your copy (it will differ form the repository and you will have to merge somehow...). To do it run
hg qfinish tip
* Forget the changes and go back to the unpatched version of the code.
hg qrefresh
hg qpop
hg qfinish tip
The file mychangeset.patch contains your changes.


== Mercurial Tips for SoC students ==
== Mercurial Tips for SoC students ==

Navigation menu