Tweets about "hg mercurial"
@tednaleid
In his book, The Productive Programmer, NealFord(@neal4d) talks about using shims or jigs to help productivity. Jigs and shims are quickly created little snippets of code that automate repetitive tasks or make them easy enough that they’re worth doing. They’re little tools that help make your job easier and let you avoid using brute force to solve all of your problems.
[1] hg color extension
add [extension] color= to ~/.hgrc
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ vi /home/prayag/.hgrc
[ui]
username = prayag
[extensions]
color =
progress =
hgext.extdiff =
hgext.purge=
graphlog =
[extdiff]
cmd.vimdiff =
[2.1] list the repository's named branches
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg branches
default 721:88ddd68c8bd9
feat-x 687:97ace77757da (inactive)
[2.2] show the current branch name
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg branch
default
[3.1] incoming changes with files that will be changed
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg incoming --stat -v
http authorization required
realm: Mercurial repositories
user: prayag
password:
comparing with http://10.X.XXX.X/hg/zazzercode-hg/
searching for changes
all local heads known remotely
changeset: 9:a788c9d9556c
tag: tip
user: pra
date: Thu Feb 28 13:27:56 2013 +0545
files: src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java
description : REFACTOR transactionAPI
src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java | 4 +++
1 files changed, 3 insertions(+), 0 deletions(-)
OR
[3.2] incoming changes for a particular branch with patch(=changed code)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg incoming -b default -v --patch
[4.1] restore a file to it's checkout state
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg revert src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java -r-1
[4.2] revert all changes
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg revert --all
reverting src/main/java/com/zazzercode/eccount/server/api/impl/TransactionApiImpl.java
reverting src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java
[5] Pull changes from a remote repository to a local one
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg pull -v
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg upadate -v
OR a single equivalent command
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg pull -u
_______________________________________________________________________________
_______________________________________________________________________________
[6] hg merge pulled change to local head
It's useful when I have a commit(1693) to push which I did before hg pull(1694).
Verify with commit log
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -G --limit 3
o changeset: 1694:c055f66f64c2
| branch: eccount_merchant
| tag: tip
| parent: 1692:7eef95617dde
| user: albert
| date: Fri Aug 23 17:56:19 2013 +0545
| summary: UPDATE search ui, i18 text, search query condition
|
| @ changeset: 1693:a14ffdea264f
|/ branch: eccount_merchant
| user: prayag<prayag.upd@gmail.com>
| date: Sun Aug 25 11:55:27 2013 +0545
| summary: REFACTOR api-context to fix multiple spring component scan
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg merge
If throws
abort: crosses branches (merge branches or use --clean to discard changes)
OR
abort : outstanding uncommitted changes (use 'hg status' to list changes)
commit changes, revert un-necessary changes and then merge.
$ hg revert -a
$ hg merge
hg status will now show pulled files as uncommited changes, commit them first and then push the previous commit with this new one.
$ hg commit -m "ADD merged files"; //this will commit all modified files
$ hg push
Verify after all these steps are performed correctly,
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -G --limit 3
@ changeset: 1695:11ea43c99d0c
|\ branch: eccount_merchant
| | tag: tip
| | parent: 1693:a14ffdea264f
| | parent: 1694:c055f66f64c2
| | user: prayag<prayag.upd@gmail.com>
| | date: Sun Aug 25 12:33:48 2013 +0545
| | summary: ADD merged changes
| |
| o changeset: 1694:c055f66f64c2
| | branch: eccount_merchant
| | parent: 1692:7eef95617dde
| | user: albert
| | date: Fri Aug 23 17:56:19 2013 +0545
| | summary: UPDATE search ui, i18 text, search query condition
| |
o | changeset: 1693:a14ffdea264f
|/ branch: eccount_merchant
| user: prayag<prayag.upd@gmail.com>
| date: Sun Aug 25 11:55:27 2013 +0545
| summary: REFACTOR api-context to fix multiple component scan
[7] show changed files in the working directory
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg status
OR : show changed files sorting by date
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ ls -t1 `hg st -n -a -m -u` > modified.log
OR
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg diff --git
OR add following conf to ~/.hgrc to enable hg diff for vimdiff
[extensions]
hgext.extdiff =
[extdiff]
cmd.vimdiff =
And then fire command like as below
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg vimdiff build.gradle
[8] commit the specified files
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg commit zazzercode-gwt/src/main/java/com/zazzercode/client/admin/presenter/UserRolesPresenter.java -m "REMOVE FEATURE of searching User Role, ADD FEATURE of Creating User" -u prayag;
[9] roll back the last transaction (dangerous)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg rollback
repository tip rolled back to revision 736 (undo commit)
[10] Show changesets not found in the specified destination repository
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg outgoing --stat -p
[11] Push changesets from the local repository to the specified destination
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg push -v
OR to track errors during push
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg push -v --debug --traceback
[12] hg log with --limit
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log --verbose --limit 1
changeset: 839:fd570795d841
tag: tip
user: prayag
date: Mon Mar 11 11:56:33 2013 +0545
files: *.*, *.*
summary: FIX slow reporting
OR log with -v (=verbose)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -v --limit 1
OR enable graphLOG extension
[extensions]
color =
graphlog =
OR log of {modified files} for a spec revision(-r)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -r 839 --template '{files}\n'
equivalent to
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -r839 --template '{files}\n'
zazzercode-gwt/src/main/java/com/zazzercode/client/admin/presenter/UserRolesPresenter.java
OR diffs in a spec changeset(-r)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -p -r 839
equivalent to
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -p -r839
OR log of all the changesets in the repository
$ hg log --template '{rev}:{node|short} {desc|firstline}\n' --limit 3
1053:2192d77f22ed ADD if PhoneNumber belongs to a User
1052:7f0d51d09ed4 FIX mobile messages
1051:6da264634482 FIX password to raw
Switch to a branch that needs to be merged (say default needs to get changes from branch feat-x)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg checkout default
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg merge feat-x
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg commit -m "MERGE from feat-x to default";
[15] hg list conflicted files
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg resolve --list
Keyboard Shortcuts for vimdiff
Diff copying
do - Get changes from other window into the current window.
dp - Put the changes from current window into the other window.
Jump-to-diffs
]c - Jump to the next change.
[c - Jump to the previous change.
Ctrl W + Ctrl W - Switch to the other split window.
[20] fix hg lock
$ rm -r wlock
References
[1] Mercurial: The Definitive Guideby Bryan O'Sullivan http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
[2] http://tortoisehg.bitbucket.org/manual/0.9/changelog.html#sync-bar
[3] Chapter 5 Mercurial in daily use, http://foozy.bitbucket.org/hgbook-ja/d6ca1334a19d/hgbookch5.html
[4] http://stackoverflow.com/a/9617214/432903
[5] Counting changed lines of code over time, http://stackoverflow.com/a/10252342
[6] Mercurial Diff Merge: What tool is this and how do I use it?, http://stackoverflow.com/a/6097728/432903
[7] Quick and Dirty : vimdiff Tutorial, http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html
[8] http://stackoverflow.com/a/2913154/432903
[9]My Mercurial Setup (Plus Some Useful Shims and Jigs), @tednaleid, http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/
@tednaleid
In his book, The Productive Programmer, NealFord(@neal4d) talks about using shims or jigs to help productivity. Jigs and shims are quickly created little snippets of code that automate repetitive tasks or make them easy enough that they’re worth doing. They’re little tools that help make your job easier and let you avoid using brute force to solve all of your problems.
[1] hg color extension
add [extension] color= to ~/.hgrc
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ vi /home/prayag/.hgrc
[ui]
username = prayag
[extensions]
color =
progress =
hgext.extdiff =
hgext.purge=
graphlog =
[extdiff]
cmd.vimdiff =
[2.1] list the repository's named branches
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg branches
default 721:88ddd68c8bd9
feat-x 687:97ace77757da (inactive)
[2.2] show the current branch name
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg branch
default
[3.1] incoming changes with files that will be changed
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg incoming --stat -v
http authorization required
realm: Mercurial repositories
user: prayag
password:
comparing with http://10.X.XXX.X/hg/zazzercode-hg/
searching for changes
all local heads known remotely
changeset: 9:a788c9d9556c
tag: tip
user: pra
date: Thu Feb 28 13:27:56 2013 +0545
files: src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java
description : REFACTOR transactionAPI
src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java | 4 +++
1 files changed, 3 insertions(+), 0 deletions(-)
OR
[3.2] incoming changes for a particular branch with patch(=changed code)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg incoming -b default -v --patch
[4.1] restore a file to it's checkout state
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg revert src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java -r-1
[4.2] revert all changes
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg revert --all
reverting src/main/java/com/zazzercode/eccount/server/api/impl/TransactionApiImpl.java
reverting src/main/java/com/zazzercode/eccount/server/api/ITransactionApi.java
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg pull -v
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg upadate -v
OR a single equivalent command
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg pull -u
_______________________________________________________________________________
_______________________________________________________________________________
[6] hg merge pulled change to local head
It's useful when I have a commit(1693) to push which I did before hg pull(1694).
Verify with commit log
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -G --limit 3
o changeset: 1694:c055f66f64c2
| branch: eccount_merchant
| tag: tip
| parent: 1692:7eef95617dde
| user: albert
| date: Fri Aug 23 17:56:19 2013 +0545
| summary: UPDATE search ui, i18 text, search query condition
|
| @ changeset: 1693:a14ffdea264f
|/ branch: eccount_merchant
| user: prayag<prayag.upd@gmail.com>
| date: Sun Aug 25 11:55:27 2013 +0545
| summary: REFACTOR api-context to fix multiple spring component scan
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg merge
If throws
abort: crosses branches (merge branches or use --clean to discard changes)
OR
abort : outstanding uncommitted changes (use 'hg status' to list changes)
commit changes, revert un-necessary changes and then merge.
$ hg revert -a
$ hg merge
hg status will now show pulled files as uncommited changes, commit them first and then push the previous commit with this new one.
$ hg commit -m "ADD merged files"; //this will commit all modified files
$ hg push
Verify after all these steps are performed correctly,
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -G --limit 3
@ changeset: 1695:11ea43c99d0c
|\ branch: eccount_merchant
| | tag: tip
| | parent: 1693:a14ffdea264f
| | parent: 1694:c055f66f64c2
| | user: prayag<prayag.upd@gmail.com>
| | date: Sun Aug 25 12:33:48 2013 +0545
| | summary: ADD merged changes
| |
| o changeset: 1694:c055f66f64c2
| | branch: eccount_merchant
| | parent: 1692:7eef95617dde
| | user: albert
| | date: Fri Aug 23 17:56:19 2013 +0545
| | summary: UPDATE search ui, i18 text, search query condition
| |
o | changeset: 1693:a14ffdea264f
|/ branch: eccount_merchant
| user: prayag<prayag.upd@gmail.com>
| date: Sun Aug 25 11:55:27 2013 +0545
| summary: REFACTOR api-context to fix multiple component scan
[7] show changed files in the working directory
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg status
OR : show changed files sorting by date
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ ls -t1 `hg st -n -a -m -u` > modified.log
OR
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg diff --git
OR add following conf to ~/.hgrc to enable hg diff for vimdiff
[extensions]
hgext.extdiff =
[extdiff]
cmd.vimdiff =
And then fire command like as below
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg vimdiff build.gradle
OR follow Using vimdiff with mercurial
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg commit zazzercode-gwt/src/main/java/com/zazzercode/client/admin/presenter/UserRolesPresenter.java -m "REMOVE FEATURE of searching User Role, ADD FEATURE of Creating User" -u prayag;
[9] roll back the last transaction (dangerous)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg rollback
repository tip rolled back to revision 736 (undo commit)
[10] Show changesets not found in the specified destination repository
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg outgoing --stat -p
[11] Push changesets from the local repository to the specified destination
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg push -v
OR to track errors during push
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg push -v --debug --traceback
[12] hg log with --limit
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log --verbose --limit 1
changeset: 839:fd570795d841
tag: tip
user: prayag
date: Mon Mar 11 11:56:33 2013 +0545
files: *.*, *.*
summary: FIX slow reporting
OR log with -v (=verbose)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -v --limit 1
OR enable graphLOG extension
[extensions]
color =
graphlog =
and then fire :
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -G --limit 1
OR log of {modified files} for a spec revision(-r)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -r 839 --template '{files}\n'
equivalent to
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -r839 --template '{files}\n'
zazzercode-gwt/src/main/java/com/zazzercode/client/admin/presenter/UserRolesPresenter.java
OR diffs in a spec changeset(-r)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -p -r 839
equivalent to
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg log -p -r839
$ hg log --template '{rev}:{node|short} {desc|firstline}\n' --limit 3
1053:2192d77f22ed ADD if PhoneNumber belongs to a User
1052:7f0d51d09ed4 FIX mobile messages
1051:6da264634482 FIX password to raw
hg log --template "{author|person}\n" | sort | uniq -c | sort -nr
136 prayag
104 hex
OR counting changed lines of code over time
$ echo `hg log -pr tip $@ | grep "^+" | wc -l` Additions;
echo `hg log -pr tip $@ | grep "^-" | wc -l` Deletions
528 Additions
37 Deletions
OR, alias it to .hgrc
[alias]
lines = !echo `hg log -pr $@ | grep "^+" | wc -l` Additions; echo `hg log -pr $@ | grep "^-" | wc -l` Deletions;
[14] search by a commit message
Use -k option followed by search query.
$ log -k FIX --template "{author|person} | {desc}\n"
[14] hg merge from a branch feat-x136 prayag
104 hex
OR counting changed lines of code over time
$ echo `hg log -pr tip $@ | grep "^+" | wc -l` Additions;
echo `hg log -pr tip $@ | grep "^-" | wc -l` Deletions
528 Additions
37 Deletions
OR, alias it to .hgrc
[alias]
lines = !echo `hg log -pr $@ | grep "^+" | wc -l` Additions; echo `hg log -pr $@ | grep "^-" | wc -l` Deletions;
[14] search by a commit message
Use -k option followed by search query.
$ log -k FIX --template "{author|person} | {desc}\n"
Switch to a branch that needs to be merged (say default needs to get changes from branch feat-x)
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg checkout default
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg merge feat-x
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg commit -m "MERGE from feat-x to default";
[15] hg list conflicted files
prayag@Prayag:~/workspace_zazzercodehg/zazzercode-hg$ hg resolve --list
Diff copying
do - Get changes from other window into the current window.
dp - Put the changes from current window into the other window.
Jump-to-diffs
]c - Jump to the next change.
[c - Jump to the previous change.
Ctrl W + Ctrl W - Switch to the other split window.
[20] fix hg lock
$ rm -r wlock
References
[1] Mercurial: The Definitive Guideby Bryan O'Sullivan http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
[2] http://tortoisehg.bitbucket.org/manual/0.9/changelog.html#sync-bar
[3] Chapter 5 Mercurial in daily use, http://foozy.bitbucket.org/hgbook-ja/d6ca1334a19d/hgbookch5.html
[4] http://stackoverflow.com/a/9617214/432903
[5] Counting changed lines of code over time, http://stackoverflow.com/a/10252342
[6] Mercurial Diff Merge: What tool is this and how do I use it?, http://stackoverflow.com/a/6097728/432903
[7] Quick and Dirty : vimdiff Tutorial, http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html
[8] http://stackoverflow.com/a/2913154/432903
[9]My Mercurial Setup (Plus Some Useful Shims and Jigs), @tednaleid, http://naleid.com/blog/2008/11/25/my-mercurial-setup-plus-some-useful-shims-and-jigs/
No comments:
Post a Comment