Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get file create/update time in mercurial?

I'm writing my blog system(django), and my blog files are VCSed by mercurial,

I want get files create/update time, how could I do this by using commandline or python?

edit: this is a example:

$ SOME_COMMAND
xxx.txt 2010-12-13-04:12:12 2010-12-14:04:12:12
xyx.txt 2010-12-13-04:12:12 2010-12-14:04:12:12
xxy.txt 2010-12-13-04:12:12 2010-12-14:04:12:12
yxx.txt 2010-12-13-04:12:12 2010-12-14:04:12:12
yyx.txt 2010-12-13-04:12:12 2010-12-14:04:12:12
like image 694
linjunhalida Avatar asked Oct 28 '10 02:10

linjunhalida


People also ask

What is hg update?

Use the command hg update to switch to an existing branch. Use hg commit --close-branch to mark this branch head as closed. When all heads of a branch are closed, the branch will be considered closed. Returns 0 on success.

What hg command saves changes to history?

A quick overview of the basic commands: hg init: create a new repository. hg commit: save your changes in the current repository.

How do you Uncommit in Heartgold?

A simple way to 'uncommit' your last commit is to use hg strip -r -1 -k. In case the link breaks, the documentation mentioned by @phb states: hg rollback Roll back the last transaction (DANGEROUS) (DEPRECATED) Please use 'hg commit --amend' instead of rollback to correct mistakes in the last commit.


1 Answers

To get the most recent modification time of a file:

hg log --template '{date}' -l 1 path/to/file

and to get the creation time:

hg log --template '{date}' -r 0:tip -l 1 README

Example output:

$ hg log --template '{date}' -r 0:tip -l 1 README
1115154970.028800

$ hg log --template '{date}' -l 1 README
1255462070.025200

Those date values are unix epoc seconds followed by a dot and a timezone offset. You can pretty format them using various filters described in hg help templates like this:

$ hg log --template '{date|rfc822date}' -l 1 README
Tue, 13 Oct 2009 12:27:50 -0700
like image 55
Ry4an Brase Avatar answered Sep 18 '22 02:09

Ry4an Brase