comparison mercurial/localrepo.py @ 22928:5e5d297ccbd0

localrepo: access status fields by name rather than index
author Martin von Zweigbergk <martinvonz@gmail.com>
date Fri, 03 Oct 2014 13:22:31 -0700
parents 4f2a5c7cdf78
children 03602f76deee
comparison
equal deleted inserted replaced
22927:7d754b7acd55 22928:5e5d297ccbd0
1233 if (not force and merge and match and 1233 if (not force and merge and match and
1234 (match.files() or match.anypats())): 1234 (match.files() or match.anypats())):
1235 raise util.Abort(_('cannot partially commit a merge ' 1235 raise util.Abort(_('cannot partially commit a merge '
1236 '(do not specify files or patterns)')) 1236 '(do not specify files or patterns)'))
1237 1237
1238 changes = self.status(match=match, clean=force) 1238 status = self.status(match=match, clean=force)
1239 if force: 1239 if force:
1240 changes[0].extend(changes[6]) # mq may commit unchanged files 1240 status.modified.extend(status.clean) # mq may commit clean files
1241 1241
1242 # check subrepos 1242 # check subrepos
1243 subs = [] 1243 subs = []
1244 commitsubs = set() 1244 commitsubs = set()
1245 newstate = wctx.substate.copy() 1245 newstate = wctx.substate.copy()
1246 # only manage subrepos and .hgsubstate if .hgsub is present 1246 # only manage subrepos and .hgsubstate if .hgsub is present
1247 if '.hgsub' in wctx: 1247 if '.hgsub' in wctx:
1248 # we'll decide whether to track this ourselves, thanks 1248 # we'll decide whether to track this ourselves, thanks
1249 for c in changes[:3]: 1249 for c in status.modified, status.added, status.removed:
1250 if '.hgsubstate' in c: 1250 if '.hgsubstate' in c:
1251 c.remove('.hgsubstate') 1251 c.remove('.hgsubstate')
1252 1252
1253 # compare current state to last committed state 1253 # compare current state to last committed state
1254 # build new substate based on last committed state 1254 # build new substate based on last committed state
1282 if subs: 1282 if subs:
1283 if (not match('.hgsub') and 1283 if (not match('.hgsub') and
1284 '.hgsub' in (wctx.modified() + wctx.added())): 1284 '.hgsub' in (wctx.modified() + wctx.added())):
1285 raise util.Abort( 1285 raise util.Abort(
1286 _("can't commit subrepos without .hgsub")) 1286 _("can't commit subrepos without .hgsub"))
1287 changes[0].insert(0, '.hgsubstate') 1287 status.modified.insert(0, '.hgsubstate')
1288 1288
1289 elif '.hgsub' in changes[2]: 1289 elif '.hgsub' in status.removed:
1290 # clean up .hgsubstate when .hgsub is removed 1290 # clean up .hgsubstate when .hgsub is removed
1291 if ('.hgsubstate' in wctx and 1291 if ('.hgsubstate' in wctx and
1292 '.hgsubstate' not in changes[0] + changes[1] + changes[2]): 1292 '.hgsubstate' not in (status.modified + status.added +
1293 changes[2].insert(0, '.hgsubstate') 1293 status.removed)):
1294 status.removed.insert(0, '.hgsubstate')
1294 1295
1295 # make sure all explicit patterns are matched 1296 # make sure all explicit patterns are matched
1296 if not force and match.files(): 1297 if not force and match.files():
1297 matched = set(changes[0] + changes[1] + changes[2]) 1298 matched = set(status.modified + status.added + status.removed)
1298 1299
1299 for f in match.files(): 1300 for f in match.files():
1300 f = self.dirstate.normalize(f) 1301 f = self.dirstate.normalize(f)
1301 if f == '.' or f in matched or f in wctx.substate: 1302 if f == '.' or f in matched or f in wctx.substate:
1302 continue 1303 continue
1303 if f in changes[3]: # missing 1304 if f in status.deleted:
1304 fail(f, _('file not found!')) 1305 fail(f, _('file not found!'))
1305 if f in vdirs: # visited directory 1306 if f in vdirs: # visited directory
1306 d = f + '/' 1307 d = f + '/'
1307 for mf in matched: 1308 for mf in matched:
1308 if mf.startswith(d): 1309 if mf.startswith(d):
1310 else: 1311 else:
1311 fail(f, _("no match under directory!")) 1312 fail(f, _("no match under directory!"))
1312 elif f not in self.dirstate: 1313 elif f not in self.dirstate:
1313 fail(f, _("file not tracked!")) 1314 fail(f, _("file not tracked!"))
1314 1315
1315 cctx = context.workingctx(self, text, user, date, extra, changes) 1316 cctx = context.workingctx(self, text, user, date, extra, status)
1316 1317
1317 if (not force and not extra.get("close") and not merge 1318 if (not force and not extra.get("close") and not merge
1318 and not cctx.files() 1319 and not cctx.files()
1319 and wctx.branch() == wctx.p1().branch()): 1320 and wctx.branch() == wctx.p1().branch()):
1320 return None 1321 return None
1321 1322
1322 if merge and cctx.deleted(): 1323 if merge and cctx.deleted():
1323 raise util.Abort(_("cannot commit merge with missing files")) 1324 raise util.Abort(_("cannot commit merge with missing files"))
1324 1325
1325 ms = mergemod.mergestate(self) 1326 ms = mergemod.mergestate(self)
1326 for f in changes[0]: 1327 for f in status.modified:
1327 if f in ms and ms[f] == 'u': 1328 if f in ms and ms[f] == 'u':
1328 raise util.Abort(_("unresolved merge conflicts " 1329 raise util.Abort(_("unresolved merge conflicts "
1329 "(see hg help resolve)")) 1330 "(see hg help resolve)"))
1330 1331
1331 if editor: 1332 if editor: