]> arthur.barton.de Git - bup.git/blobdiff - cmd/tag-cmd.py
tvfs: accommodate python 3 and test there
[bup.git] / cmd / tag-cmd.py
index 5a3108f2236c0d9ba291acbae0e350cf41a6cf58..2fc068ddc7189eb535a31def25681480fc7cc9cb 100755 (executable)
@@ -1,13 +1,15 @@
-#!/usr/bin/env python
-"""Tag a commit in the bup repository.
-Creating a tag on a commit can be used for avoiding automatic cleanup from
-removing this commit due to old age.
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
 """
-import sys
-import os
+# end of bup preamble
+
+from __future__ import absolute_import, print_function
+import os, sys
 
 from bup import git, options
-from bup.helpers import *
+from bup.helpers import debug1, handle_ctrl_c, log
 
 # FIXME: review for safe writes.
 
@@ -16,10 +18,10 @@ handle_ctrl_c()
 optspec = """
 bup tag
 bup tag [-f] <tag name> <commit>
-bup tag -d [-f] <tag name>
+bup tag [-f] -d <tag name>
 --
 d,delete=   Delete a tag
-f,force     Overwrite existing tag, or 'delete' a tag that doesn't exist
+f,force     Overwrite existing tag, or ignore missing tag when deleting
 """
 
 o = options.Options(optspec)
@@ -43,7 +45,7 @@ if opt.delete:
 
 if not extra:
     for t in tags:
-        print t
+        print(t)
     sys.exit(0)
 elif len(extra) < 2:
     o.fatal('no commit ref or hash given.')
@@ -62,7 +64,7 @@ if tag_name.startswith('.'):
 
 try:
     hash = git.rev_parse(commit)
-except git.GitError, e:
+except git.GitError as e:
     log("bup: error: %s" % e)
     sys.exit(2)
 
@@ -77,8 +79,8 @@ if not pL.exists(hash):
 
 tag_file = git.repo('refs/tags/%s' % tag_name)
 try:
-    tag = file(tag_file, 'w')
-except OSError, e:
+    tag = open(tag_file, 'w')
+except OSError as e:
     log("bup: error: could not create tag '%s': %s" % (tag_name, e))
     sys.exit(3)