comparison mercurial/commands.py @ 17292:8da6fe276a23 stable

debugobsolete: do not traceback on invalid node identifiers
author Patrick Mezard <patrick@mezard.eu>
date Mon, 30 Jul 2012 19:26:05 +0200
parents 4e35dea77e31
children e51d4aedace9
comparison
equal deleted inserted replaced
17291:2d6bbf87f7b4 17292:8da6fe276a23
2065 2065
2066 @command('debugobsolete', [] + commitopts2, 2066 @command('debugobsolete', [] + commitopts2,
2067 _('[OBSOLETED [REPLACEMENT] [REPL... ]')) 2067 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2068 def debugobsolete(ui, repo, precursor=None, *successors, **opts): 2068 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2069 """create arbitrary obsolete marker""" 2069 """create arbitrary obsolete marker"""
2070 def parsenodeid(s):
2071 try:
2072 # We do not use revsingle/revrange functions here to accept
2073 # arbitrary node identifiers, possibly not present in the
2074 # local repository.
2075 n = bin(s)
2076 if len(n) != len(nullid):
2077 raise TypeError()
2078 return n
2079 except TypeError:
2080 raise util.Abort('changeset references must be full hexadecimal '
2081 'node identifiers')
2082
2070 if precursor is not None: 2083 if precursor is not None:
2071 metadata = {} 2084 metadata = {}
2072 if 'date' in opts: 2085 if 'date' in opts:
2073 metadata['date'] = opts['date'] 2086 metadata['date'] = opts['date']
2074 metadata['user'] = opts['user'] or ui.username() 2087 metadata['user'] = opts['user'] or ui.username()
2075 succs = tuple(bin(succ) for succ in successors) 2088 succs = tuple(parsenodeid(succ) for succ in successors)
2076 l = repo.lock() 2089 l = repo.lock()
2077 try: 2090 try:
2078 tr = repo.transaction('debugobsolete') 2091 tr = repo.transaction('debugobsolete')
2079 try: 2092 try:
2080 repo.obsstore.create(tr, bin(precursor), succs, 0, metadata) 2093 repo.obsstore.create(tr, parsenodeid(precursor), succs, 0,
2094 metadata)
2081 tr.close() 2095 tr.close()
2082 finally: 2096 finally:
2083 tr.release() 2097 tr.release()
2084 finally: 2098 finally:
2085 l.release() 2099 l.release()