[PYTHON] An introduction to Mercurial for non-engineers

What is Mercurial?

I think it is the most useful / well-known tool for non-engineers.

One of the so-called version management tools, a tool that creates something like a restore point in Windows for files. It can be said to be a memory card-like tool for Sony PlayStation. You can save, load, and copy the state of the file. In the following, we will use the analogy of a Sony PlayStation memory card. It is difficult to explain version management in words, so I strongly recommend that you try it out. If you install it and it works, you can learn the basics in about 20 minutes.

How to install Mercurial?

Download and install the latest version of Mercurial from here

\ #Maybe it's right, but I'm sorry if it's different

Create a blank memory card

hg init

Since Mercurial manages each folder, you need a memory card for each folder you want to monitor. For Windows7, press windows key-> cmd-> enter and a command prompt will appear. Enter it, move to the folder you want to monitor, and type the above command to create an empty memory card. If successful, a folder named .hg will be created in that folder. This .hg folder corresponds to the memory card. If you don't understand the meaning of moving, ask the engineer and they will answer in about 5 seconds.

Make the files under the corresponding directory the storage monitoring target of the memory card

hg add

With this command, all files in the corresponding folder will be monitored. You need to run it every time you add a new file.

Check the monitoring status of the corresponding directory

hg st
#M tinko.txt
#A hage.txt
#! unko.txt
#? fugu.txt

You can check the monitoring status with this command. The file edited since the above M was last recorded in the save data. A is a newly added file to be monitored. Files that were monitored but deleted. Files whose? Is not monitored. R is a file that has been removed from monitoring and deleted.

Save the state in the current folder to the memory card

hg ci -m "Leave a note about the save here"

With this command, save data (= restore point) can be created. Unless you mess with the .hg folder, you can assume that the save data will not disappear.

View the memory card save log

hg log

You can see the history of save data created so far. A number is attached to each save data.

Load from the save data of the memory card

hg up -C save number
#Example hg up-C 3
#The above example means to restore the 3rd save

When the above is executed, the file is rewritten to the state of the corresponding save data. Even if you load from the past save data, the saved data will not be deleted, so you can rest assured.

See the last loaded save data

hg par

With this command, you can get an overview of the save data that was last loaded. If you have never loaded it, you will see a summary of the last saved data.

Copy save data

hg clone pathname
#Example hg clone c:¥MercurialTest
#c:If there is a memory card in \ MercurialTest, copy the entire folder and copy it to the current directory.
#If you don't know the current directory, ask the engineer there

Assumed FAQ

Q. Why isn't it git?

Because it's difficult.

Q. What is the official name of the save data?

Repository.

Q. Japanese settings do not work in Windows environment. Is there a solution?

is there. Gugure. Maybe easy. I don't know because I don't have 7. XP settings will be posted if requested. Tip: c: \ program files \ Mercurial \ Mercurial.ini

Q. I don't understand the meaning of the explanation, so please tell me more.

The description of any site probably doesn't come out very well. It's easy to run once it's installed, and I think you'll understand the meaning of each command in about 20 minutes.

Q. Please give an example of the output result or make it like a tutorial.

sleepy. If you are a master, please request editing.

Recommended Posts

An introduction to Mercurial for non-engineers
An introduction to Python for non-engineers
An introduction to OpenCV for machine learning
An introduction to Python for machine learning
An introduction to Python for C programmers
An introduction to object-oriented programming for beginners by beginners
An introduction to statistical modeling for data analysis
An introduction to voice analysis for music apps
An introduction to machine learning
An introduction to Python Programming
An introduction to Bayesian optimization
Introduction to Python For, While
[Python Tutorial] An Easy Introduction to Python
Recurrent Neural Networks: An Introduction to RNN
Introduction to discord.py (1st day) -Preparation for discord.py-
Beginners read "Introduction to TensorFlow 2.0 for Experts"
An Introduction to Object-Oriented-Give an object a child.
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to Tkinter 1: Introduction
Introduction to PyQt
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
An introduction to self-made Python web applications for a sluggish third-year web engineer
Introduction to discord.py
[What is an algorithm? Introduction to Search Algorithm] ~ Python ~
For beginners to build an Anaconda environment. (Memo)
An introduction to Cython that doesn't go deep
[Introduction to Udemy Python3 + Application] 43. for else statement
Introduction to Python "Re" 1 Building an execution environment
Introduction to Programming (Python) TA Tendency for beginners
[For beginners] Introduction to vectorization in machine learning
Understand Python for Pepper development. -Introduction to Python Box-
An introduction to Cython that doesn't go deep -2-
Introduction to Deep Learning (1) --Chainer is explained in an easy-to-understand manner for beginners-
Introduction to Lightning pytorch
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to EV3 / MicroPython
An introduction to Python distributed parallel processing with Ray
Reading Note: An Introduction to Data Analysis with Python
Introduction to Python language
Introduction to TensorFlow-Image Recognition
[Introduction to python] A high-speed introduction to Python for busy C ++ programmers
Introduction to OpenCV (python)-(2)
An introduction to Word2Vec that even cats can understand
Introduction to PyQt4 Part 1
Introduction to Dependency Injection
Introduction to Private Chainer
[Introduction to Python] How to write repetitive statements using for statements
Introduction to machine learning
An introduction to machine learning from a simple perceptron
An introduction to statistical modeling for data analysis (Midorimoto) reading notes (in Python and Stan)
Introduction to Flask Part 1: First try running it locally & create an executable file for distribution
An introduction to Web API development for those who have completed the Progate Go course
An introduction to object orientation-let's change the internal state of an object
[Introduction to Udemy Python3 + Application] 42. for statement, break statement, and continue statement