[PATCH 0 of 6] mq: handle the User and Date fields consistently in qrefresh, v5

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Mon Aug 10 21:52:30 UTC 2009


This patch series makes mq consitently handle the author and date fields
when qrefresh-ing patches.

This patch series is against the selenic repository, tell me if you want
it against the crew repos...


First patch fixes an obvious coding style issue (missing space after
comma) in the code that updates an existing '# User' field.

Second patch simplifies the code for updateheader, to get rid of a temporary
variable, and to return as soon as we know the result.

Third patch adds the private function _hasheader to the class patchheader.
This function works a bit like the updateheader function, but does no
replacement.  It takes a list of prefixes as argument, and returns true if
a header in the patch starts with any of the given prefixes, false otherwise.
That way, we can deduce from existence/abscence of a header if the patch is
in the email-like or in the extended format, and it will be used by the next
patches.

Fourth patch correctly sets the author field (either 'From:' or '# User'),
trying to keep the _existing_ email-like format, or upgrading to extended
otherwise. It works like that:
- first, try to update any of the above-mentioned existing field
- if it fails:
  - check if the patch is already in extended format, and if so adds an
    extended '# User' field
  - if not in extended format, then
    - checks if a 'Date:' field exists, and if so, adds an email-like
      'From:' field
    - else, upgrade the patch to extended format, and add a '# User'
      field
At the same time, update the test-suite to match (maybe incomplete?).

Fifth patch applies the above reasoning to the date field.  This patch comes
in response to issue #1768:
  mq: use date from last qrefresh as commit date, not date from last qpush
  http://mercurial.selenic.com/bts/issue1768

Sixth patch re-phrases the help entries for the [-u|-U] and [-d|-D] options,
to be in-line with what actually happens: adding/setting the date/user won't
necessarily add an email-like header, but can add an HG extended format
header.


Changes since v4:
- simplify code for updateheader and _hasheader

Changes since v3:
- use temporaries rather than linewrapping
- re-phrase qrefresh help entries about [-d|-D] and [-u|-U]

Changes since v2:
- keep patch in the _existing_ email-like format, upgrading to the extended
  format if no field already present
- update testsuite to match (maybe incomplete?)
  ( Cheers, Cedric! ;-) )

Changes since v1:
- fix coding style errors
- fix comment message


PS. I've patch-bombed this list quite a bit, lately.
    I'm sorry for the extra noise.
    I'll go to sleep, now. :-)




More information about the Mercurial-devel mailing list