]> arthur.barton.de Git - bup.git/commitdiff
save: make the py3 save commit message args match py2
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 4 Aug 2020 14:46:16 +0000 (16:46 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 8 Aug 2020 17:11:25 +0000 (12:11 -0500)
We shouldn't use sys.argv, it's missing the actual arguments
now. Also, encode it but drop the "b" on the bytes (if present,
i.e. python3) to make this look the same as on python2.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
[rlb@defaultvalue.org: make formatting decision via py_maj; adjust
 commit message]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/cmd/save-cmd.py

index 5cdedf65f1c10bdb362802d7cb3f1bb034229271..37155cb2e2a66ca68e4808790d828836e397be20 100755 (executable)
@@ -487,8 +487,13 @@ if opt.tree:
     out.write(hexlify(tree))
     out.write(b'\n')
 if opt.commit or name:
-    msg = (b'bup save\n\nGenerated by command:\n%r\n'
-           % [argv_bytes(x) for x in sys.argv])
+    if compat.py_maj > 2:
+        # Strip b prefix from python 3 bytes reprs to preserve previous format
+         msgcmd = b'[%s]' % b', '.join([repr(argv_bytes(x))[1:].encode('ascii')
+                                       for x in compat.argv])
+    else:
+        msgcmd = repr(compat.argv)
+    msg = b'bup save\n\nGenerated by command:\n%s\n' % msgcmd
     userline = (b'%s <%s@%s>' % (userfullname(), username(), hostname()))
     commit = w.new_commit(tree, oldref, userline, date, None,
                           userline, date, None, msg)