Mercurial > hg
comparison hgext/mq.py @ 6217:fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
author | Joel Rosdahl <joel@rosdahl.net> |
---|---|
date | Thu, 06 Mar 2008 22:51:16 +0100 |
parents | 272fd5fa576d |
children | 949e607ac544 |
comparison
equal
deleted
inserted
replaced
6216:a88259018f79 | 6217:fe8dbbe9520d |
---|---|
28 remove patch from applied stack qpop | 28 remove patch from applied stack qpop |
29 refresh contents of top applied patch qrefresh | 29 refresh contents of top applied patch qrefresh |
30 ''' | 30 ''' |
31 | 31 |
32 from mercurial.i18n import _ | 32 from mercurial.i18n import _ |
33 from mercurial.node import bin, hex, short | |
34 from mercurial.repo import RepoError | |
33 from mercurial import commands, cmdutil, hg, patch, revlog, util | 35 from mercurial import commands, cmdutil, hg, patch, revlog, util |
34 from mercurial import repair | 36 from mercurial import repair |
35 import os, sys, re, errno | 37 import os, sys, re, errno |
36 | 38 |
37 commands.norepo += " qclone" | 39 commands.norepo += " qclone" |
1252 if lines[i] == 'Patch Data:': | 1254 if lines[i] == 'Patch Data:': |
1253 datastart = i + 1 | 1255 datastart = i + 1 |
1254 elif lines[i].startswith('Dirstate:'): | 1256 elif lines[i].startswith('Dirstate:'): |
1255 l = lines[i].rstrip() | 1257 l = lines[i].rstrip() |
1256 l = l[10:].split(' ') | 1258 l = l[10:].split(' ') |
1257 qpp = [ hg.bin(x) for x in l ] | 1259 qpp = [ bin(x) for x in l ] |
1258 elif datastart != None: | 1260 elif datastart != None: |
1259 l = lines[i].rstrip() | 1261 l = lines[i].rstrip() |
1260 se = statusentry(l) | 1262 se = statusentry(l) |
1261 file_ = se.name | 1263 file_ = se.name |
1262 if se.rev: | 1264 if se.rev: |
1275 heads = repo.changelog.heads() | 1277 heads = repo.changelog.heads() |
1276 if delete: | 1278 if delete: |
1277 if rev not in heads: | 1279 if rev not in heads: |
1278 self.ui.warn("save entry has children, leaving it alone\n") | 1280 self.ui.warn("save entry has children, leaving it alone\n") |
1279 else: | 1281 else: |
1280 self.ui.warn("removing save entry %s\n" % hg.short(rev)) | 1282 self.ui.warn("removing save entry %s\n" % short(rev)) |
1281 pp = repo.dirstate.parents() | 1283 pp = repo.dirstate.parents() |
1282 if rev in pp: | 1284 if rev in pp: |
1283 update = True | 1285 update = True |
1284 else: | 1286 else: |
1285 update = False | 1287 update = False |
1286 self.strip(repo, rev, update=update, backup='strip') | 1288 self.strip(repo, rev, update=update, backup='strip') |
1287 if qpp: | 1289 if qpp: |
1288 self.ui.warn("saved queue repository parents: %s %s\n" % | 1290 self.ui.warn("saved queue repository parents: %s %s\n" % |
1289 (hg.short(qpp[0]), hg.short(qpp[1]))) | 1291 (short(qpp[0]), short(qpp[1]))) |
1290 if qupdate: | 1292 if qupdate: |
1291 self.ui.status(_("queue directory updating\n")) | 1293 self.ui.status(_("queue directory updating\n")) |
1292 r = self.qrepo() | 1294 r = self.qrepo() |
1293 if not r: | 1295 if not r: |
1294 self.ui.warn("Unable to load queue repository\n") | 1296 self.ui.warn("Unable to load queue repository\n") |
1309 else: | 1311 else: |
1310 msg = "hg patches: " + msg.rstrip('\r\n') | 1312 msg = "hg patches: " + msg.rstrip('\r\n') |
1311 r = self.qrepo() | 1313 r = self.qrepo() |
1312 if r: | 1314 if r: |
1313 pp = r.dirstate.parents() | 1315 pp = r.dirstate.parents() |
1314 msg += "\nDirstate: %s %s" % (hg.hex(pp[0]), hg.hex(pp[1])) | 1316 msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) |
1315 msg += "\n\nPatch Data:\n" | 1317 msg += "\n\nPatch Data:\n" |
1316 text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and | 1318 text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and |
1317 "\n".join(ar) + '\n' or "") | 1319 "\n".join(ar) + '\n' or "") |
1318 n = repo.commit(None, text, user=None, force=1) | 1320 n = repo.commit(None, text, user=None, force=1) |
1319 if not n: | 1321 if not n: |
1595 dest = hg.defaultdest(source) | 1597 dest = hg.defaultdest(source) |
1596 sr = hg.repository(ui, ui.expandpath(source)) | 1598 sr = hg.repository(ui, ui.expandpath(source)) |
1597 patchespath = opts['patches'] or patchdir(sr) | 1599 patchespath = opts['patches'] or patchdir(sr) |
1598 try: | 1600 try: |
1599 pr = hg.repository(ui, patchespath) | 1601 pr = hg.repository(ui, patchespath) |
1600 except hg.RepoError: | 1602 except RepoError: |
1601 raise util.Abort(_('versioned patch repository not found' | 1603 raise util.Abort(_('versioned patch repository not found' |
1602 ' (see qinit -c)')) | 1604 ' (see qinit -c)')) |
1603 qbase, destrev = None, None | 1605 qbase, destrev = None, None |
1604 if sr.local(): | 1606 if sr.local(): |
1605 if sr.mq.applied: | 1607 if sr.mq.applied: |