Changeset 181 in tracdarcs


Ignore:
Timestamp:
06/10/10 17:03:39 (3 years ago)
Author:
lele@…
Hash name:
20100610150339-97f81-cd1b73f2ba1b1d98c28542ecbd1d5e2bd9052056
Message:

Helper for the repository's posthook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tracdarcs/changesparser.py

    r176 r181  
    136136            log.warning('-'*(e._colnum-1)+'^'*5) 
    137137    return handler.patches 
     138 
     139# Aid for the repository posthook: since Trac 0.12 the preferred way 
     140# to trigger a syncronization is "trac-admin $ENV changeset added ..." 
     141# 
     142# With darcs, this can be achieved by putting something like 
     143# 
     144#  apply posthook trac-admin /path/to/trac/env changeset added $(pwd) $(python -m tracdarcs.changesparser) 
     145#  apply run-posthook 
     146# 
     147# into the repository's `_darcs/prefs/defaults` configuration. 
     148 
     149if __name__ == '__main__': 
     150    from logging import basicConfig, root as log 
     151    from os import environ 
     152    import sys 
     153 
     154    basicConfig() 
     155 
     156    # If invoked by a darcs posthook, the text to parse comes 
     157    # from the $DARCS_PATCHES_XML envvar. Otherwise slurp it 
     158    # from the stdin. 
     159 
     160    if 'DARCS_PATCHES_XML' in environ: 
     161        changes = environ['DARCS_PATCHES_XML'] 
     162    else: 
     163        changes = sys.stdin.read() 
     164 
     165    if len(sys.argv)>1: 
     166        output = open(sys.argv[1], 'w') 
     167    else: 
     168        output = sys.stdout 
     169 
     170    for patch in parse_changes(changes, log): 
     171        print >>output, patch.hash 
     172 
     173    output.close() 
Note: See TracChangeset for help on using the changeset viewer.