Skip to content

Instantly share code, notes, and snippets.

@deanmalmgren
Last active December 31, 2015 20:29
Show Gist options
  • Save deanmalmgren/8040209 to your computer and use it in GitHub Desktop.
Save deanmalmgren/8040209 to your computer and use it in GitHub Desktop.
Change the timestamps of all files managed in a mercurial repository to the last modified time recorded in the repository. This is useful, for example, when multiple people are using the same Makefile to run a data workflow
#!/bin/bash
cd $(hg root)
for f in $(hg st -A | awk '{if($1!="I") print $2}'); do
# http://stackoverflow.com/a/4039466/564709
t=$(hg log -l1 --template '{date|isodate}' $f | awk '{d=$1; gsub(/-/,"",d); t=$2; sub(/:/,"",t); printf("%s%s", d, t)}')
# http://stackoverflow.com/a/6839855/564709
touch -t $t $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment