--- a/hgext/qsync.py Wed May 02 14:08:21 2012 +0200
+++ b/hgext/qsync.py Fri May 04 14:33:35 2012 +0200
@@ -1,7 +1,7 @@
import re
-
from cStringIO import StringIO
+import json
from mercurial.i18n import _
from mercurial import commands
@@ -13,18 +13,12 @@
from mercurial import scmutil
from mercurial import error
from mercurial import extensions
-
-
-import re
-
-import json
-
+from mercurial import phases
### old compat code
#############################
BRANCHNAME="qsubmit2"
-OLDBRANCHNAME="pyves-qsubmit"
### new command
#############################
@@ -59,7 +53,6 @@
interleaved changeset will appear interleaved.
'''
- review = None
review = 'edit'
if opts['review_all']:
review = 'all'
@@ -67,10 +60,7 @@
try:
parent = mqrepo[BRANCHNAME]
except error.RepoLookupError:
- try:
- parent = mqrepo[OLDBRANCHNAME]
- except error.RepoLookupError:
- parent = initqsubmit(mqrepo)
+ parent = initqsubmit(mqrepo)
store, data, touched = fillstore(repo, parent)
if not touched:
raise util.Abort('Nothing changed')
@@ -78,15 +68,45 @@
# mark some as ready for review
message = 'qsubmit commit\n\n'
review_list = []
+ applied_list = []
if review:
+ olddata = get_old_data(parent)
+ oldfiles = dict([(name, ctxhex) for ctxhex, name in olddata])
+
for patch_name in touched:
try:
store.getfile(patch_name)
review_list.append(patch_name)
except IOError:
- pass
+ oldnode = oldfiles[patch_name]
+ obsolete = extensions.find('obsolete')
+ newnodes = obsolete.newerversion(repo, oldnode)
+ if newnodes:
+ newnodes = [n for n in newnodes if n] # remove killing
+ if not newnodes:
+ # changeset has been killed (eg. reject)
+ pass
+ else:
+ assert len(newnodes) == 1 # conflict!!!
+ newnode = newnodes[0]
+ assert len(newnode) == 1 # split unsupported for now
+ newnode = list(newnode)[0]
+ # XXX unmanaged case where a cs is obsoleted by an unavailable one
+ #if newnode.node() not in repo.changelog.nodemap:
+ # raise util.Abort('%s is obsoleted by an unknown node %s'% (oldnode, newnode))
+ ctx = repo[newnode]
+ if ctx.phase() == phases.public:
+ # applied
+ applied_list.append(patch_name)
+ elif ctx.phase() == phases.secret:
+ # already exported changeset is now secret
+ repo.ui.warn("An already exported changeset is now secret!!!")
+ else:
+ # draft
+ assert False, "Should be exported"
if review:
+ message += '\n'.join('* applied %s' % x for x in applied_list)
message += '\n'.join('* %s ready for review' % x for x in review_list)
memctx = patch.makememctx(mqrepo, (parent.node(), nullid),
message,
@@ -122,7 +142,7 @@
return []
def get_current_data(repo):
- """Return what would be exported if not previous data exists"""
+ """Return what would be exported if no previous data exists"""
data = []
for ctx in repo.set('draft() - (obsolete() + merge())'):
name = makename(ctx)
@@ -188,6 +208,7 @@
finaldata.sort(key=lambda x: sort_key(repo[x[0]]))
# sort touched too (ease review list)
stouched = [f[1] for f in finaldata if f[1] in touched]
+ stouched += [x for x in touched if x not in stouched]
return finaldata, stouched
def sort_key(ctx):
@@ -196,7 +217,7 @@
def fillstore(repo, basemqctx):
- """file store with patch data"""
+ """fill store with patch data"""
olddata = get_old_data(basemqctx)
newdata = get_current_data(repo)
store = patch.filestore()
@@ -207,7 +228,6 @@
store.setfile('series', series, (False, False))
# export data to ease futur work
- series ='\n'.join(d[1] for d in data) + '\n'
store.setfile('qsubmitdata', json.dumps(data, indent=True),
(False, False))
finally: