Reputation: 37
I am only interested in the history of a single file. I tried hg log already, which shows all the changes made to the file. But if there was a branch made of the entire repository, how do I know from log (short of checking out the entire repository in that branch and then looking at the file and manually compare to the different check-ins in head) which version of the file (i.e. at what point along the head) that branch got?
(I have also tried googling to no avail. Maybe I'm not using the right search terms as I am new to Mercurial. I hope I have explained my goal clearly though.)
Thanks a lot in advance!
Upvotes: 0
Views: 982
Reputation: 97280
For Ry4an's text of task revset for log have to be
"max(branch(Y) & contains(X))"
Upvotes: 0
Reputation: 154454
You can use the glog
command:
$ hg glog foo.py
Note that you'll need to enable the graphlog
extension, by adding hgext.graphlog =
to the [extensions]
heading of your ~/.hgrc
:
$ cat ~/.hgrc
[extensions]
hgext.graphlog =
…
$
A simple, manual, way to figure out when a branch was taken is to run:
$ hg glog
Then search for the filename and see which changesets it's changed in.
Alternatively, you could run:
hg log -r 'ancestors(mybranch)' myfile
To show you all the changesets both in and before mybranch which contain changes to myfile
, then look for the last changeset that modifies the file before the branch was taken:
$ hg log -r 'ancestors(mybranch)' myfile changeset: 30:3b2f7243c1ac user: David Wolever <[email protected]> date: Mon Nov 15 09:47:46 2010 -0500 files: myfile description: doing stuff changeset: 31:804257c328ab <-- last change to the file before the branch user: David Wolever <[email protected]> date: Thu Nov 18 21:44:11 2010 -0500 files: myfile description: changing things changeset: 32:df26ccd32c38 <-- change was made to the file in the branch branch: mybranch user: David Wolever <[email protected]> date: Thu Nov 18 23:23:44 2010 -0500 files: myfile anotherfile description: starting mybranch
Upvotes: 0
Reputation: 9058
Not sure whether this is what you want, but you can list all revisions that contain a specific filename using either
hg log -r "contains(filename)"
or
hg glog -r "contains(filename)"
If you want something more specific, check out the hg help revsets
output, which shows the possibilities of the -r
option.
Upvotes: 0
Reputation: 78330
You're thinking in 'svn' (or CSV) terms. Your question doesn't make sense in the context of Mercurial (or git). Individual files don't have versions in either of these DVCSs. Versions are called revisions and are repository-wide. You can't "checkout" revision X of one file and revision Y of another like you can in svn.
So a question similar to yours what would make sense might be "What revision most recently change file X in branch Y" and one way to get that answer would be:
hg log -r 'ancestors(Y)' X
or
hg log -r 'ancestors(default)' TODO
with some concrete values.
Upvotes: 1