diff options
author | http://christian.amsuess.com/chrysn <chrysn@web> | 2012-11-22 03:14:45 +0000 |
---|---|---|
committer | admin <admin@branchable.com> | 2012-11-22 03:14:45 +0000 |
commit | 2ba03a95a6c9adb920a0308e1c5a89dda46a09cd (patch) | |
tree | 341b65cde451839ea0ec4c075f730cf6dc583022 | |
parent | 953edfb41218897c7597460211514e15df02aafb (diff) |
Added a comment: single-line migration
-rw-r--r-- | doc/bugs/using_old_remote_format_generates_irritating_output/comment_5_7438caecf78b4fb5d21f9f31dff95cf2._comment | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/bugs/using_old_remote_format_generates_irritating_output/comment_5_7438caecf78b4fb5d21f9f31dff95cf2._comment b/doc/bugs/using_old_remote_format_generates_irritating_output/comment_5_7438caecf78b4fb5d21f9f31dff95cf2._comment new file mode 100644 index 000000000..707ea52cf --- /dev/null +++ b/doc/bugs/using_old_remote_format_generates_irritating_output/comment_5_7438caecf78b4fb5d21f9f31dff95cf2._comment @@ -0,0 +1,14 @@ +[[!comment format=mdwn + username="http://christian.amsuess.com/chrysn" + nickname="chrysn" + subject="single-line migration" + date="2012-11-22T03:14:45Z" + content=""" +i've successfully applied this monster to migrate my repository (as always with such expressions, use it only if you know what it does, and have a backup): + + find . -path './??/??/*' -type d \( -exec python -c 'import sys, hashlib, os; hash = hashlib.md5(sys.argv[1][8:]).hexdigest(); h1 = hash[:3]; h2 = hash[3:6]; os.mkdir(h1) if not os.path.exists(h1) else None; os.mkdir(h1+\"/\"+h2) if not os.path.exists(h1+\"/\"+h2) else None; os.rename(sys.argv[1], h1+\"/\"+h2+\"/\"+sys.argv[1][8:])' '{}' ';' -o -print \) -prune + +when executed in an encrypted git annex object directory, it takes all two-letter directories, executes a python expression on them (in case of failure, printing the file name it failed on), and doesn't continue searching there (-prune avoids error messages about moved-away directories). + +the python expression itself generates the hash described above, generates the required directories (put awkwardly in an `a if b else c` expression to avoid ifs (which wouldn't fit in a single line) and because python still doesn't have a proper mkdir-p function), and moves the found object there. (nb: using the system's `mkdir -p` would trigger [[another bug|bugs/using_old_remote_format_generates_irritating_output]]). +"""]] |