2015-03-19 21:05:02 +03:00
|
|
|
$ extpath=$(dirname $TESTDIR)
|
|
|
|
$ cp $extpath/githelp.py $TESTTMP # use $TESTTMP substitution in message
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
|
|
|
> githelp=$TESTTMP/githelp.py
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ hg init repo
|
|
|
|
$ cd repo
|
Have githelp for checkout guess whether the first argument is a path or rev
Summary:
The command `git checkout foo` uses a heuristic to determine whether to treat
'foo' as a revision or a path. We try to mimic that behavior as best we can, but
there will still be corner cases where it does not work.
In particular, if there is a file that is present in a previous revision but not
the current one, this will incorrectly assume that it's a revision.
Test Plan:
Added tests to make sure that it behaves properly for untracked files, tracked
files, deleted files, removed files, and names which are both revisions and
files.
Reviewers: durham, sid0, mitrandir, rmcelroy
Reviewed By: rmcelroy
Subscribers: elenapr
Differential Revision: https://phabricator.fb.com/D1996393
Tasks: 6751516
Signature: t1:1996393:1429306520:2f13c194a8fe2a721bac501c5479250b2afe3f9e
2015-04-18 00:25:12 +03:00
|
|
|
$ echo foo > test_file
|
|
|
|
$ mkdir dir
|
|
|
|
$ echo foo > dir/file
|
|
|
|
$ echo foo > removed_file
|
|
|
|
$ echo foo > deleted_file
|
|
|
|
$ hg add -q .
|
|
|
|
$ hg commit -m 'bar'
|
|
|
|
$ hg bookmark both
|
|
|
|
$ touch both
|
|
|
|
$ touch untracked_file
|
|
|
|
$ hg remove removed_file
|
|
|
|
$ rm deleted_file
|
2015-03-19 21:05:02 +03:00
|
|
|
|
|
|
|
githelp on a single command should succeed
|
|
|
|
$ hg githelp -- commit
|
|
|
|
hg commit
|
|
|
|
|
|
|
|
githelp on a command with options should succeed
|
|
|
|
$ hg githelp -- commit -pm "abc"
|
|
|
|
hg record -m 'abc'
|
|
|
|
|
|
|
|
githelp on a command with standalone unrecognized option should succeed with warning
|
|
|
|
$ hg githelp -- commit -p -v
|
|
|
|
ignoring unknown option -v
|
|
|
|
hg record
|
|
|
|
|
|
|
|
githelp on a command with unrecognized option packed with other options should fail with error
|
|
|
|
$ hg githelp -- commit -pv
|
|
|
|
abort: unknown option v packed with other options
|
|
|
|
Please try passing the option as it's own flag: -v
|
|
|
|
|
|
|
|
If this is a valid git command, please log a task for the source_control oncall.
|
|
|
|
|
|
|
|
[255]
|
2015-03-26 22:48:36 +03:00
|
|
|
githelp for git rebase --skip
|
|
|
|
$ hg githelp -- git rebase --skip
|
|
|
|
hg revert --all -r .
|
|
|
|
hg rebase --continue
|
|
|
|
|
2015-04-13 20:47:34 +03:00
|
|
|
githelp for git commit --amend (hg commit --amend pulls up an editor)
|
|
|
|
$ hg githelp -- commit --amend
|
|
|
|
hg commit --amend
|
|
|
|
|
|
|
|
githelp for git commit --amend --no-edit (hg amend does not pull up an editor)
|
|
|
|
$ hg githelp -- commit --amend --no-edit
|
|
|
|
hg amend
|
2015-04-14 00:57:52 +03:00
|
|
|
|
|
|
|
githelp for git checkout -- . (checking out a directory)
|
|
|
|
$ hg githelp -- checkout -- .
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert .
|
|
|
|
|
|
|
|
githelp for git checkout HEAD^ (should still work to pass a rev)
|
|
|
|
$ hg githelp -- checkout HEAD^
|
|
|
|
hg update .^
|
|
|
|
|
|
|
|
githelp checkout: args after -- should be treated as paths no matter what
|
|
|
|
$ hg githelp -- checkout -- HEAD
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert HEAD
|
|
|
|
|
|
|
|
githelp for git checkout with rev and path
|
|
|
|
$ hg githelp -- checkout HEAD^ -- file.txt
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert -r .^ file.txt
|
|
|
|
|
|
|
|
githelp for git with rev and path, without separator
|
|
|
|
$ hg githelp -- checkout HEAD^ file.txt
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert -r .^ file.txt
|
Have githelp for checkout guess whether the first argument is a path or rev
Summary:
The command `git checkout foo` uses a heuristic to determine whether to treat
'foo' as a revision or a path. We try to mimic that behavior as best we can, but
there will still be corner cases where it does not work.
In particular, if there is a file that is present in a previous revision but not
the current one, this will incorrectly assume that it's a revision.
Test Plan:
Added tests to make sure that it behaves properly for untracked files, tracked
files, deleted files, removed files, and names which are both revisions and
files.
Reviewers: durham, sid0, mitrandir, rmcelroy
Reviewed By: rmcelroy
Subscribers: elenapr
Differential Revision: https://phabricator.fb.com/D1996393
Tasks: 6751516
Signature: t1:1996393:1429306520:2f13c194a8fe2a721bac501c5479250b2afe3f9e
2015-04-18 00:25:12 +03:00
|
|
|
|
|
|
|
githelp for checkout with a file as first argument
|
|
|
|
$ hg githelp -- checkout test_file
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert test_file
|
|
|
|
|
|
|
|
githelp for checkout with a removed file as first argument
|
|
|
|
$ hg githelp -- checkout removed_file
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert removed_file
|
|
|
|
|
|
|
|
githelp for checkout with a deleted file as first argument
|
|
|
|
$ hg githelp -- checkout deleted_file
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert deleted_file
|
|
|
|
|
|
|
|
githelp for checkout with a untracked file as first argument
|
|
|
|
$ hg githelp -- checkout untracked_file
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert untracked_file
|
|
|
|
|
|
|
|
githelp for checkout with a directory as first argument
|
|
|
|
$ hg githelp -- checkout dir
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert dir
|
|
|
|
|
|
|
|
githelp for checkout when not in repo root
|
|
|
|
$ cd dir
|
|
|
|
$ hg githelp -- checkout file
|
|
|
|
note: use --no-backup to avoid creating .orig files
|
|
|
|
|
|
|
|
hg revert file
|
|
|
|
|
|
|
|
githelp for checkout with an argument that's both a file and a revision
|
|
|
|
$ hg githelp -- checkout both
|
|
|
|
hg update both
|
2015-04-21 20:21:17 +03:00
|
|
|
|
|
|
|
githelp for grep with pattern and path
|
|
|
|
$ hg githelp -- grep shrubbery flib/intern/
|
|
|
|
hg grep shrubbery flib/intern/
|