Commit b8f0eb26 authored by paugier's avatar paugier
Browse files

Cleanup pres on Mercurial

parent 88c63fe0
......@@ -27,10 +27,6 @@
"source": [
"### Why Mercurial?\n",
"\n",
"- https://www.mercurial-scm.org/ \n",
"\n",
"- https://fluiddyn.readthedocs.io/en/latest/mercurial_bitbucket.html\n",
"\n",
"Why not Git?"
]
},
......@@ -51,9 +47,30 @@
}
},
"source": [
"Git is really too complicated for what we need as scientists / students / teachers / developers of most scientific programs.\n",
"Git is a very good tool for advanced users but it is really too complicated and unsafe for what we need as scientists / students / teachers / developers of most scientific programs."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Why Mercurial?\n",
"\n",
"[Mercurial is more adapted for us in academics.](http://www.legi.grenoble-inp.fr/people/Pierre.Augier/mercurial-as-a-great-version-source-control-management-tool-in-academics.html)\n",
"\n",
"- simpler and safer for beginners,\n",
"\n",
"- very powerful for advanced users (it is used for example at Facebook and Mozilla... and for the PyPy repository).\n",
"\n",
"For advanced Git users, when using Mercurial, you loose the Git index (but not what you usually do with it) and you gain very interesting features, like for example long-term named branches, safe distributed history edition (phases, obsolete changesets, evolve extension) and the command `hg absorb` (automatic injection of uncommitted changes into prior commits in a PR).\n",
"\n",
"- https://www.mercurial-scm.org/ \n",
"\n",
"[Mercurial is more adapted for us in academics.](http://www.legi.grenoble-inp.fr/people/Pierre.Augier/mercurial-as-a-great-version-source-control-management-tool-in-academics.html)"
"- https://fluiddyn.readthedocs.io/en/latest/mercurial_bitbucket.html"
]
},
{
......@@ -83,7 +100,7 @@
}
},
"source": [
"## Level 0: commands `help`, `init`, `status`, `add`, `remove`, `addremove`, `commit`, `log` and `summary`"
"## Level 0: command `help`"
]
},
{
......@@ -318,6 +335,17 @@
"hg help init"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Level 0: commands `init`, `status`, `add`, `remove`, `addremove`, `commit`, `log` and `summary`"
]
},
{
"cell_type": "code",
"execution_count": 3,
......@@ -561,21 +589,81 @@
"ls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's modify the file `file1.txt`: "
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"echo \"Hello world!\" >> file1.txt"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mparent: 1:4c7dfaebb15e \u001b[0mtip\n",
" Remove file0 and add file1\n",
"\u001b[0;34;1mM \u001b[0m\u001b[0;34;1mfile1.txt\u001b[0m\n"
]
}
],
"source": [
"hg st"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There is no \"Git index\" in Mercurial. A modification in a versioned file is automatically included in the next commit. \n",
"\n",
"We can really think about the commits as \"snapshots of the code\"."
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"hg commit -m \"Hello world in file1.txt\""
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"hg st"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mparent: 2:f64ab784311c \u001b[0mtip\n",
" Hello world in file1.txt\n",
"branch: default\n",
"commit: (clean)\n",
"update: (current)\n",
"phases: 2 draft\n"
"phases: 3 draft\n"
]
}
],
......@@ -592,22 +680,27 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mchangeset: 1:4c7dfaebb15e\u001b[0m\n",
"\u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"tag: tip\n",
"user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"date: Thu May 23 14:28:56 2019 +0200\n",
"date: Fri Jun 14 23:20:17 2019 +0200\n",
"summary: Hello world in file1.txt\n",
"\n",
"\u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"date: Fri Jun 14 23:20:16 2019 +0200\n",
"summary: Remove file0 and add file1\n",
"\n",
"\u001b[0;33mchangeset: 0:8879044fa44a\u001b[0m\n",
"\u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
"user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"date: Thu May 23 14:28:54 2019 +0200\n",
"date: Fri Jun 14 23:20:14 2019 +0200\n",
"summary: First commit\n",
"\n"
]
......@@ -619,22 +712,27 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 1:4c7dfaebb15e\u001b[0m\n",
"@ \u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"| tag: tip\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Thu May 23 14:28:56 2019 +0200\n",
"| date: Fri Jun 14 23:20:17 2019 +0200\n",
"| summary: Hello world in file1.txt\n",
"|\n",
"o \u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:16 2019 +0200\n",
"| summary: Remove file0 and add file1\n",
"|\n",
"o \u001b[0;33mchangeset: 0:8879044fa44a\u001b[0m\n",
"o \u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
" user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
" date: Thu May 23 14:28:54 2019 +0200\n",
" date: Fri Jun 14 23:20:14 2019 +0200\n",
" summary: First commit\n",
"\n"
]
......@@ -646,22 +744,27 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 1:4c7dfaebb15e\u001b[0m\n",
"@ \u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"| tag: tip\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Thu May 23 14:28:56 2019 +0200\n",
"| date: Fri Jun 14 23:20:17 2019 +0200\n",
"| summary: Hello world in file1.txt\n",
"|\n",
"o \u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:16 2019 +0200\n",
"| summary: Remove file0 and add file1\n",
"|\n",
"o \u001b[0;33mchangeset: 0:8879044fa44a\u001b[0m\n",
"o \u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
" user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
" date: Thu May 23 14:28:54 2019 +0200\n",
" date: Fri Jun 14 23:20:14 2019 +0200\n",
" summary: First commit\n",
"\n"
]
......@@ -684,7 +787,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 29,
"metadata": {},
"outputs": [
{
......@@ -701,7 +804,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
......@@ -710,7 +813,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 31,
"metadata": {},
"outputs": [
{
......@@ -727,7 +830,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
......@@ -738,7 +841,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 33,
"metadata": {},
"outputs": [
{
......@@ -755,7 +858,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 34,
"metadata": {},
"outputs": [
{
......@@ -772,7 +875,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
......@@ -792,7 +895,39 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"| tag: tip\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:17 2019 +0200\n",
"| summary: Hello world in file1.txt\n",
"|\n",
"o \u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:16 2019 +0200\n",
"| summary: Remove file0 and add file1\n",
"|\n",
"o \u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
" user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
" date: Fri Jun 14 23:20:14 2019 +0200\n",
" summary: First commit\n",
"\n"
]
}
],
"source": [
"hg log -G"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
......@@ -810,19 +945,19 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mparent: 0:8879044fa44a \u001b[0m\n",
"\u001b[0;33mparent: 0:29f68d89d843 \u001b[0m\n",
" First commit\n",
"branch: default\n",
"commit: (clean)\n",
"update: 1 new changesets (update)\n",
"phases: 2 draft\n"
"update: 2 new changesets (update)\n",
"phases: 3 draft\n"
]
}
],
......@@ -832,7 +967,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 39,
"metadata": {},
"outputs": [
{
......@@ -849,7 +984,96 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"echo \"A line in file0.txt\" >> file0.txt"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;34;1mM \u001b[0m\u001b[0;34;1mfile0.txt\u001b[0m\n"
]
}
],
"source": [
"hg st"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"created new head\n",
"(consider using topic for lightweight branches. See 'hg help topic')\n"
]
}
],
"source": [
"hg commit -m \"A line in file0.txt\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We were at commit 0 and we commited. It created a (unnamed) branch."
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 3:674ce551f5c4\u001b[0m\n",
"| tag: tip\n",
"| parent: 0:29f68d89d843\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:21 2019 +0200\n",
"| summary: A line in file0.txt\n",
"|\n",
"| o \u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"| | user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| | date: Fri Jun 14 23:20:17 2019 +0200\n",
"| | summary: Hello world in file1.txt\n",
"| |\n",
"| o \u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"|/ user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:16 2019 +0200\n",
"| summary: Remove file0 and add file1\n",
"|\n",
"o \u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
" user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
" date: Fri Jun 14 23:20:14 2019 +0200\n",
" summary: First commit\n",
"\n"
]
}
],
"source": [
"hg log -G"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
......@@ -861,24 +1085,24 @@
}
],
"source": [
"hg up"
"hg up 1"
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mparent: 1:4c7dfaebb15e \u001b[0mtip\n",
"\u001b[0;33mparent: 1:ebb8c645f614 \u001b[0m\n",
" Remove file0 and add file1\n",
"branch: default\n",
"commit: (clean)\n",
"update: (current)\n",
"phases: 2 draft\n"
"update: 2 new changesets (update)\n",
"phases: 4 draft\n"
]
}
],
......@@ -888,7 +1112,48 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 files updated, 0 files merged, 0 files removed, 0 files unresolved\n",
"updated to \"f64ab784311c: Hello world in file1.txt\"\n",
"1 other heads for branch \"default\"\n"
]
}
],
"source": [
"hg up"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;33mparent: 2:f64ab784311c \u001b[0m\n",
" Hello world in file1.txt\n",
"branch: default\n",
"commit: (clean)\n",
"update: 1 new changesets, 2 branch heads (merge)\n",
"phases: 4 draft\n"
]
}
],
"source": [
"hg sum"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
......@@ -905,7 +1170,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
......@@ -914,7 +1179,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 50,
"metadata": {},
"outputs": [
{
......@@ -931,7 +1196,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 51,
"metadata": {},
"outputs": [
{
......@@ -948,7 +1213,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
......@@ -957,27 +1222,101 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 53,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 4:5f1ccf526f78\u001b[0m\n",
"| tag: tip\n",
"| parent: 2:f64ab784311c\n",
"| user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:23 2019 +0200\n",
"| summary: Add file 2\n",
"|\n",
"| o \u001b[0;33mchangeset: 3:674ce551f5c4\u001b[0m\n",
"| | parent: 0:29f68d89d843\n",
"| | user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| | date: Fri Jun 14 23:20:21 2019 +0200\n",
"| | summary: A line in file0.txt\n",
"| |\n",
"o | \u001b[0;33mchangeset: 2:f64ab784311c\u001b[0m\n",
"| | user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| | date: Fri Jun 14 23:20:17 2019 +0200\n",
"| | summary: Hello world in file1.txt\n",
"| |\n",
"o | \u001b[0;33mchangeset: 1:ebb8c645f614\u001b[0m\n",
"|/ user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
"| date: Fri Jun 14 23:20:16 2019 +0200\n",
"| summary: Remove file0 and add file1\n",
"|\n",
"o \u001b[0;33mchangeset: 0:29f68d89d843\u001b[0m\n",
" user: paugier <pierre.augier@univ-grenoble-alpes.fr>\n",
" date: Fri Jun 14 23:20:14 2019 +0200\n",
" summary: First commit\n",
"\n"
]
}
],
"source": [
"hg log -G"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We cleanup a bit to get back a linear history. Since all commits are local, they are in a draft phase and they can be obsoleted without problem."
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@ \u001b[0;33mchangeset: 2:c67605445601\u001b[0m\n",