63 What version a file is on. |
63 What version a file is on. |
64 Head: |
64 Head: |
65 The latest revision of the repo. |
65 The latest revision of the repo. |
66 Check out: |
66 Check out: |
67 Initial download of repo onto machine. |
67 Initial download of repo onto machine. |
68 Check in: |
68 Commit: |
69 Upload a file to repository(if it has changed). The file gets a new revision number, and people can “check out” the latest one. |
69 Upload a file to repository(if it has changed). The file gets a new revision number, and people can “check out” the latest one. |
70 Checking Message: |
70 Checking Message: |
71 A short message describing what was changed. |
71 A short message describing what was changed. |
72 Change log/History: |
72 Change log/History: |
73 A list of changes made to a file since it was created. |
73 A list of changes made to a file since it was created. |
167 |
167 |
168 Every Mercurial repository is complete, self-contained, and independent. It contains its own private copy of a project's files and history. |
168 Every Mercurial repository is complete, self-contained, and independent. It contains its own private copy of a project's files and history. |
169 |
169 |
170 To start a new repository hg uses *"init"*: :: |
170 To start a new repository hg uses *"init"*: :: |
171 |
171 |
172 $ mkdir newRepo |
172 $ mkdir feviCol |
173 $ cd newRepo/ |
173 $ cd feviCol/ |
174 $ cp ../Desktop/handOut.rst . |
174 $ echo "print 'Yeh Fevicol ka Majboot jod hai!'" > feviStick.py |
175 $ ls -a |
175 $ ls -a |
176 . .. handOut.rst |
176 . .. feviStick.py |
177 $ hg init |
177 $ hg init |
178 $ ls -a |
178 $ ls -a |
179 . .. handOut.rst .hg |
179 . .. feviStick.py .hg |
180 |
180 |
181 *.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. |
181 *.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. |
182 |
182 |
183 Creating a branch of existing local repo is very easy via hg using clone command: :: |
183 Creating a branch of existing local repo is very easy via hg using clone command: :: |
184 |
184 |
185 $ hg clone localCopyhello newCopy |
185 $ hg clone localCopyhello newCopy |
186 updating working directory |
186 updating working directory |
187 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
187 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
188 |
188 |
189 now newCopy is exact copy of already existing repo. And this command can be used to create branch of locally created repo also: :: |
189 newCopy is exact copy of already existing repo. And this command can be used to create branch of locally created repo also: :: |
190 |
190 |
191 $ hg clone newRepo copyNewRepo |
191 $ hg clone feviCol feviCol-pull |
192 updating working directory |
192 updating working directory |
193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
193 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
194 |
194 |
195 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. |
195 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. |
196 |
196 |
197 History or Logs: |
197 History or Logs: |
198 ~~~~~~~~~~~~~~~~ |
198 ~~~~~~~~~~~~~~~~ |
199 |
199 |
200 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"* (we are working here on localCopyhello repo). :: |
200 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). :: |
201 |
201 |
202 $hg log |
202 $hg log |
203 changeset: 4:2278160e78d4 |
203 changeset: 4:2278160e78d4 |
204 tag: tip |
204 tag: tip |
205 user: Bryan O'Sullivan <bos@serpentine.com> |
205 user: Bryan O'Sullivan <bos@serpentine.com> |
269 date: Sat Aug 16 22:08:02 2008 +0200 |
269 date: Sat Aug 16 22:08:02 2008 +0200 |
270 files: Makefile |
270 files: Makefile |
271 description: |
271 description: |
272 Get make to generate the final binary from a .o file. |
272 Get make to generate the final binary from a .o file. |
273 |
273 |
274 All about command options??? should we use this? |
274 Making Changes: |
|
275 ~~~~~~~~~~~~~~~ |
|
276 |
|
277 There is feviStick.py file in repo created above with name feviCol. :: |
|
278 |
|
279 $ cd feviCol |
|
280 $ hg log |
|
281 $ hg status |
|
282 ? feviStick.py |
|
283 |
|
284 *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. :: |
|
285 |
|
286 $ hg add feviStick.py |
|
287 $ hg st |
|
288 A feviStick.py |
|
289 |
|
290 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). :: |
|
291 |
|
292 $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "First commit." |
|
293 $ hg log |
|
294 changeset: 0:84f5e91f4de1 |
|
295 tag: tip |
|
296 user: Shantanu <shantanu@fossee.in> |
|
297 date: Fri Aug 21 23:37:13 2009 +0530 |
|
298 summary: First commit. |
|
299 |
|
300 Similar to add there are other commands available for file management in repo. :: |
|
301 |
|
302 $ hg cp feviStick.py pidiLite.py |
|
303 $ hg st |
|
304 A pidiLite.py |
|
305 |
|
306 *copy (alias cp)* command is used to mark files as copied for the next commit. :: |
|
307 |
|
308 $ hg rename pidiLite.py feviCol.py |
|
309 $ hg st |
|
310 A feviCol.py |
|
311 $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Renamed pidiLite.py." |
|
312 $ hg tip |
|
313 changeset: 1:d948fb4137c5 |
|
314 tag: tip |
|
315 user: Shantanu <shantanu@fossee.in> |
|
316 date: Sat Aug 22 00:11:25 2009 +0530 |
|
317 summary: Renamed pidiLite.py. |
|
318 |
|
319 *rename(alias mv)* rename files; equivalent of copy + remove. *tip* command shows newest revision in the repository.. :: |
|
320 |
|
321 $ hg remove feviCol.py |
|
322 $ hg st |
|
323 R feviCol.py |
|
324 |
|
325 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. :: |
|
326 |
|
327 $ ls |
|
328 feviStick.py |
|
329 $ hg revert feviCol.py |
|
330 $ ls |
|
331 feviCol.py feviStick.py |
|
332 |
|
333 Sharing Changes: |
|
334 ~~~~~~~~~~~~~~~~ |
|
335 |
|
336 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 feviVol-pull. There are a few ways that can be used to propagate this change into other repositories. |
275 |
337 |
276 Suggested Reading: |
338 Suggested Reading: |
277 ------------------ |
339 ------------------ |
278 |
340 |
279 * http://karlagius.com/2009/01/09/version-control-for-the-masses/ |
341 * http://karlagius.com/2009/01/09/version-control-for-the-masses/ |