]> arthur.barton.de Git - bup.git/blobdiff - cmd/save-cmd.py
compat.hexstr: add and use
[bup.git] / cmd / save-cmd.py
index 91d01ca84912dfa2f0e5ca5a1069f816fc06ede6..04cf55d0e043135697c4467b4b1536a7489ebfe1 100755 (executable)
@@ -5,7 +5,7 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 from errno import EACCES
 from io import BytesIO
 import os, sys, stat, time, math
@@ -16,7 +16,8 @@ from bup.helpers import (add_error, grafted_path_components, handle_ctrl_c,
                          hostname, istty2, log, parse_date_or_fatal, parse_num,
                          path_components, progress, qprogress, resolve_parent,
                          saved_errors, stripped_path_components,
-                         userfullname, username, valid_save_name)
+                         valid_save_name)
+from bup.pwdgrp import userfullname, username
 
 
 optspec = """
@@ -107,7 +108,6 @@ def eatslash(dir):
     else:
         return dir
 
-
 # Metadata is stored in a file named .bupm in each directory.  The
 # first metadata entry will be the metadata for the current directory.
 # The remaining entries will be for each of the other directory
@@ -348,7 +348,8 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
         dir_name, fs_path = path_component
         # Not indexed, so just grab the FS metadata or use empty metadata.
         try:
-           meta = metadata.from_path(fs_path) if fs_path else metadata.Metadata()
+            meta = metadata.from_path(fs_path, normalized=True) \
+                if fs_path else metadata.Metadata()
         except (OSError, IOError) as e:
             add_error(e)
             lastskip_name = dir_name
@@ -425,7 +426,8 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
             sort_key = git.shalist_item_sort_key((ent.mode, file, id))
             hlink = find_hardlink_target(hlink_db, ent)
             try:
-                meta = metadata.from_path(ent.name, hardlink_target=hlink)
+                meta = metadata.from_path(ent.name, hardlink_target=hlink,
+                                          normalized=True)
             except (OSError, IOError) as e:
                 add_error(e)
                 lastskip_name = ent.name
@@ -453,14 +455,14 @@ tree = _pop(force_tree = None,
             dir_metadata = metadata.Metadata() if root_collision else None)
 
 if opt.tree:
-    print tree.encode('hex')
+    print(tree.encode('hex'))
 if opt.commit or opt.name:
     msg = 'bup save\n\nGenerated by command:\n%r\n' % sys.argv
     userline = '%s <%s@%s>' % (userfullname(), username(), hostname())
     commit = w.new_commit(tree, oldref, userline, date, None,
                           userline, date, None, msg)
     if opt.commit:
-        print commit.encode('hex')
+        print(commit.encode('hex'))
 
 msr.close()
 w.close()  # must close before we can update the ref