comparison mercurial/obsolete.py @ 32327:3546a771e376

obsolete: add operation metadata to rebase/amend/histedit obsmarkers By recording what operation created the obsmarker, we can show very intuitive messages to the user in various UIs. For instance, log output could have messages like "Amended as XXX" to show why a commit is old and has an 'x' on it. @ ac28e3 durham / First commit | | o d4afe7 durham | | Second commit | | | x 8e9a5d (Amended as ac28e3) durham |/ First commit |
author Durham Goode <durham@fb.com>
date Tue, 09 May 2017 16:29:31 -0700
parents 7c3ef55dedbe
children 566cfe9cbbb9
comparison
equal deleted inserted replaced
32325:763d72925691 32327:3546a771e376
1201 break 1201 break
1202 toprocess.update(obsstore.precursors.get(prec, ())) 1202 toprocess.update(obsstore.precursors.get(prec, ()))
1203 return divergent 1203 return divergent
1204 1204
1205 1205
1206 def createmarkers(repo, relations, flag=0, date=None, metadata=None): 1206 def createmarkers(repo, relations, flag=0, date=None, metadata=None,
1207 operation=None):
1207 """Add obsolete markers between changesets in a repo 1208 """Add obsolete markers between changesets in a repo
1208 1209
1209 <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) 1210 <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}])
1210 tuple. `old` and `news` are changectx. metadata is an optional dictionary 1211 tuple. `old` and `news` are changectx. metadata is an optional dictionary
1211 containing metadata for this marker only. It is merged with the global 1212 containing metadata for this marker only. It is merged with the global
1222 # prepare metadata 1223 # prepare metadata
1223 if metadata is None: 1224 if metadata is None:
1224 metadata = {} 1225 metadata = {}
1225 if 'user' not in metadata: 1226 if 'user' not in metadata:
1226 metadata['user'] = repo.ui.username() 1227 metadata['user'] = repo.ui.username()
1228 if operation:
1229 metadata['operation'] = operation
1227 tr = repo.transaction('add-obsolescence-marker') 1230 tr = repo.transaction('add-obsolescence-marker')
1228 try: 1231 try:
1229 markerargs = [] 1232 markerargs = []
1230 for rel in relations: 1233 for rel in relations:
1231 prec = rel[0] 1234 prec = rel[0]