Commits

ZyX_I committed c4bef63

@aurum/repo, @aurum/drivers/git, @aurum/drivers/mercurial:
Added rf-push() and rf-pull()
@aurum: Added :AuOther push/pull/outgoing/incoming (untested)
Ref #4

  • Participants
  • Parent commits a42655c

Comments (0)

Files changed (6)

File doc/aurum.txt

                 Default: disabled.
     repo        Path. Repository that should be operated upon.
 
+AuOther[!] {action} [{rev}[ {repo}[ {url}]]]                        *:AuOther*
+    Push, pull or view what will be pushed or pulled. {rev} determines 
+    revision to be pushed/pulled, {url} determines where it should be pushed 
+    to/pulled from. If bang is present, then push even to unrelated 
+    repositories. Possible actions:
+    Action    Description ~
+    push      Push
+    pull      Pull
+    outgoing  View what will be pushed if you replace “outgoing” with “push”
+    incoming  View what will be pulled if you replace “incoming” with “pull”
+
 AuRecord {opts} [glob1 [...]]                                      *:AuRecord*
     Start record mode (|aurum-record|). Possible options are just the same as 
     |:AuCommit| has (except for “type” option that is absent).
   reltorepo :: path -> path                               *aurum-rf-reltorepo*
     Turn absolute or relative to current directory path into relative to 
     repository root one.
+  push :: dryrun, force[, url[, rev]] -> _                     *aurum-rf-push*
+  pull :: dryrun, force[, url[, rev]] -> _                     *aurum-rf-pull*
+    Push or pull to given or default URL. If {rev} argument is present, then 
+    push/pull only this revision. {dryrun} designates that nothing should be 
+    actually done, only what will be done should be shown.
+    Note: unlike other functions, this should expect any possible revision 
+    specification.
 The following functions do not accept repo argument:
   repo :: path -> repo                                         *aurum-rf-repo*
     Creates new repository object using repository located at given path.
     2.4: Added {requiresclean} argument to |aurum-rf-status|.
     2.5: Added parsecmdarg and crnl resources
     3.0: Moved setlines and some other functions to @aurum/lineutils
+    3.1: Added |aurum-rf-push| and |aurum-rf-pull|
 @aurum:
     0.1: Added :AuBranch and :AuName.
 @aurum/edit:

File plugin/aurum.vim

                 \                      '@/os': '0.1',
                 \           '@aurum/cmdutils': '0.0',
                 \                     '@/fwc': '0.2',
-                \               '@aurum/repo': '3.0',
+                \               '@aurum/repo': '3.1',
                 \               '@aurum/edit': '1.0',
                 \            '@aurum/bufvars': '0.0',}, 0)
     "▶2 Команды
     " TODO :AuMerge ?
     " TODO :AuExplore
     let s:addargs={'Update': {'bang': 1}, 'Move': {'bang': 1},
-                \  'Branch': {'bang': 1}, 'Name': {'bang': 1}}
+                \  'Branch': {'bang': 1}, 'Name': {'bang': 1},
+                \   'Other': {'bang': 1}}
     for s:cmd in ['Update', 'Move', 'Junk', 'Track', 'Hyperlink', 'Grep',
-                \ 'Branch', 'Name']
+                \ 'Branch', 'Name', 'Other']
         let s:part=tolower(s:cmd[:3])
         if len(s:cmd)>4 && stridx('aeiouy', s:part[-1:])!=-1
             let s:part=s:part[:-2]
             \           '} '.
             \           '+ type ""', 'filter']
 call add(s:namecomp, s:namefunc['@FWC'][0])
