author | Puneeth Chaganti <puneeth@fossee.in> |
Mon, 24 Aug 2009 05:33:40 +0530 | |
changeset 30 | 3ca8ab883c13 |
parent 26 | 977009f5a22a |
child 37 | 4cddf3a13843 |
permissions | -rw-r--r-- |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
1 |
|
26 | 2 |
================= |
3 |
Version Control |
|
4 |
================= |
|
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
5 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
6 |
Introduction |
26 | 7 |
============ |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
8 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
9 |
The following words are from a blogpost "http://karlagius.com/2009/01/09/version-control-for-the-masses/" |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
10 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
11 |
"Version control is one of those weird, geeky things that never really gained much ground in non-geek fields, despite the fact that it’s blindingly useful. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
12 |
|
26 | 13 |
Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it. On the surface, it’s all straight-forward; make a copy of every file before making any changes to it. That way, if something seriously messes up, one can always fall back to something that worked before, or at least compare the broken copy with one that used to work so one can figure out where it went off kilter. Accidentally deleted half of thesis and closed the word processor? No problem – out comes the backup." |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
14 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
15 |
Now, in the real world, it’s not so easy. One probably cooks up their own version control system without realizing it had such a geeky name. For instances files with names oldxxxxxx.odt and latestxxxxxx.odt. Every time to make some change in a file, one save it with different name then the original one. Luckily there are like, loads of version control systems out there to do this heavy lifting. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
16 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
17 |
Why Use Version Control |
26 | 18 |
======================= |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
19 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
20 |
"Its the start which most people fail to attempt". |
26 | 21 |
One of idea behind Version Control Tools was to save that "one" step, to build onto it, rather then simply loose it. So here are some reasons why is automated version control needed: |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
22 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
23 |
- It will track the history and evolution of a project, so one don't have to do it manually. It allows to track what changes where made, when were they made, by whom and why. |
26 | 24 |
- For a team of people working on same project, revision control software makes it easier to collaborate. For example, when people more or less simultaneously make potentially incompatible changes, the software will help them to identify and resolve those conflicts. |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
25 |
- It can help to recover from mistakes. If a change made at some moment of time, turns out to be in error in future, one can revert to an earlier version of one or more files. In fact, a really good revision control tool will even help in efficiently figure out exactly when a problem was introduced. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
26 |
|
26 | 27 |
Most of these reasons are equally valid for the project having one man show, or hundred people. Besides projects, even it can be used to maintain assignments related to one particular subject/course, it will help manage things in way much better way. These tools can be used for better *resources management*. All codes, documents, presentation, assignments related to one course maintained in such a inventory can help avoiding accidental lose of data(deletion) and Internet hosting for version control will make the work immune to local hard-disk crash, unless hosting crashes itself. |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
28 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
29 |
Some of Version Control Tools available and used widely are: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
30 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
31 |
- cvs (Concurrent Version System) |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
32 |
- svn (Subversion) |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
33 |
- hg (Mercurial) |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
34 |
- bzr (Bazaar) |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
35 |
- git |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
36 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
37 |
Each of above mentioned tools have sets of feature which it offers in unique way. For this session we are going to concentrate on hg (mercurial). After covering the basics of hg, one can easily try other tools, and use what-ever he/she is most comfortable with. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
38 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
39 |
Learning the Lingo |
26 | 40 |
================== |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
41 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
42 |
Each Version Control uses its own nomenclature for more or less the same features. Here are some of terms which are going to used through out the rest of session: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
43 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
44 |
Basic Setup |
26 | 45 |
----------- |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
46 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
47 |
Repository(repo): |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
48 |
The database/folder storing the files. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
49 |
Server: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
50 |
The computer storing the repo. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
51 |
Client: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
52 |
The computer connecting to the repo. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
53 |
Working Set/Working Copy: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
54 |
Your local directory of files, where you make changes. This is what is present on client side. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
55 |
Trunk/Main: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
56 |
The “primary” location for code in the repo. Think of code as a family tree — the “trunk” is the main line. This is generally what is present on server. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
57 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
58 |
Basic Actions |
26 | 59 |
------------- |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
60 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
61 |
Add: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
62 |
Put a file into the repo for the first time, i.e. begin tracking it with Version Control. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
63 |
Revision: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
64 |
What version a file is on. |
26 | 65 |
Head/Tip: |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
66 |
The latest revision of the repo. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
67 |
Check out: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
68 |
Initial download of repo onto machine. |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
69 |
Commit: |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
70 |
Upload a file to repository(if it has changed). The file gets a new revision number, and people can “check out” the latest one. |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
71 |
Checking Message: |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
72 |
A short message describing what was changed. |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
73 |
Change log/History: |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
74 |
A list of changes made to a file since it was created. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
75 |
Update/Sync: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
76 |
Synchronize local files with the latest from the repository on server. This get the latest revisions of all files. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
77 |
Revert: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
78 |
Throw away the local changes and reload the latest version from the repository. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
79 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
80 |
Advanced Actions: |
26 | 81 |
----------------- |
7
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
82 |
|
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
83 |
Branch: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
84 |
Create a separate copy of a file/folder for private use (bug fixing, testing, etc). |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
85 |
Diff/Change: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
86 |
Finding the differences between two files. Useful for seeing what changed between revisions. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
87 |
Merge (or patch): |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
88 |
Apply the changes from one file to another, to bring it up-to-date. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
89 |
Conflict: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
90 |
When pending changes to a file contradict each other (both changes cannot be applied). |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
91 |
Resolve: |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
92 |
Fixing the changes that contradict each other and checking in the correct version. |
eef24e2b0bac
Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
93 |
|
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
94 |
Types of Version Control: |
26 | 95 |
------------------------- |
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
96 |
|
26 | 97 |
Based on how source/code management is carried out in a tool there are two categories of Version Control Systems(VCS): |
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
98 |
|
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
99 |
- Centralized VCS: |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
100 |
In this kind of system all the revision control functions are performed on a shared server. If two developers try to change the same file at the same time, without some method of managing access the developers may end up overwriting each other's work. Centralized revision control systems solve this problem in one of two different "source management models": file locking and version merging. Both svn and cvs follows this kind of management. |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
101 |
|
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
102 |
- Distributed VCS: |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
103 |
In a distributed model, every developer has their own repo. Diffs, commits, and reverts are all done locally, one needs Internet only to share the changes with others. It makes work faster, handles branching and merging in better way, with less management. hg, bzr and git uses this work flow. |
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
104 |
|
15 | 105 |
Get Going with Hg: |
26 | 106 |
================== |
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
107 |
|
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
108 |
Why hg? |
26 | 109 |
------- |
15 | 110 |
|
111 |
- It is easy to learn and use. |
|
112 |
- It is lightweight. |
|
113 |
- It scales excellently. |
|
114 |
- It is based on Python. |
|
115 |
||
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
116 |
Getting Started: |
26 | 117 |
---------------- |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
118 |
|
26 | 119 |
Following command tells the version of hg installed on machine: :: |
15 | 120 |
|
121 |
$hg version |
|
122 |
||
123 |
Mercurial Distributed SCM (version 1.1.2) |
|
124 |
Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others |
|
125 |
This is free software; see the source for copying conditions. There is NO |
|
126 |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
127 |
||
128 |
Built-in help, Mercurial provides a built-in help system. Following command will print a brief list of commands, along with a description of what each does. :: |
|
129 |
||
130 |
$hg help |
|
131 |
||
132 |
Mercurial Distributed SCM |
|
133 |
list of commands: |
|
134 |
add add the specified files on the next commit |
|
135 |
addremove ----------------------- |
|
136 |
||
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
137 |
For specific command, just follow the command name after the help. :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
138 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
139 |
$hg help diff |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
140 |
hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]... |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
141 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
142 |
diff repository (or selected files) |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
143 |
Show differences between revisions for the specified files. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
144 |
Differences between files are shown using the unified diff format. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
145 |
NOTE:____________ |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
146 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
147 |
Let there be Repository: |
26 | 148 |
------------------------ |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
149 |
|
26 | 150 |
In Mercurial, everything happens inside a repository. The repository for a project contains all of the files that “belong to” that project, along with a historical record of the project's files. A repository is simply a directory tree in filesystem that Mercurial treats as special. |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
151 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
152 |
There can be two ways to create a repo, either getting local copy for existing repo available on Internet or machine, or creating a new repo. For getting already existing repo hg uses command *"clone"* :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
153 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
154 |
$hg clone http://hg.serpentine.com/tutorial/hello localCopyhello |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
155 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
156 |
requesting all changes |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
157 |
adding changesets |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
158 |
adding manifests |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
159 |
adding file changes |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
160 |
added 5 changesets with 5 changes to 2 files |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
161 |
updating working directory |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
162 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
163 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
164 |
If clone succeeded, there would be a local directory called localCopyhello, with some files: :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
165 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
166 |
$ls localCopyhello/ |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
167 |
hello.c Makefile |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
168 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
169 |
Every Mercurial repository is complete, self-contained, and independent. It contains its own private copy of a project's files and history. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
170 |
|
26 | 171 |
To start a new repository use *hg init*: :: |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
172 |
|
26 | 173 |
$ mkdir Fevicol |
174 |
$ cd Fevicol/ |
|
175 |
$ echo "print 'Yeh Fevicol ka Majboot jod hai'" > feviStick.py |
|
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
176 |
$ ls -a |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
177 |
. .. feviStick.py |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
178 |
$ hg init |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
179 |
$ ls -a |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
180 |
. .. feviStick.py .hg |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
181 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
182 |
*.hg* directory indicates that this new dir is now a repo.This is where Mercurial keeps all of its metadata for the repository.The contents of the .hg directory and its subdirectories are private to Mercurial. Rest all files are for the user to use them as they pleases. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
183 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
184 |
Creating a branch of existing local repo is very easy via hg using clone command: :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
185 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
186 |
$ hg clone localCopyhello newCopy |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
187 |
updating working directory |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
188 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
189 |
|
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
190 |
newCopy is exact copy of already existing repo. And this command can be used to create branch of locally created repo also: :: |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
191 |
|
26 | 192 |
$ hg clone Fevicol Fevicol-pull |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
193 |
updating working directory |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
194 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
195 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
196 |
These local branches can prove really handy at times. It allows keep multiple copies of local branch for different purposes, say for debugging, testing, working version. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
197 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
198 |
History or Logs: |
26 | 199 |
---------------- |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
200 |
|
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
201 |
For the new repo created, first thing which can be tried is to check the logs/history. What changes were made and when and why, answers to all those questions are stored in logs safely. So for the the cloned repo the history can be viewed using command *"log"* (following commands are wrt localCopyhello repo). :: |
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
202 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
203 |
$hg log |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
204 |
changeset: 4:2278160e78d4 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
205 |
tag: tip |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
206 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
207 |
date: Sat Aug 16 22:16:53 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
208 |
summary: Trim comments. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
209 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
210 |
changeset: 3:0272e0d5a517 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
211 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
212 |
date: Sat Aug 16 22:08:02 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
213 |
summary: Get make to generate the final binary from a .o file. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
214 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
215 |
changeset: 2:fef857204a0c |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
216 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
217 |
date: Sat Aug 16 22:05:04 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
218 |
summary: Introduce a typo into hello.c. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
219 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
220 |
changeset: 1:82e55d328c8c |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
221 |
user: mpm@selenic.com |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
222 |
date: Fri Aug 26 01:21:28 2005 -0700 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
223 |
summary: Create a makefile |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
224 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
225 |
changeset: 0:0a04b987be5a |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
226 |
user: mpm@selenic.com |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
227 |
date: Fri Aug 26 01:20:50 2005 -0700 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
228 |
summary: Create a standard "hello, world" program |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
229 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
230 |
By default, this command prints a brief paragraph of output for each change to the project that was recorded.The fields in a record of output from hg log are as follows: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
231 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
232 |
- changeset: This field has the format of a number, followed by a colon, followed by a hexadecimal (or hex) string. These are identifiers for the changeset. The hex string is a unique identifier: the same hex string will always refer to the same changeset in every copy of this repository. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
233 |
- user: The identity of the person who created the changeset. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
234 |
- date: The date and time on which the changeset was created, and the timezone in which it was created. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
235 |
- summary: The first line of the text message that the creator of the changeset entered to describe the changeset. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
236 |
- tag: A tag is another way to identify a changeset, by giving it an easy-to-remember name. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
237 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
238 |
To narrow the output of hg log down to a single revision, use the -r (or --rev) option. :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
239 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
240 |
$hg log -r 3 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
241 |
changeset: 3:0272e0d5a517 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
242 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
243 |
date: Sat Aug 16 22:08:02 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
244 |
summary: Get make to generate the final binary from a .o file. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
245 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
246 |
*range notation* can be used to get history of several revisions without having to list each one. :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
247 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
248 |
$ hg log -r 2:4 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
249 |
changeset: 2:fef857204a0c |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
250 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
251 |
date: Sat Aug 16 22:05:04 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
252 |
summary: Introduce a typo into hello.c. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
253 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
254 |
changeset: 3:0272e0d5a517 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
255 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
256 |
date: Sat Aug 16 22:08:02 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
257 |
summary: Get make to generate the final binary from a .o file. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
258 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
259 |
changeset: 4:2278160e78d4 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
260 |
tag: tip |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
261 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
262 |
date: Sat Aug 16 22:16:53 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
263 |
summary: Trim comments. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
264 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
265 |
The hg log command's -v (or --verbose) option gives you this extra detail. :: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
266 |
|
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
267 |
$ hg log -v -r 3 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
268 |
changeset: 3:0272e0d5a517 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
269 |
user: Bryan O'Sullivan <bos@serpentine.com> |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
270 |
date: Sat Aug 16 22:08:02 2008 +0200 |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
271 |
files: Makefile |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
272 |
description: |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
273 |
Get make to generate the final binary from a .o file. |
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
274 |
|
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
275 |
Making Changes: |
26 | 276 |
--------------- |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
277 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
278 |
There is feviStick.py file in repo created above with name feviCol. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
279 |
|
26 | 280 |
$ cd Fevicol |
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
281 |
$ hg log |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
282 |
$ hg status |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
283 |
? feviStick.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
284 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
285 |
*status(st)* command prints the revision history of the specified files or the entire project. "?" sign in front of file indicates that this file is not yet part of track record. *add* command is used to add new files to repo. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
286 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
287 |
$ hg add feviStick.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
288 |
$ hg st |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
289 |
A feviStick.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
290 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
291 |
So file is now part of repository(A symbol). Use *commit (alias ci)* command to make changes effective(this command would be explained in more details in later parts). :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
292 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
293 |
$ hg ci -u "Shantanu <shantanu@fossee.in>" -m "First commit." |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
294 |
$ hg log |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
295 |
changeset: 0:84f5e91f4de1 |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
296 |
tag: tip |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
297 |
user: Shantanu <shantanu@fossee.in> |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
298 |
date: Fri Aug 21 23:37:13 2009 +0530 |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
299 |
summary: First commit. |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
300 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
301 |
Similar to add there are other commands available for file management in repo. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
302 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
303 |
$ hg cp feviStick.py pidiLite.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
304 |
$ hg st |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
305 |
A pidiLite.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
306 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
307 |
*copy (alias cp)* command is used to mark files as copied for the next commit. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
308 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
309 |
$ hg rename pidiLite.py feviCol.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
310 |
$ hg st |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
311 |
A feviCol.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
312 |
$ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Renamed pidiLite.py." |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
313 |
$ hg tip |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
314 |
changeset: 1:d948fb4137c5 |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
315 |
tag: tip |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
316 |
user: Shantanu <shantanu@fossee.in> |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
317 |
date: Sat Aug 22 00:11:25 2009 +0530 |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
318 |
summary: Renamed pidiLite.py. |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
319 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
320 |
*rename(alias mv)* rename files; equivalent of copy + remove. *tip* command shows newest revision in the repository.. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
321 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
322 |
$ hg remove feviCol.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
323 |
$ hg st |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
324 |
R feviCol.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
325 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
326 |
R status of files denotes, file is marked as to be removed by the previous command *remove*. To add the file again to repo, one can use *revert* command, which restore individual files or dirs to an earlier state. :: |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
327 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
328 |
$ ls |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
329 |
feviStick.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
330 |
$ hg revert feviCol.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
331 |
$ ls |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
332 |
feviCol.py feviStick.py |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
333 |
|
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
334 |
Sharing Changes: |
26 | 335 |
---------------- |
336 |
||
337 |
Pulling from repo: |
|
338 |
~~~~~~~~~~~~~~~~~~ |
|
339 |
||
340 |
As mentioned earlier that repositories in Mercurial are self-contained. This means that the changeset just created exists only in Fevicol repository and not in previously cloned fevicol-pull. There are a few ways that can be used to propagate this change into other repositories. :: |
|
341 |
||
342 |
$ hg clone Fevicol Fevicol-clone |
|
343 |
updating working directory |
|
344 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
345 |
||
346 |
Or traverse into the any dir which is a working hg repo(using hg init) and pull command will download all changeset from main repo. :: |
|
347 |
||
348 |
$ mkdir Fevicol-pull |
|
349 |
$ cd Fevicol-pull |
|
350 |
$ hg init |
|
351 |
$ hg pull ../Fevicol |
|
352 |
pulling from ../Fevicol |
|
353 |
requesting all changes |
|
354 |
adding changesets |
|
355 |
adding manifests |
|
356 |
adding file changes |
|
357 |
added 2 changesets with 2 changes to 2 files |
|
358 |
(run 'hg update' to get a working copy) |
|
359 |
||
360 |
*changeset* means a list of changes made to a file. In words of *hg help*, pull command is: :: |
|
361 |
||
362 |
pull changes from the specified source |
|
363 |
||
364 |
Pull changes from a remote repository to a local one. |
|
365 |
||
366 |
This finds all changes from the repository at the specified path |
|
367 |
or URL and adds them to the local repository. By default, this |
|
368 |
does not update the copy of the project in the working directory. |
|
369 |
||
370 |
Some times, even before pulling changesets, one may need to see what changes would be pulled, Mercurial provides *hg incoming* to tell what changes *hg pull* would pull into repo, without actually pulling the changes. This command is really handy in case of avoiding unwanted changesets into the repo. |
|
371 |
||
372 |
With Mercurial, *hg pull* does not(by default) touch the working directory. Instead there is *hg up (alias update, co, checkout)* command to do this. :: |
|
373 |
||
374 |
$ cd Fevicol-pull |
|
375 |
$ ls -a |
|
376 |
. .. .hg |
|
377 |
$ hg up |
|
378 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
379 |
$ ls -a |
|
380 |
. .. feviCol.py feviStick.py .hg |
|
381 |
||
382 |
To update to specific version, give a version number to the *hg update* command. :: |
|
383 |
||
384 |
$ hg update 0 |
|
385 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
386 |
$ hg parent |
|
387 |
changeset: 0:84f5e91f4de1 |
|
388 |
user: Shantanu <shantanu@fossee.in> |
|
389 |
date: Fri Aug 21 23:37:13 2009 +0530 |
|
390 |
summary: First commit. |
|
391 |
||
392 |
If no version number is specified *hg up* will update to the tip version. Version number of hg starts from 0. Compare *hg parent* output to the one before doing update to see the difference. |
|
393 |
||
394 |
Making Changes: |
|
395 |
~~~~~~~~~~~~~~~ |
|
396 |
||
397 |
After getting the desired version of local repo, one can make changes as he/she needs and then make them available(share) for others. For these operations we will be working in Fevicol-clone repo which we created earlier. It's often good practice to keep a “pristine” copy of a remote repository around, which you can then make temporary clones of to create sandboxes for each task you want to work on. :: |
|
398 |
||
399 |
$ cd Fevicol-clone/ |
|
400 |
$ cat cat feviStick.py |
|
401 |
print 'Yeh Fevicol ka Majboot jod hai' |
|
402 |
||
403 |
This tagline is correct for feviCol.py but for feviStick.py it should be different. :: |
|
404 |
||
405 |
$ echo "print 'Ab no more Chip Chip'" > feviStick.py |
|
406 |
$ cat cat feviStick.py |
|
407 |
print 'Ab no more Chip Chip' |
|
408 |
$ hg st |
|
409 |
M feviStick.py |
|
410 |
||
411 |
Mercurial's hg status command will tell us what Mercurial knows about the files in the repository. 'M' sign infront of feviStick.py indicates that Mercurial has noticed change. |
|
412 |
||
413 |
It's somewhat helpful to know that feviStick.py was modified, but one might prefer to know exactly what changes were made to it. To do this, use the *hg diff* command. :: |
|
414 |
||
415 |
$ hg diff |
|
416 |
diff -r a7912d45f47c feviStick.py |
|
417 |
--- a/feviStick.py Sun Aug 23 22:34:35 2009 +0530 |
|
418 |
+++ b/feviStick.py Sun Aug 23 22:47:49 2009 +0530 |
|
419 |
@@ -1,1 +1,1 @@ |
|
420 |
-print 'Yeh Fevicol ka Majboot jod hai' |
|
421 |
+print 'Ab no more Chip Chip' |
|
422 |
||
423 |
We can modify files, build and test our changes, and use hg status and hg diff to review our changes, until we're satisfied with what we've done and arrive at a natural stopping point where we want to record our work in a new changeset. All the diffs prior to committing the changes would be done wrt earlier marked record.The hg commit command lets us create a new changeset. |
|
424 |
||
425 |
Mercurial records your name and address with each change that you commit, so that you and others will later be able to tell who made each change. Mercurial tries to automatically figure out a sensible username to commit the change with. When we try to use *hg commit* there are various ways by which one can specify User name, some of those are: |
|
426 |
||
427 |
- Specify a -u option to the hg commit command on the command line, followed by a username. |
|
428 |
- set HGUSER environment variable. |
|
429 |
- Edit hgrc file present in .hg folder to set this property, add following lines to that file and Mercurial will read those parameters from that location. |
|
430 |
||
431 |
[ui] |
|
432 |
username = Firstname Lastname <email.address@example.net> |
|
433 |
||
434 |
For me the hgrc file looks like this: :: |
|
435 |
||
436 |
[paths] |
|
437 |
default = /home/baali/Fevicol |
|
438 |
[ui] |
|
439 |
username = Shantanu Choudhary <shantanu@fossee.in> |
|
440 |
||
441 |
Once this parameter is set, *hg commit* command drops us into a text editor, to enter a message that will describe the modifications we've made in this changeset. This is called the commit message. It will be a record for readers of what we did and why, and it will be printed by hg log after we've finished committing. :: |
|
442 |
||
443 |
Changed tagline for feviStick.py. |
|
444 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
445 |
HG: -- |
|
446 |
HG: user: Shantanu Choudhary <shantanu@fossee.in> |
|
447 |
HG: branch 'default' |
|
448 |
HG: changed feviStick.py |
|
449 |
||
450 |
This would be vi sort of editor, where you can enter the log message in first line, once you are done with log message quit the editor using *[ESC] key ":wq"*.Once we've finished the commit, we can use the hg tip command to display the changeset we just created. :: |
|
451 |
||
452 |
$ hg tip |
|
453 |
changeset: 3:e1ab2aff4ddd |
|
454 |
tag: tip |
|
455 |
user: Shantanu Choudhary <shantanu@fossee.in> |
|
456 |
date: Sun Aug 23 23:32:01 2009 +0530 |
|
457 |
summary: Changed tagline for feviStick.py. |
|
458 |
||
459 |
One can do above mentioned procedure using following one line command: :: |
|
460 |
||
461 |
$ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Changed tagline for feviStick.py." |
|
462 |
||
463 |
Sharing Changes: |
|
17
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
464 |
~~~~~~~~~~~~~~~~ |
e6240ecd7ae6
Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents:
16
diff
changeset
|
465 |
|
26 | 466 |
The *hg outgoing* command tells us what changes would be pushed into another repository. :: |
467 |
||
468 |
$ hg outgoing ../Fevicol |
|
469 |
comparing with ../Fevicol |
|
470 |
searching for changes |
|
471 |
changeset: 3:e1ab2aff4ddd |
|
472 |
tag: tip |
|
473 |
user: Shantanu Choudhary <shantanu@fossee.in> |
|
474 |
date: Sun Aug 23 23:32:01 2009 +0530 |
|
475 |
summary: Changed tagline for feviStick.py. |
|
476 |
||
477 |
And the hg push command does the actual push. :: |
|
478 |
||
479 |
$ hg push ../Fevicol |
|
480 |
pushing to ../Fevicol |
|
481 |
searching for changes |
|
482 |
adding changesets |
|
483 |
adding manifests |
|
484 |
adding file changes |
|
485 |
added 1 changesets with 1 changes to 1 files |
|
486 |
||
487 |
As with hg pull, the hg push command does not update the working directory in the repository that it's pushing changes into. One has to use hg update to populate the changes in desired repo. :: |
|
488 |
||
489 |
$ cd ../Fevicol |
|
490 |
$ hg tip |
|
491 |
changeset: 3:e1ab2aff4ddd |
|
492 |
tag: tip |
|
493 |
user: Shantanu Choudhary <shantanu@fossee.in> |
|
494 |
date: Sun Aug 23 23:32:01 2009 +0530 |
|
495 |
summary: Changed tagline for feviStick.py. |
|
496 |
$ cat feviStick.py |
|
497 |
print 'Yeh Fevicol ka Majboot jod hai' |
|
498 |
||
499 |
changesets are imported, but update is yet to be done. :: |
|
500 |
||
501 |
$ hg up tip |
|
502 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
503 |
$ $ cat feviStick.py |
|
504 |
print 'Ab no more Chip Chip' |
|
505 |
||
506 |
Dos and Don'ts with Mercurial: |
|
507 |
============================== |
|
508 |
||
509 |
||
16
7a8f9fa7accd
Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents:
15
diff
changeset
|
510 |
|
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
511 |
Suggested Reading: |
26 | 512 |
================== |
8
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
513 |
|
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
514 |
* http://karlagius.com/2009/01/09/version-control-for-the-masses/ |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
515 |
* http://betterexplained.com/articles/a-visual-guide-to-version-control/ |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
516 |
* http://en.wikipedia.org/wiki/Revision_control |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
517 |
* http://hgbook.red-bean.com/ |
461e2574d624
Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents:
7
diff
changeset
|
518 |
* http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/ |