hgext/evolve.py
branchstable
changeset 1055 cfe1b9d3e5d9
parent 1054 93e920feff5e
child 1058 00bc31523074
child 1061 f3867e60d072
equal deleted inserted replaced
1054:93e920feff5e 1055:cfe1b9d3e5d9
   931 
   931 
   932 @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
   932 @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
   933 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
   933 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
   934     extracted = patch.extract(ui, hunk)
   934     extracted = patch.extract(ui, hunk)
   935     expected = extracted[5]
   935     expected = extracted[5]
   936     expected = node.bin(expected)
   936     if extracted is not None:
       
   937         expected = node.bin(expected)
   937     oldextract = patch.extract
   938     oldextract = patch.extract
   938     try:
   939     try:
   939         patch.extract = lambda ui, hunk: extracted
   940         patch.extract = lambda ui, hunk: extracted
   940         ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
   941         ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
   941     finally:
   942     finally:
   942         patch.extract = oldextract
   943         patch.extract = oldextract
   943     created = ret[1]
   944     created = ret[1]
   944     if opts['obsolete'] and created is not None and created != expected:
   945     if (opts['obsolete'] and None not in (created, expected)
       
   946         and created != expected):
   945             tr = repo.transaction('import-obs')
   947             tr = repo.transaction('import-obs')
   946             try:
   948             try:
   947                 metadata = {'user': ui.username()}
   949                 metadata = {'user': ui.username()}
   948                 repo.obsstore.create(tr, expected, (created,),
   950                 repo.obsstore.create(tr, expected, (created,),
   949                                      metadata=metadata)
   951                                      metadata=metadata)