+"▶1 othfunc
+let s:pushactions=['push', 'outgoing']
+let s:pullactions=['pull', 'incoming']
+let s:ppactions=s:pushactions+s:pullactions
+function s:othfunc.function(bang, action, rev, repo, url)
+    let repo=s:_r.repo.get(a:repo)
+    call s:_r.cmdutils.checkrepo(repo)
+    let key=((index(s:pushactions, a:action)==-1)?('pull'):('push'))
+    return repo.functions[key](repo, (a:action[0] isnot# 'p'), a:bang,
+                \              ((a:url is# ':')?(0):(a:url)),
+                \              ((a:rev is# ':')?(0):(a:rev)))
+endfunction
+let s:othfunc['@FWC']=['-onlystrings _ '.
+            \          'in ppactions ~ smart '.
+            \          '[:":" type "" '.
+            \          '['.s:_r.cmdutils.nogetrepoarg.' '.
+            \          '[:":" type ""]]]', 'filter']
+call add(s:othcomp, substitute(s:othfunc['@FWC'][0],
+            \'\Vtype ""', s:_r.comp.rev, ''))
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File plugin/aurum/drivers/git.vim

             \  'nocfg': 'Failed to get property %s of repository %s',
             \ 'invrng': 'Range %s..%s is invalid for the repository %s, '.
             \           'as well as reverse',
+            \    'ppf': 'Failed to run “git %s” for the repository %s: %s',
         \}
 let s:git={}
 "▶1 s:hypsites
     endif
     call s:_f.throw('nocfg', a:prop, a:repo.path)
 endfunction
+"▶1 pushpull :: cmd, repo, dryrun, force[, URL[, rev]] → + ?
+function s:F.pushpull(cmd, repo, dryrun, force, ...)
+    let kwargs={'all': 1}
+    let args=[]
+    if a:0
+        if a:1 isnot 0
+            let args+=['--', a:1]
+        endif
+        if a:0>1 && a:2 isnot 0
+            if empty(args)
+                let args+=['--', 'origin']
+            endif
+            let args+=[a:2]
+            unlet kwargs.all
+        endif
+    endif
+    if a:force
+        let kwargs.force=1
+    endif
+    if a:dryrun
+        let kwargs['dry-run']=1
+    endif
+    return s:F.git(a:repo, a:cmd, args, kwargs, 0, 'ppf', a:cmd)
+endfunction
+"▶1 git.push :: repo, dryrun, force[, URL[, rev]]
+function s:git.push(...)
+    return call(s:F.pushpull, ['push']+a:000, {})
+endfunction
+"▶1 git.pull :: repo, dryrun, force[, URL[, rev]]
+function s:git.pull(...)
+    return call(s:F.pushpull, ['fetch']+a:000, {})
+endfunction
 "▶1 git.repo :: path → repo
 function s:git.repo(path)
     let repo={'path': a:path, 'changesets': {}, 'cslist': [],

File plugin/aurum/drivers/mercurial.vim

     call s:_f.throw('nocfg', a:prop, a:repo.path)
 endfunction
 endif
+"▶1 pushpull :: cmd, repo, force[, URL[, rev]] → + ?
+function s:F.pushpull(cmd, repo, force, ...)
+    let kwargs={}
+    let args=[]
+    if a:0
+        if a:1 isnot 0
+            let args+=[a:1]
+        endif
+        if a:0>1 && a:2 isnot 0
+            let kwargs.rev=''.a:2
+        endif
+    endif
+    if a:force
+        let kwargs.force=1
+    endif
+    return s:F.runcmd(a:repo, a:cmd, args, kwargs)
+endfunction
+"▶1 hg.push :: repo, dryrun, force[, URL[, rev]]
+function s:hg.push(repo, dryrun, ...)
+    return call(s:F.pushpull, [((a:dryrun)?('outgoing'):
+                \                          ('push')), a:repo]+a:000, {})
+endfunction
+"▶1 hg.pull :: repo, dryrun, force[, URL[, rev]]
+function s:hg.pull(repo, dryrun, ...)
+    return call(s:F.pushpull, [((a:dryrun)?('incoming'):
+                \                          ('pull')), a:repo]+a:000, {})
+endfunction
 "▶1 hg.repo :: path + ? → repo
 if s:usepythondriver "▶2
 function s:hg.repo(path)

File plugin/aurum/repo.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('3.0', {'@/resources': '0.0',
+    execute frawor#Setup('3.1', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
                 \                  '@/options': '0.0',
                 \           '@aurum/lineutils': '0.0',
 "▶1 regdriver feature
 let s:requiredfuncs=['repo', 'getcs', 'checkdir']
 let s:optfuncs=['readfile', 'annotate', 'diff', 'status', 'commit', 'update',
-            \   'dirty', 'diffre', 'getrepoprop', 'forget', 'branch', 'label']
+            \   'dirty', 'diffre', 'getrepoprop', 'forget', 'branch', 'label',
+            \   'push', 'pull']
 "▶2 regdriver :: {f}, name, funcs → + s:drivers
 function s:F.regdriver(plugdict, fdict, name, funcs)
     "▶3 Check arguments

File python/aurum.py

             kwargs['force']=bool(kwargs['force'])
         else:
             kwargs['force']=False
-        cargs=[PrintUI(), repo]
+        if 'bundle' not in kwargs:
+            kwargs['bundle']=None
+        cargs=[repo.ui, repo]
         cargs.extend(args)
         run_in_dir(repo.root, commands.__getattribute__(attr),
                    *cargs, **kwargs)