顯示包含「tag」標籤的文章。顯示所有文章
顯示包含「tag」標籤的文章。顯示所有文章

2010年12月25日星期六

[Mercurial] Use hg strip to remove an unwanted changeset/revision/branch

Reference: http://mercurial.selenic.com/wiki/Strip

One way to remove unwanted commit is using "hg strip REV" command.
hg strip rev removes the rev revision and all its descendants from a repository.

Let me show you an example in using hg strip.

1. View the current repository tree

2. Add a new file a.c
$ echo "Create new file a.c" > a.c
$ hgad a.c
$ hgci "Add new file a.c"

3. Work on this file, modify, commit, and tag it as a stable version for release
$ echo "Alan fixed a serious driver bug." >> a.c
$ hgci "Driver bug fix"
$ echo "Curtis makes AAC decode 10 times faster." >> a.c
$ hgci "Enhance performance"
$ hgta "Full tested" RELEASE_1.0

$ cat a.c
Create new file a.c
Alan fixed a serious driver bug.
Curtis makes AAC decode 10 times faster.


4. Base on RELEASE_1.0, continue add bug fix in hurry:
$ echo "Customer push, add quick fix." >> a.c
$ hgci "Not fully tested"
$ echo "Need to meet deadline, ci all fixes." >> a.c
$ hgci "Will be release 2.0 tomorrow"

$ cat a.c
Create new file a.c
Alan fixed a serious driver bug.
Curtis makes AAC decode 10 times faster.
Customer push, add quick fix.
Need to meet deadline, ci all fixes.


5. Use hg strip command to remove unwanted commit
At 11:00pm, suddenly find the last 2 commits (rev10, rev11) introduce a major bug, need to get rid of them and go back to rev9.

6. See the repository tree after hg strip
You can see rev10 and rev11 are removed from repository. The tip points to rev9.

7. Double check the file content is correct

$ cat a.c
Create new file a.c
Alan fixed a serious driver bug.
Curtis makes AAC decode 10 times faster.

Actually, Curtis and Alan already make the software good enough, can release RELEASE_1.0 to customer tomorrow! :)


Merry Xmas 2010!!!

2010年12月20日星期一

[Mercurial] Graphical view of a repository, simple view of a Changeset of a File

With the style template mentioned in previous post: [Mercurial] Enhance hg log with nice coloring, you can view your repository, changeset and history of a file in a colorful way in a ANSI console.
Today I will introduce 4 alias commands: hggl, hgch, hgcs and hgsl.

1. [hggl] Graphical view of a repository

To see latest N changeset of your repository, you can type "hggl N"


2. [hgch] View the detail of latest commit

After you commit a file, it will become a head, the latest head call tip. To view the detail of tip, type "hgch"


3. [hgcs] View detail of a Tag or Changeset

If you want to view the detail of a tag or a changeset, you can type "hgcs" followed by a ChangesetID or a Tag name.


4. [hgsl] View the history summary of a file

If you want to see the latest N changesets include the change of a particular file, you can type "hgsl N FILE"

To get the above 4 commands works, first, you need to download the style template and put them in "C:\Program Files\TortoiseHg\templates". Then, add the aliases in .hgrc and .bashrc.

Download:

Modify files:
File: .hgrc
[alias]
slog  = log --style slog
sglog = glog --style sglog
cslog = log --style changeset
chlog = log -r tip --style changeset

File: .bashrc
# hggl, hgch, hgcs and hgsl
alias hggl="hg sglog -v -l"
alias hgch="hg chlog"
alias hgcs="hg cslog -r"
alias hgsl="hg slog -l"