View a changeset using mercurial - mercurial

How do I view a changeset of a mercurial repository.
I want to get the same output I get with
git show <commit>
How do I do this with hg?

The git show command for commits shows log message and diff. The equivalent Mercurial command could be:
hg log -p -r <REV>
Remember that in Mercurial can refer to a local revision number, changeset, tag, a rangeset of revision numbers ... see the manual page for details and more options.

Related

Mercurial - How do I diff with a previous version?

I'm using the command
hg kdiff3 filename
to visualize differences between my current status and what's pushed in the master repository.
If I was to see the differences between a specific revision (say 5 commits back) and the current, how would I do it?
To see the changes between two versions of a file in the repository:
hg kdiff3 -r 4 filename
where the current version is assumed to be the "other" changeset. If you want to compare two past revisions:
hg log filename
hg kdiff3 -r2 -r7 filename
where the revision numbers -r2 -r7 are drawn from the changeset log.

How to clone partially using TortoiseHG "Clone" on bitbucket?

I want to clone part of repository to non-tip changeset, so I use TortoiseHG -> Clone command, enter commit URL and clone. For some reason I get the clone to the last changeset, not that I wanted to clone.
How to clone to old changeset?
I've read that I can do this with git commands. Can I do it with TortoiseHG?
You clone not "commit", but "repository"
If you want to have partial clone, you have to read hg help clone
Procedure and syntax is common to all and any repositories, unrelated to BitBucket
To pull only a subset of changesets, specify one or more revisions
identifiers with -r/--rev or branches with -b/--branch. The resulting
clone will contain only the specified changesets and their ancestors.
hg clone -r <ID> SRC
hg help urls suggests second form of command
hg clone SRC#ID
GUI-way
In case of pure GUI in TortoiseHG "Clone" dialogue, expand "Options" enable "Clone to revision" and define this revision ID

Get tip changeset of remote Mercurial repository

My .hg/hgrc file has the line:
default = http://some/remote/repository
Is there a quick command to print the tip revision of that repository (which may or may not be inside my local repository)?
You can use the identify command like this:
$ hg identify $(hg paths default)
This is one of the few commands that can operate on a remote repository. If you need more information about the remote repository, then I suggest you take a look at hg incoming.
The following returns the latest changeset number (tip) of a remote repository:
hg identify --id http://www.myrepo.com
hg id default
This is a shorter form of "hg identify $(hg paths default)".

Mercurial reporting - Revision and file change report available?

I'm looking for a way to view all of a repository's branches and each file that has changed in that branch. I'm not interested in the file level changes as this report is for simple auditing.
Can this be done?
hg log -b <branchname> --template "{files} "
Plus some post-processing, because output will be like this
lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php plugins/serendipity_event_assigncategories/UTF-8/lang_ru.inc.php plugins/serendipity_event_entryproperties/UTF-8/lang_ru.inc.php plugins/serendipity_event_freetag/UTF-8/lang_ru.inc.php plugins/serendipity_event_gravatar/UTF-8/lang_ru.inc.php plugins/serendipity_event_relatedlinks/UTF-8/lang_ru.inc.php plugins/serendipity_event_nl2br/UTF-8/lang_ru.inc.php plugins/serendipity_event_freetag/UTF-8/lang_ru.inc.php
Use hg status to get information about files that have changed between revisions. See the revset language for how to select the revisions.
If you want to see file changes between the first and last changesets on branch B:
$ hg status --rev "min(branch(B)):max(branch(B))"
You can even make an alias for this:
[alias]
audit = status --rev "min(branch($1)):max(branch($1))"
and then use hg audit B to get the same result.

Mercurial Newbie confused

I am familiar with TFS and Vault, but having just started using Mercurial I seem to be getting into a bit of a mess.
Heres what I (think) I've done:
-Created a central repository on bitbucket.org
-On my desktop PC, cloned repository from bitbucket, added files, commit them, push them to bitbucket
-On my laptop, cloned repository from bitbucket, pulled files, added more files, commit them, push them to bitbucket
I've continued to add, edit etc on the different computers.
Now I've noticed that some files from each computer are not in the bitbucket repository, and therefore only in the local repository. No amount of pulling and pushing seems to get it into the bitbucket repository.
What is the most likely thing I've done wrong?
Is there a way to 'force' by changes up to the bitbucket repository?
Did they get into your local repository? I suspect not, i.e. they were new files that were not added to the commit. Use hg add to add them to the changeset before committing or whatever the equivalent is for whatever mercurial interface you're using.
Edit:
Here's the help from Mercurial:
C:\Users\Bert>hg add --help
hg add [OPTION]... [FILE]...
add the specified files on the next commit
Schedule files to be version controlled and added to the repository.
The files will be added to the repository at the next commit. To undo an
add before that, see "hg forget".
If no names are given, add all files to the repository.
...
See Mercurial: The Definitive Guide (a.k.a. the hg "red book") for more info:
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
Telling Mercurial which files to track
Mercurial does not work with files in your repository unless you tell it to manage them. The hg status command will tell you which files Mercurial doesn't know about; it uses a “?” to display such files.
To tell Mercurial to track a file, use the hg add command. Once you have added a file, the entry in the output of hg status for that file changes from “?” to “A”.
$ hg init add-example
$ cd add-example
$ echo a > myfile.txt
$ hg status
? myfile.txt
$ hg add myfile.txt
$ hg status
A myfile.txt
$ hg commit -m 'Added one file'
$ hg status
use "hg -v help add" to show global options