Guest User

Untitled

a guest
May 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <link rel="stylesheet" href="example.css?{% mercurial_revision "example.css" %}" />
  2.  
  3. import subprocess
  4.  
  5. def get_hg_rev(file_path):
  6. pipe = subprocess.Popen(
  7. ["hg", "log", "-l", "1", "--template", "{node}", file_path],
  8. stdout=subprocess.PIPE
  9. )
  10. return pipe.stdout.read()
  11.  
  12. > path_to_file = "/home/jim/workspace/lgr/pinax/projects/lgr/site_media/base.css"
  13. > get_hg_rev(path_to_file)
  14. '0ed525cf38a7b7f4f1321763d964a39327db97c4'
  15.  
  16. from mercurial import ui, hg
  17. from mercurial.node import hex
  18.  
  19. repo = hg.repository('/path/to/repo/root', ui.ui())
  20. fctx = repo.filectx('/path/to/file', 'tip')
  21. hexnode = hex(fctx.node())
Add Comment
Please, Sign In to add comment