sfink avatar sfink committed 4748bd4

Add a qcrefresh command that updates the current patch with crecord

Comments (0)

Files changed (1)

crecord/__init__.py

     dorecord(ui, repo, committomq, *pats, **opts)
 
 
+def qcrefresh(ui, repo, *pats, **opts):
+    '''interactively update the current patch
+
+    See :hg:`help qrefresh` & :hg:`help crecord` for more information and
+    usage.
+    '''
+
+    try:
+        mq = extensions.find('mq')
+    except KeyError:
+        raise util.Abort(_("'mq' extension not loaded"))
+
+    def refreshmq(ui, repo, *pats, **opts):
+        mq.refresh(ui, repo, *pats, **opts)
+
+    # If the record operation (or subsequent refresh), the top applied patch
+    # will be emptied and the working directory will contain all of its
+    # changes.
+    import pdb
+    pdb.set_trace()
+    clearopts = { 'exclude': '*', 'message': '' }
+    mq.refresh(ui, repo, **clearopts)
+    dorecord(ui, repo, refreshmq, *pats, **opts)
+
+
 cmdtable = {
     "crecord":
         (crecord,
 def extsetup():
     try:
         keyword = extensions.find('keyword')
-        keyword.restricted += ' crecord qcrecord'
+        keyword.restricted += ' crecord qcrecord qcrefresh'
         try:
             keyword.recordextensions += ' crecord'
-            keyword.recordcommands += ' crecord qcrecord'
+            keyword.recordcommands += ' crecord qcrecord qcrefresh'
         except AttributeError:
             pass
     except KeyError:
         # backwards compatible with pre 301633755dec
         qnew = 'qnew'
 
+    qrefresh = '^qrefresh'
+    if not qrefresh in mq.cmdtable:
+        # backwards compatible?
+        qrefresh = 'qrefresh'
+
     qcmdtable = {
     "qcrecord":
         (qcrecord,
          [opt for opt in mq.cmdtable[qnew][1] if opt[1] != 'force'],
 
          _('hg qcrecord [OPTION]... PATCH [FILE]...')),
+
+    "qcrefresh":
+        (qcrefresh,
+
+         # sample options as qrefresh
+         mq.cmdtable[qrefresh][1],
+
+         _('hg qcrecord [OPTION]... PATCH [FILE]...')),
     }
 
     cmdtable.update(qcmdtable)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.