Ticket #12082: fixdate.sh

File fixdate.sh, 376 bytes (added by jdemeyer, 10 years ago)

Shell script to change modification time of Mercurial-tracked files to the time of last commit

Line 
1#!/bin/bash
2
3hg status --all |sed -n 's/^C //p' | \
4while read file
5do
6    date=`hg log $file |sed -n 's/^date: *//; T; s/ \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\) \([0-9]*\) / \2 \1/p; q;'`
7    echo "$date $file"
8    touch "--date=$date" $file
9done
10
11find . -type d |tac | \
12while read dir
13do
14        newestfile=`ls -1 -A --sort=time $dir |head -n1`
15        touch -r $dir/$newestfile $dir
16done