]> arthur.barton.de Git - bup.git/commitdiff
Handle commit mergetags (at all)
authorRob Browning <rlb@defaultvalue.org>
Fri, 12 Apr 2019 19:55:13 +0000 (14:55 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 12 Apr 2019 19:55:24 +0000 (14:55 -0500)
Previously bup would just crash (i.e. bup ls) if it encountered a
commit with a mergetag header (apparently a new thing).  For now,
adjust git.parse_commit to accept and ignore them as long as they only
appear as an optional, final header in the commit.  That may or may
not turn out to be sufficient, and it does mean that for now we won't
be able to preserve mergetags (if we want to) whenever we rewrite
commits via bup gc, get, etc.

A mergetag example (indented two spaces):

  tree 1ebcecb7117725fd567de6e9652dc34b5b103f6d
  parent d3e6b8a251634ad673242aaa4a298edbb2e8ee39
  parent 3a34412caae002accd0fc7a7fc0b718c2f34159b
  author Rob Browning <rlb@defaultvalue.org> 1498341839 -0500
  committer Rob Browning <rlb@defaultvalue.org> 1498341839 -0500
  mergetag object 3a34412caae002accd0fc7a7fc0b718c2f34159b
   type commit
   tag emacs-25.2
   tagger Nicolas Petton <nicolas@petton.fr> 1492704766 +0200

   Emacs 25.2 release
   -----BEGIN PGP SIGNATURE-----
   Version: GnuPG v2

   iQEcBAABCAAGBQJY+N4EAAoJECM1h6R8IHkQFeEH/2FlBZSzsxNnXcMLVNirG0Uu
   8CBEAlme4LcViKs6Ae2uzPP4DrwN1g4LLNGnHBYQoL5nzwPtNOLDjaVtB2D7Q5Lj
   OgtiLix5kHNXh6j2GRnCHI5a6h52FY0yiaslefbstVu554S+1ttDbmqCgo5wtzFM
   eSPbxjLn1SrXSe9Mpfi/tBM2go7J4bihF6GyUktObwAkhOCz3ctJGTMltHzub1RC
   fZBku7bYjgbJocKJ+8MyfcgGz8sb1lV6jeJ9Yu+FuO6PIH9JtHZkjYbFhXqV8TxU
   vHfiCD8QK8w3SJ4RiMltfaFqhc0LFt1mUYOtHzwMbML8nqDV9SfozG7APN7f4OE=
   =oY2c
   -----END PGP SIGNATURE-----

  Merge upstream version 25.2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/git.py

index 23fadb3866bb40cd94974042fa6e192300cc600a..3c88d74f8b02ad6b6ef1c8e14cd10f9e255835d1 100644 (file)
@@ -76,17 +76,21 @@ _safe_str_rx = '(?:%s{1,2}|(?:%s%s*%s))' \
        _start_end_char, _content_char, _start_end_char)
 _tz_rx = r'[-+]\d\d[0-5]\d'
 _parent_rx = r'(?:parent [abcdefABCDEF0123456789]{40}\n)'
+# Assumes every following line starting with a space is part of the
+# mergetag.  Is there a formal commit blob spec?
+_mergetag_rx = r'(?:\nmergetag object [abcdefABCDEF0123456789]{40}(?:\n [^\0\n]*)*)'
 _commit_rx = re.compile(r'''tree (?P<tree>[abcdefABCDEF0123456789]{40})
 (?P<parents>%s*)author (?P<author_name>%s) <(?P<author_mail>%s)> (?P<asec>\d+) (?P<atz>%s)
-committer (?P<committer_name>%s) <(?P<committer_mail>%s)> (?P<csec>\d+) (?P<ctz>%s)
+committer (?P<committer_name>%s) <(?P<committer_mail>%s)> (?P<csec>\d+) (?P<ctz>%s)(?P<mergetag>%s?)
 
 (?P<message>(?:.|\n)*)''' % (_parent_rx,
                              _safe_str_rx, _safe_str_rx, _tz_rx,
-                             _safe_str_rx, _safe_str_rx, _tz_rx))
+                             _safe_str_rx, _safe_str_rx, _tz_rx,
+                             _mergetag_rx))
 _parent_hash_rx = re.compile(r'\s*parent ([abcdefABCDEF0123456789]{40})\s*')
 
-
-# Note that the author_sec and committer_sec values are (UTC) epoch seconds.
+# Note that the author_sec and committer_sec values are (UTC) epoch
+# seconds, and for now the mergetag is not included.
 CommitInfo = namedtuple('CommitInfo', ['tree', 'parents',
                                        'author_name', 'author_mail',
                                        'author_sec', 'author_offset',